简体   繁体   中英

How can I know if I leave the screen already with tab navigation (react-navigation)?

I am using react navigation (tab navigation) for my app. But how can I know if I leave the screen already?

For example, I have Screen A and Screen B. And I have a timer in my screen A but when I click Screen B, I want the timer stop. Before I use react navigation, I can simply use componentWillunmount function. However, I think when I use tab navigation, the first screen (Screen A) hasn't been destroy or unmount when I go to the screen B.

Any ideas? Thanks!

对于Tab Navigator,您可以使用特殊事件来定义当前的活动屏幕以及“焦点”和“模糊”之类的事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM