版本:
"dependencies": {
"prop-types": "^15.6.1",
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-elements": "^0.19.1",
"react-navigation": "^1.5.11",
"react-navigation-redux-helpers": "^1.0.5",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
使用最新版本的
react-navigation
具有
redux
,我得到消息:
'警告:已装载(…)在普通JavaScript React类中不推荐使用。相反,请确保清除componentWillUnmount中的订阅和挂起的请求,以防止内存泄漏。”
我没有使用
isMounted(已安装)
在我的代码中。
我不知道为什么会这样。
我以前没有收到过这个消息。
需要帮忙吗。
import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import PropTypes from 'prop-types';
import {View, Text, Button} from 'react-native';
import {handleNav} from '../../actions/navAction';
import styles from '../styles/styles';
const Login = ({handleNav}) => (
<View style={styles.container}>
<Text>Login Page</Text>
<Text>Login Page</Text>
<Text>Login Page</Text>
<Text>Login Page</Text>
<Text>Login Page</Text>
<Text>Login Page</Text>
<Button
title = {'Login Button'}
onPress = {handleNav.bind(null, 'MAIN')}
/>
<Button
title={'go to register page'}
onPress={handleNav.bind(null, 'REGISTER')}
/>
</View>
);
Login.propTypes = {
handleNav:PropTypes.func,
};
const mapDispatchToProps = dispatch => bindActionCreators({handleNav},dispatch);
export default connect(null, mapDispatchToProps)(Login);