Switch navigator in React Native version 0.62.2

i am using react-native version 0.62.2 in main screen, i dont want to back to Login screen by back button in older react-native version, the createSwitchNavigator help me solve it but react native version 0.62.2 can not use createSwitchNavigator anyone can help me, help me!!!!

          <NavigationContainer
            ref={containerRef}
            initialState={initialNavigationState}>
            <Stack.Navigator initialRouteName="LoginScreen">
              <Stack.Screen
                name="LoginScreen"
                component={LoginScreen}
              />
              <Stack.Screen
                name="MainScreen"
                component={MainScreen}
              />
            </Stack.Navigator>
          </NavigationContainer>

Upvotes: 1

Views: 280

Answers (1)

Sagar Kulkarni
Sagar Kulkarni

Reputation: 503

This is probably not the issue with react-native version! This issue seems to be with the react-navigation version. The code snippet you've posted is an example of v5 of react-navigation. If you prefer to use createSwitchNavigator(), then install react-navigation v4 and you'll be good to go!

Official Docs for react-navigation v4 : https://reactnavigation.org/docs/4.x/getting-started/

Upvotes: 1

Related Questions