当我在react native中导航到新页面时如何强制卸载组件? [英] How do I force a component to unmount when I navigate to a new page in react native?
本文介绍了当我在react native中导航到新页面时如何强制卸载组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想确保在导航到新页面时会触发生命周期方法ComponentWillUnmount.我发现了这条帖子,但这没有似乎没有提及有关导航到新页面的任何信息.我还发现了这条
I want to make sure the lifecycle method ComponentWillUnmount fires when I navigate to a new page. I found this post, but that doesn't seem to mention anything about navigating to a new page. I also found this post but I'm using react-navigation. In addition, I'm not using pop/push. I'm simply using this.props.navigation.navigate('SomePage') to get to the next page
推荐答案
您可以使用this.props.navigation.replace('routName');
它将完成您的工作.
You can use this.props.navigation.replace('routName');
It will do your job.
这篇关于当我在react native中导航到新页面时如何强制卸载组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文