navigation.state is undefined when navigating back from materialTopTabNavigatior
See original GitHub issueWhen a sharedElementStack
has a nested materialTopTabNavigator inside as a screen, an exception TypeError: undefined is not an object (evaluating 'navigation.state')
pops up when trying to go back from it. An example:
const TabScreen = createMaterialTopTabNavigator(
{
InsideOne: { screen: InsideOne },
InsideTwo: { screen: InsideTwo },
}
)
const SharedStack = createSharedElementStackNavigator(
{
Main: { screen: MainScreen },
TabScreen: { screen: TabScreen }
}
)
When navigating to the TabScreen and then navigating back by tapping on the back arrow, the app crashes as soon as the transition is done.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
React-native navigation state 'undefined' at the very beginning
I'm trying to check the navigation state via hooks: const state = useNavigationState(state => state);. The hooks itself works pretty well.
Read more >Material Top Tabs Navigator | React Navigation
A material-design themed tab bar on the top of the screen that lets you switch between different routes by tapping the tabs or...
Read more >A Complete Guide to React Native Navigation | by Allan Graves
A navigation container is required — it sets up the state required for screens to persist, track which screen you are on, and...
Read more >Track the Current Route in React Navigation V5 Outside Of a ...
React Navigation 5.x has useful hooks that are great when you ... if (state.index === undefined || state.index < 0) { return undefined;...
Read more >React Native Passing Value between Screen - Javatpoint
This function is used to navigate between the different screens. ... Component {; constructor(props) {; //constructor to set default state; super(props); ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had two reproducible cases where it crashed and tested it out quickly. It seems like this is now both fixed with 2.1.0, thank you!
I’ve fixed the issue and release a new version 👍 https://github.com/IjzerenHein/react-navigation-shared-element/releases/tag/v2.1.0