【发布时间】:2018-04-11 13:17:07
【问题描述】:
版本:
"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 后,我收到消息:
'警告:isMounted(...) 在纯 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);
【问题讨论】:
-
您能否发布您的
redux navigation setup的代码,以及您如何处理react navigation listener?
标签: react-native react-navigation