React native screen change的简单实现

问题描述 投票:0回答:1

我是React Native的新手,我正在尝试实现从一个屏幕到另一屏幕的导航,这有点困难,因为源太旧了,无法作为当前React Native版本的可能解决方案,我知道这个问题不是在这里提出的最佳问题,但我需要帮助]

react-native react-navigation
1个回答
3
投票
导航中,您可以执行类似的操作。让我们快速看一下示例:

RootStack.js

import createAnimatedSwitchNavigator from 'react-navigation-animated-switch'; import { withNavigation } from 'react-navigation'; const RootStack = createAnimatedSwitchNavigator( { splash:SplashScreen, second:SecondScreen, }, { initialRouteName: splash } ) export default RootStack;

APP.js

import { createStackNavigator } from 'react-navigation-stack'; import AuthStack from './AuthStack' const RootStack = createStackNavigator({ RootStack}); const AppContainer = createAppContainer(RootStack); export default AppContainer;

您的组件应该像这样。

...rest const SplashScreen = (props) =>{ return ( <View> <TouchableOpacity onPress={()=>{ props.navigation.navigate("second") }}></TouchableOpacity> </View> ) } export default withNavigation(SplashScreen)

© www.soinside.com 2019 - 2024. All rights reserved.