Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native componentWillUnmount not being called

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.

Thanks.

like image 812
Railton Avatar asked Dec 16 '16 17:12

Railton


1 Answers

You can check AppState Api for information about detecting current state foreground or active. https://facebook.github.io/react-native/docs/appstate.html

like image 126
Ahmed Ali Avatar answered Nov 08 '22 15:11

Ahmed Ali