【发布时间】:2019-05-07 06:00:19
【问题描述】:
已经以多种不同的形式提出了这个问题,我搜索了一整周,但无法弄清楚如何在以下设置中从 Connect 导航回 Devices。
const HomeStack = createStackNavigator({
Devices: DevicesScreen,
Details: DetailsScreen, // go here
})
const NewDeviceStack = createStackNavigator({
Start: StartScreen,
Connect: ConnectScreen, // start here
})
const BottomTabs = createBottomTabNavigator(
{
Home: { screen: HomeStack },
Settings: { screen: NewDeviceStack },
}
export default createAppContainer(BottomTabs);
从Connect 屏幕,此代码尝试重置当前堆栈并返回到Devices
const resetAction = StackActions.reset({
index: 0,
key: null,
actions: [
NavigationActions.navigate({routeName: 'Devices'})
],
})
this.props.navigation.dispatch(resetAction)
这失败了:
Error: There is no route defined for key Devices.
Must be one of: 'Start','Connect'
【问题讨论】:
标签: react-native react-navigation react-native-navigation