Hi! If I have a ListView and I go to any item who goes to new scene, and insde it I press back button and quickly I go to another item the item component is not unmounted thus the component preserves data from the last item. This is because the component is not unmounted immediately. Why ocurrs that? I need that the scene is unmounted to get new values and use the normal lifecycle of component.
Many thanks!
I face the same issue. In my case, I have a timeout which is cleared when the component is unmounted. Since unmounting is happening late, the mentioned timeout is being cleared late too, and this is causing an undesirable behavior.
Is there any plan to fix this behavior soon?
There are some past issues related:
https://github.com/aksonov/react-native-router-flux/issues/1254
https://github.com/aksonov/react-native-router-flux/issues/800
@manask88 any solution?
Also need for a solution :(
@arnsa i found that transitioning with Actions.key({type: 'replace'}) ensures that the component you are transitioning from unmounts. then when navigating you just need to ensure that on back you override Actions.pop() and transition back to the previous component because replace will remove the scene from the stack
@bulkyracehorse512 hm, interesting. But could you please show me how have you overriden pop() action? I am not sure how to do that.
@arnsa for android in the component you are are transitioning to:
componentWillUnmount() {
BackAndroid.removeEventListener('hardwareBackPress', this._onBack);
}
componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress', this._onBack);
}
where _onBack() transitions back to the previous component. for iOS, you would just override back in the nav bar
not sure that this is the best way to approach the issue, but it's the only thing i've tried that's worked
+1
+1
+1
Most helpful comment
I face the same issue. In my case, I have a timeout which is cleared when the component is unmounted. Since unmounting is happening late, the mentioned timeout is being cleared late too, and this is causing an undesirable behavior.
Is there any plan to fix this behavior soon?
There are some past issues related:
https://github.com/aksonov/react-native-router-flux/issues/1254
https://github.com/aksonov/react-native-router-flux/issues/800