-
-
Notifications
You must be signed in to change notification settings - Fork 597
Open
Labels
Missing infoThe user didn't precise the problem enoughThe user didn't precise the problem enoughMissing reproThis issue need minimum repro scenarioThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOSThis issue is specific to iOS
Description
Description
When navigating with CommonActions.reset to remove multiple screens from the stack on iOS, the app crashes with:
RCTComponentViewRegistry: Attempt to recycle a mounted view
This happens in two scenarios:
- Login redirect: After login, I reset the stack to redirect the user into the
TabNavigator. - Nested navigation reset: Inside a tab stack (HomeTab), when moving forward from
ScreenBtoScreenCwhile removingScreenAandScreenBfrom the stack.
On Android this works as expected. The crash only occurs on iOS.
Navigation hierarchy
RootStack
│
├── Login
├── Otp
└── TabNavigator
├── HomeTab
│ └── HomeStack
│ ├── HomeScreen
│ ├── ScreenA
│ ├── ScreenB <-- starting point
│ └── ScreenC <-- destination
│
├── SalesTab
│ └── SalesStack
│ ├── SalesScreen
│ ├── ScreenX
│ └── ScreenY
│
└── SettingsTab
└── SettingsStack
├── SettingsScreen
└── ...
Environment
- React Native:
0.81.0 - React Navigation:
7.0.14 - @react-navigation/native-stack:
7.2.0 - @react-navigation/stack:
7.1.1 - react-native-screens:
^4.9.1 - @react-navigation/bottom-tabs:
^7.2.0
Steps to Reproduce
-
RootStack contains:
AuthScreen(no AuthStack wrapper)TabNavigator(no AppStack wrapper)- Each tab has its own stack.
-
After login
navigation.reset({ index: 0, routes: [{ name, params }], });
→ Works fine most of the time.
-
In HomeTab
- Start on
HomeScreen. - Navigate:
HomeScreen → ScreenA → ScreenB. - From
ScreenB, navigate toScreenCwhile removing ScreenB and ScreenA.
Code:
navigation.dispatch(state => { const keepUntil = Math.max(0, state.routes.length - 2); const remainingRoutes = state.routes.slice(0, keepUntil).map(route => ({ name: route.name, params: route.params, })); const routes = [...remainingRoutes, { name: 'screenC', params: {} }]; return CommonActions.reset({ ...state, routes, index: routes.length - 1, }); });
- Start on
-
Expected stack:
HomeScreen → ScreenC. -
Actual behavior: iOS crashes with:
RCTComponentViewRegistry: Attempt to recycle a mounted view
Snack or a link to a repository
Screens version
4.9.1
React Native version
0.81.0
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Fabric (New Architecture)
Build type
Debug mode
Device
Real device
Device model
iPhone 14
Acknowledgements
Yes
Metadata
Metadata
Assignees
Labels
Missing infoThe user didn't precise the problem enoughThe user didn't precise the problem enoughMissing reproThis issue need minimum repro scenarioThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOSThis issue is specific to iOS
