react-native-navigation
react-native-navigation copied to clipboard
iOS: Navigation.pop promise doesn't resolve and componentWillUnmount doesn't run as expected
🐛 Bug Report
I ran into an issue where an ActivityIndicator displayed in a FlatList prevents a screen Navigation.push'ed on top and then Navigation.pop'ped from properly unmounting - Navigation.pop promise doesn't resolve and componentWillUnmount doesn't run.
I have compiled my initial findings in this comment: https://github.com/wix/react-native-navigation/issues/5348#issuecomment-1088695792
As described in the linked comment, Navigation.pop promise doesn't resolve unless some additional actions are performed and componentWillUnmount of the popped screen doesn't run.
I have also prepared a minimal reproducible example, which can be found here: https://github.com/Caundy/rnn-unmount-bug-reproduction
Have you read the Contributing Guidelines on issues?
Yes.
To Reproduce
- Clone the repository at https://github.com/Caundy/rnn-unmount-bug-reproduction
- run yarn
- run cd ios && pod install
- run cd .. && npx react-native run-ios
- After the app has started, press on the Open item 0's details
- On the Detail screen, press Go back, which triggers Navigation.pop with Detail screen's componentId as an argument
- Observe Navigation.pop not resolving and code in componentWillUnmount of the Detail screen not running (which would be expected at this point)
- Once again, press on the Open item 0's details, which Navigation.push'es the Detail screen into the stack
- Observe Navigation.pop resolving and componentWillUnmount running of the previously popped screen running
Additionally, this behaviour can't be observed when using the topBar's back button to dismiss the Detail screen.
Expected behavior
Navigation.pop should resolve or reject and componentWillUnmount should run, regardless of whether an ActivityIndicator is present or not in the underlying screen's FlatList. I am not 100% clear on the actual cause of this behaviour but having an ActivityIndicator appears to allow reproducing it reliably.
Actual Behavior
In the provided scenario, Navigation.pop doesn't resolve or reject and componentWillUnmount of the popped screen doesn't run unless additional actions are taken.
Your Environment
- React Native Navigation version: "^7.26.0"
- React Native version: "0.63.4"
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): simulator and physical device (i.e. iPhone 8+ running iOS 15.1)
Reproducible Demo
https://github.com/Caundy/rnn-unmount-bug-reproduction
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Running into the same issue myself. In my case I am trying to run a cleanup in a useEffect with an empty dependency array, and it doesn't run sometimes whenever I pop. However, it does run when I go back to the same screen, but it runs after the new instance of the same screen mounts, meaning it runs too late.
@Caundy Any workarounds you might have figured out for this?
@hmust92 Sorry for the delay, you've probably tackled this already :)
Given that the cause appeared to have been the ActivityIndicator's animation or its presence, I simply made sure it's not being rendered in the FlatList's footer when opening the details screen that runs some cleanup code on unmount.
Not happy with having to use that type of workaround but it does get the job done
any update on this? I'm having the same issue.
- if I swipe the screen to go back it will trigger componentWillUnMount
- if I call Navigation.Pop() it not trigger componentWillUnMount
++++++++
I have same issue with RN 0.70.6 & react-native-navigation 7.32.1. any update?