我是 React Native 的新手
我有路线外观:
ScreenA -> ScreenB -> ScreenC
现在我想从 ScreenC 重新导航到 ScreenA,我使用 this.props.navigation.navigate('ScreenA');
But i get the fact, i get previous screenA (not new one) or i can say it is like back to previous screen method. What i want similar to Intent intent = new Intent(ScreenA) in Android Native. Can anyone help to solve it?
更新:
我有 2 个路由组,这可能会导致真正的问题:
StackNavigator {
screenA,
screenB
}
TabNavigator {
screenC
}
I can't move screenC to screenA using .push or .dispatch. But working well using .navigate. But if i use .navigate , screenA is previous screen not new screen (same like before i move to screenB). I want move from screenC to a new screenA not previous screenA.
最佳答案
尝试
import { NavigationActions, StackActions } from 'react-navigation';
//Reset and navigate
const resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'YourScreen' })
]
})
this.props.navigation.dispatch(resetAction);
//Or Navigate
this.props.navigation.navigate("YourScreen");
//Similar to navigate, push will move you forward to a new route in the stack
this.props.navigation.push(routeName, params, action)
有关更多信息,请参阅 here
关于android - 如何新鲜导航到特定屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52870511/