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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use this.props.navigation.replace('routName');
It will do your job.
回答2:
Checkout React Navigation
's ways to handle a component's lifecycle event in their docs here
TL;DR, you can checkout React Navigation
's navigation lifecycle event to perform actions when you switch screens. Hope it helps.