async SetState in componentDidMount() warning in React Native

Viewed 1878

The warning message says:

"Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op."

The code caused it:

async componentDidMount() {
  const token = await AsyncStorage.getItem('google_token');

  if (token) {
    this.props.navigation.navigate('feed');
    this.setState({ token });
  } else {
    this.setState({ token: false });
  }
 }

After some google, I'm really confused on if I should be worried about this warning. How can I get the warning message away without disabling the rule like this Github issue suggested ?

1 Answers
Related