react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Navigation.events().bindComponent not working after setRoot for the second time

Open Komeyl94 opened this issue 7 years ago • 6 comments

Issue Description

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?


Environment

  • React Native Navigation version: 2.22.3
  • React Native version: 0.59.8
  • Platform(s) (iOS, Android, or both?): Tested only on Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Google Nexus 5X Android 7.1.0 Genymotion Emulator - Debug & Release

Komeyl94 avatar Aug 24 '19 12:08 Komeyl94

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 avatar Aug 24 '19 16:08 phuhk

@phuhk thanks a lot, your solution worked

Komeyl94 avatar Aug 25 '19 06:08 Komeyl94

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.

stale[bot] avatar Sep 24 '19 07:09 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Oct 01 '19 07:10 stale[bot]

same issue

ashish-lonare avatar Jan 03 '20 09:01 ashish-lonare

Same issue..

agestaun avatar Jan 25 '23 12:01 agestaun