0

i'm currently executing this.props.navigation.navigate('myView') using react-navigation.

But when i leave and enter quickly to that view, in some cases a strange behavior occurs in the react-native life cycle.

My logs:

*When works normally:

- Navigate to `myView`
  componentWillMount >>>>>>>>> 

- Back from `myView`
  componentWillUnmount >>>>>>>>> 

*When i navigate quickly:

- Navigate to `myView`
  componentWillMount >>>>>>>>> 

- Back from `myView`
  componentWillUnmount >>>>>>>>> 

- Quick navigate to `myView`
  componentWillMount >>>>>>>>> 
  componentWillMount >>>>>>>>> 
  componentWillUnmount >>>>>>>>> 

At the end of this case, the unmount is running and leaving the view in an incorrect state.

jose920405
  • 7,982
  • 6
  • 45
  • 71
  • I believe this issue has been solved in v3, which version are you running? – dentemm Dec 13 '18 at 15:16
  • :O.. thanks.. i'm running `2.0.4`. Is recommended upgrade to `v3`? I'm asking because is an `alpha` version. Anyway, I'll try it and if that version solves the problem, I'll consider leaving the update. – jose920405 Dec 13 '18 at 15:55
  • The update is pretty straightforward, you only need to add one extra step in your main routes config. – dentemm Dec 13 '18 at 19:42
  • ok, thanks. The truth is that what worries me is the stability of that version, not the changes I have to make in my code. – jose920405 Dec 13 '18 at 20:04
  • Which version of react are you using? componentWillMount is going to be deprecated and there is new life-cycle events implemented. For more info please check [React Component API](https://reactjs.org/docs/react-component.html#unsafe_componentwillmount) – bennygenel Dec 13 '18 at 22:58
  • `"react": "16.0.0", "react-native": "0.51.0"`. This will continue to work until the `17` version and I'm on the 16. This should have no impact on the problem in question – jose920405 Dec 14 '18 at 12:56

0 Answers0