尝试使用 Redux 和 Saga 向 React Native 应用程序添加导航。它适用于一个屏幕,但是当像这样添加 AppNavigator 时,它的行为很奇怪
import HomeScreen from '../screens/fake/HomeScreen';
import LoginScreen from '../screens/fake/LoginScreen';
import SplashScreen from '../screens/fake/SplashScreen';
export const AppNavigator = createStackNavigator({
Splash: SplashScreen,
Home: HomeScreen,
Login: LoginScreen
});
每个屏幕都是这样控制的: HomeScreen 类
extends React.Component {
render() {
return (
<View>
<Button
title="Go to Login"
onPress={() => this.props.navigation.navigate('Login')}
/>
<Button
title="Go to Splash"
onPress={() => this.props.navigation.navigate('Splash')}
/>
</View>
);
}
};
即只包含应该导航到另一个屏幕的按钮。它确实如此。但是在那之后发生Navigation/NAVIGATE
了将用户返回到上一页的事件。
第一个事件Navigation/NAVIGATE
包含正确的路由键。但是第二次出现 - Navigation/COMPLETE_TRANSITION
(更准确地说:){type: "Navigation/COMPLETE_TRANSITION", key: "StackRouterRoot"}
将用户返回到上一个屏幕。
有任何想法吗?