I've used setRoot when switching users in my app, but the problem is that after switching it seems that the navigation events doesn't bind again, so as a result non of the lifecycle methods (didAppear & didDisappear) works!
Does anybody know what could be the problem?
Same here, because when you setRoot, componentDidMount of "new Component instance" call first, then componentWillUnmount of "old Component instance" call later, which trigger unmounted function of ComponentEventsObserver class (check code in react-native-navigation/events), which should remove all your listener.
Work around here, try to setRoot to some temp root screen, thanks for setRoot return Promise, so you can know setRoot complete, then you can set it to your real root screen.
@phuhk thanks a lot, your solution worked
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.
same issue
Most helpful comment
Same here, because when you
setRoot,componentDidMountof "new Component instance" call first, thencomponentWillUnmountof "old Component instance" call later, which triggerunmountedfunction ofComponentEventsObserverclass (check code in react-native-navigation/events), which should remove all your listener.Work around here, try to
setRootto some temp root screen, thanks forsetRootreturn Promise, so you can knowsetRootcomplete, then you can set it to your real root screen.