[英]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!!!!我在主屏幕中使用 react-native 版本 0.62.2,我不想在旧 react-native 版本中通过后退按钮返回登录屏幕,createSwitchNavigator 帮我解决它,但反应原生版本 0.62.2 不能使用 createSwitchNavigator 任何人都可以帮助我,帮我!!!!
<NavigationContainer
ref={containerRef}
initialState={initialNavigationState}>
<Stack.Navigator initialRouteName="LoginScreen">
<Stack.Screen
name="LoginScreen"
component={LoginScreen}
/>
<Stack.Screen
name="MainScreen"
component={MainScreen}
/>
</Stack.Navigator>
</NavigationContainer>
This is probably not the issue with react-native
version!这可能不是
react-native
版本的问题! This issue seems to be with the react-navigation
version.这个问题似乎与
react-navigation
版本有关。 The code snippet you've posted is an example of v5 of react-navigation
.您发布的代码片段是
react-navigation
v5 的示例。 If you prefer to use createSwitchNavigator()
, then install react-navigation
v4 and you'll be good to go!如果您更喜欢使用
createSwitchNavigator()
,那么安装react-navigation
v4 就可以了!
Official Docs for react-navigation
v4: https://reactnavigation.org/docs/4.x/getting-started/ react-navigation
v4 的官方文档: https://reactnavigation.org/docs/4.x/getting-started/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.