Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independant navigator feature is broken #9080

Closed
Njaah-0 opened this issue Nov 19, 2020 · 3 comments
Closed

Independant navigator feature is broken #9080

Njaah-0 opened this issue Nov 19, 2020 · 3 comments

Comments

@Njaah-0
Copy link

Njaah-0 commented Nov 19, 2020

this issue is about advanced but undocumented <NavigationContainer independent={true} /> feature. We use it on purpose, and our goal is not to achieve regular nested navigation.

Current Behavior
When using <NavigationContainer independent={true} />, the code will crash or give invalid results when you attempt to use any of the *RootState functions provided by the navigation ref. Eg. getRootState, resetRoot etc. getCurrentRoute is also affected, as it uses getRootState.

Issue is caused by the state not having root key at all. resetRoot used to work before 5.14, as it operated directly on state. Now it tries to get root value from state and throws NOT_INITIALIZED_ERROR.

resetRoot -> crash
getRootState -> undefined
getCurrentRoute -> undefined

It also seems that onStateChange is never called with state value.

Expected Behavior

*RootState functions should work correctly and operate on the root state of the independant navigation.

How to reproduce

By using independent={true} and trying to use functions mentioned above.
https://snack.expo.io/@njaah/react-navigation---independant

Your Environment

software version
iOS or Android Both + web + Windows
@react-navigation/native 5.7.6 (5.8.9 in Snack)
react-native 0.62.2
expo Not used (39 in Snack)
node 12.3
npm or yarn 1.22.5
@Njaah-0 Njaah-0 added the bug label Nov 19, 2020
@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 5.7.0, latest: 5.8.9)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 5.7.6, latest: 5.8.9)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@Njaah-0
Copy link
Author

Njaah-0 commented Nov 19, 2020

Here's the commit that changed resetRoot to cause a crash.
e50c8aa

Our @react-navigation/* versions are not latest because we are forced to lock the core version to 5.13.2, in order to avoid crashing the app. However, the Snack I provided is using the latest versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant