代码之家  ›  专栏  ›  技术社区  ›  TMD

使用react navigation redux后,获取警告

  •  2
  • TMD  · 技术社区  · 6 年前

    版本: "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);
    
    2 回复  |  直到 6 年前
        1
  •  1
  •   Nandam Mahesh    6 年前

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

    在下一版本中,您可以使用以下方法解决此问题:

    从“react native”导入{YellowBox};

    黄箱。忽略警告(['Warning:isMounted(…)已弃用“]);

        2
  •  1
  •   Yevhen Baidiuk    6 年前

    您使用的库具有此依赖关系。 尝试更新不推荐的包: npm过时-(将显示所有可更新的包)

    如果更新了所有程序包:等待新版本或返回: “react”:“16.3.0-rc.0”, “react native”:“0.54.3”,