如何清除本机中的导航历史记录

时间:2021-06-21 06:56:20

标签: reactjs react-native

我在我的 react-native 应用程序中创建了一个登录/注册页面...我想阻止用户在成功登录后返回该页面

在 nativescript 中,我通过在导航时设置 clearHistory: true 来实现 我怎么能在 react-native 中做到这一点

我的导航代码是这样的this.props.navigation.navigate('home screen', { email: email}

谢谢

2 个答案:

答案 0 :(得分:1)

如果您使用 react-navigation,则有一个方法 popToTop。这应该会清除您的导航堆栈,如果 'home screen' 不是您应用的第一个屏幕,您可以稍后navigate

this.props.navigation.popToTop();
this.props.navigation.navigate('home screen', { email: email};

答案 1 :(得分:0)

这有效

navigation.replace('homescreen', {email : email})