我想从相机屏幕导航到摘要屏幕,但它不起作用:
// 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('Home')
替换this.props.navigation.navigate('Summary')
时,它就起作用了。
这是主屏幕导航器:
const HomeStack = createStackNavigator({
Home: HomeScreen
});
const ScanStack = createStackNavigator({
Camera: CameraScreen
});
export default createBottomTabNavigator({
HomeStack,
CameraStack
});
要使其工作,请将SummaryStack添加到主堆栈中
const HomeStack = createStackNavigator({
Home: HomeScreen,
Summary: SummaryStack
});