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