为什么我的Stacknavigator只能在一个屏幕上工作而不在另一个屏幕上工作?

时间:2018-11-05 13:36:03

标签: react-native navigation navigator stack-navigator

我想将整个屏幕从“摄像头”屏幕导航到“摘要”屏幕,但是它不起作用:

        // Camera screen
        if (data.data){
            const data = {date,name,place}

           Alert.alert(
               'Info', 'Show', 
                [{text: 'More', onPress: () => this.props.navigation.navigate('Summary')}],          
               )
        })}

我已经定义了如下的堆栈导航器:

        //Navigator file
        import SummaryScreen from  '../screens/SummaryScreen';

         export const SummaryStack = createStackNavigator({
         Summary : SummaryScreen
         });

有趣的是,当我将this.props.navigation.navigate('Summary')替换为this.props.navigation.navigate('Home')时,它会起作用。

这是主屏幕导航器:

const HomeStack = createStackNavigator({
Home: HomeScreen
});

const ScanStack = createStackNavigator({
Camera: CameraScreen
});

export default createBottomTabNavigator({
HomeStack,
CameraStack
});

1 个答案:

答案 0 :(得分:0)

要使其工作,请将SummaryStack添加到您的主堆栈中

const HomeStack = createStackNavigator({
   Home: HomeScreen,
   Summary: SummaryStack
});