【问题标题】:after using react-navigation-redux, get the warning使用 react-navigation-redux 后,得到警告
【发布时间】: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-navigationredux 后,我收到消息:

'警告: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


【解决方案1】:

确实,它的反应导航问题 (https://github.com/react-navigation/react-navigation/issues/3956),

仍然是下一个版本,您可以使用以下方法解决问题:

从 'react-native' 导入 { YellowBox };

YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated']);

【讨论】:

【解决方案2】:

您使用的库具有此依赖关系。 尝试更新已弃用的软件包: npm outdated - (将显示所有可以更新的包)

如果所有软件包都更新了:等待新版本或返回: “反应”:“16.3.0-rc.0”, "react-native": "0.54.3",

【讨论】:

猜你喜欢
  • 2023-04-03
  • 2021-05-20
  • 1970-01-01
  • 1970-01-01
  • 2017-08-09
  • 1970-01-01
  • 2018-04-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多