Open matpoz opened 3 weeks ago
I have the same issue on react native 0.72.2 and similar navigation packages version.
@matpoz why did you close it? you found another solution?
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.
@AptypTheKing I found this in the v5 to v6 migration guide: https://reactnavigation.org/docs/upgrading-from-5.x/#no-more-state-property-on-the-route-prop
"The route prop passed to components often contained a state property which held state of the child navigator. While it wasn't meant to be public and we recommended against using it in the docs, we've seen a lot of people use this property. It's problematic to use the property since it's not guaranteed to exist before navigation happens in the child navigator. This can cause subtle bugs in your app which you might not notice during development. So we have started warning on using this property in React Navigation 5 and removed this property entirely in React Navigation 6 prevent its usage."
Although this is not exactly the same case (I don't intend to use the route prop at all), this shows that this probably doesn't work by design.
I haven't found a solution. I'd really appreciate any advice.
Current behavior
Check the route.state of this stack. Use any method: getState, useNavigationState, the route prop all give the same result.
Expected behavior
The nested stack is rendered and so is a screen within the stack. The state property containing the name and index of the currently rendered route should already be accessible.
Reproduction
https://snack.expo.dev/WDITwptdY68Ahe_pf0wwW
Platform
Packages
Environment