React-native componentWillUnmount未被调用 [英] React-native componentWillUnmount not being called
问题描述
我在Android上运行,如果我使用硬件返回按钮退出应用程序,则会调用componentWillUnmount函数。但是,如果我使用方形按钮显示正在运行的应用程序列表并滑动关闭该功能不会被调用。
I'm running on Android and if I used the hardware back button to exit the application the componentWillUnmount function gets called. However, if I use the square button to show the list of running apps and swipe to close the function does not get called.
有关如何检测应用程序的任何想法正在关闭,以便我可以清除计时器,保存数据等。
Any ideas on how to detect when the app is being closed so that I can clear timers, save data etc.
谢谢。
推荐答案
您可以检查AppState Api以获取有关检测当前状态前景或活动状态的信息。 https://facebook.github.io/react-native/docs/appstate。 HTML
You can check AppState Api for information about detecting current state foreground or active. https://facebook.github.io/react-native/docs/appstate.html
这篇关于React-native componentWillUnmount未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!