TMD
TMD

Reputation: 325

after using react-navigation-redux, get the warning

version: "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" },

After using the latest version of react-navigation with redux, i get the message:

'Warning: isMounted(...) is deprecated in plain JavaScript React classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.' I didn't use isMounted in my code.

I don't know why this happen. I haven't get this message before.

Need some help, please.

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);

Upvotes: 2

Views: 553

Answers (2)

Nandam Mahesh
Nandam Mahesh

Reputation: 1278

Indeed, its react-navigation issue (https://github.com/react-navigation/react-navigation/issues/3956),

still the next release, you can solve the issue using below:

import { YellowBox } from 'react-native';

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

Upvotes: 1

Yevhen Baidiuk
Yevhen Baidiuk

Reputation: 11

Library that you use have this dependency. try update deprecated packages : npm outdated - (will show you all packages that can be updated)

if all packages updated : Wait for new version or go back to : "react": "16.3.0-rc.0", "react-native": "0.54.3",

Upvotes: 1

Related Questions