react-native-screens: Multiple transitions between screens causes app to crash
Description
Repeated navigation between 2 screens using React Navigation’s Native Stack with a getId() prop causes the app to “crash”. I use the term crash loosely as the behaviour is different per platform but both result in the app becoming unusable.
iOS
react-native elements that use Pressibility become stuck in their “onPress” state, preventing them from receiving further onPress events. The issue does not occur with non-Pressibility elements such as <TouchableOpacity />.
You can observe this behaviour with the reproduction snack by repeatedly moving between the two screens using the Forwards/Backwards <Text /> items. After 3 transitions, the <Text /> items are no longer pressable and will be rendered with their onPress highlighting.
Android
After 3 transitions, the native stack header will disappear. After 4 transitions, the native stack will no longer render any visible context.
Expo Router issue: https://github.com/expo/expo/issues/33658 React Navigation issue: https://github.com/react-navigation/react-navigation/issues/12346
Steps to reproduce
- Open Snack
- Click “forwards” / “backwards” 3-5 times
Snack or a link to a repository
https://snack.expo.dev/@mwlawlor/react-navigation-native-stack-stuck
Screens version
3.3.0
React Native version
0.76.3
Platforms
Android, iOS
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 25
- Comments: 28 (6 by maintainers)
I am quite concerned that this issue is not getting more priority. 😟
Using Expo (or RN), it is really a problem if solid navigation cannot be guaranteed. Navigating between screens is such a core feature to any app.
We will release our Expo app pretty soon to production and I am not sure how to explain to stakeholders that something basic such as navigating is able to crash. 😅
Reading the previous comments, it seems there is not really a solid workaround yet? Or did someone had success with replacing all
<Pressable/ >with<TouchableOpacity />or only usingrouter.push()?Thanks in advance for any help on this!
I just wanna update that I’m looking into the issue. However current approach is to forbid certain kinds of navigation patters as they do not make much sense on stack-based navigator. I’m building the case 😅
The same problem happens to me using expo-router , it’s a game stopper. Using tab with a stack for each tab . When i navigate back and forth within the stack / to different stacks , the stack becomes blank . It gets dismissed somehow. One time touchable opacity within the stack became unclickable . I tried a mix of router.push , router.replace , router.navigate . I ended up using push but it didn’t fix all the problem . Tho it happens less now . I am on Android .
Running into this issue as well. Is this going to be addressed?
I am also facing this issue on Android. On iOS everything works fine.
When I navigate back to the same screen with the same
getId, I observe the described behavior. However, in my actual app, where I have a lot of integrations, this issue results in a crash with the following error:The temporary fix working for me now on Android is conditionally using
navigateDeprecatedif Platform is Android:navigation.navigateDeprecated(name, params);This is causing Pizzahuts app to freeze on IOS 18 devices and simulators.
It still happens in expo SDK 53, Android only, app crashes with
We have Tab bar, each has a stack inside. On the main tab we have a banner at the top of the page that takes user to another tab
router.navigate('/anotherTab');. This works fine if stack inanotherTabis at the root, but if user was inanotherTabbefore, navigated to a nested screen then used tab bar to go back to main tab and used that banner that callsrouter.navigate('/anotherTab');it will crash. iOS works fine and takes user back to root of another tab. I know it is somewhat an anti-pattern and bad UX to switch tabs like that, but it should still work.jumping to start RN for a day and already found this kind of bug LMAO 😺
@marklawlor it has not been resolved in SDK 53, it’s still there. Just tested it (expo 53.0.9). There is an open issue assigned to you https://github.com/expo/expo/issues/33658#issuecomment-2878154551 (from December 13 2024) which is essentially the same bug. I wonder when it gets prioritized as this is a blocker for anyone who want to use New Architecture.
Just an update on our situation.
We are on “react-native-screens”: “~3.29.0”
We experienced a bug that switching to a certain tab would freeze our app on IOS only.
We fixed it by switching to .replace instead of .navigate.
Facing the same issue right now