我正在制作一个react native应用程序,其中有一个包含所有导航器的主文件。这是我的应用程序的主堆栈。
const RootStack = createStackNavigator({
Splash : { screen: Splash },
ModelProfile: { screen: ModelProfile},
HomeModel: {screen: modeldrawerNavigator},
EnterOtp : { screen: EnterOtp},
OtpChangePassword : { screen: OtpChangePassword},
}, {
headerMode: 'none',
initialRouteName: 'Splash'
})
const AppNavigator = createAppContainer(RootStack)
export default AppNavigator;
这里是modeldrawerNavigator
const modeldrawerNavigator = createDrawerNavigator(
{
HomeScreen: { screen: homeStack},
EditProfile : { screen: profileStack},
BuyStar : { screen: StarStack},
Notifications : { screen: nStackmodel},
ResetPassword : { screen: ResetPassword},
},
{initialRouteName: 'HomeScreen',
gesturesEnabled: true,
contentComponent: props => <DrawerModel {...props} />
},
);
StarStack是
const StarStack = createStackNavigator({
Buy : { screen: BuyStars},
PaymentMode : { screen: PaymentMode},
}, {
headerMode: 'none',
initialRouteName: 'Buy'
});
当有人单击BuyStar时,现在在抽屉导航器中,我必须重置星号堆栈 这是我的代码
<TouchableOpacity onPress={() =>{
this.props.navigation.navigate('BuyStar');
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Buy' })],
});
this.props.navigation.dispatch(resetAction);
}}>
<Text style={styles.drawertext}>Buy Stars</Text>
</TouchableOpacity>
但这给了我
错误No route defined for key 'Buy',Must be one of 'Splash','EnterOtp' etc.
请帮助我解决此问题。