Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect App Getting Focus in React Native

I'm trying to detect when the app gains the focus back (i.e. switch to it from another app) in order to perform a certain task. Is there a way to detect this in React Native?

What I'm doing is copying a file to a temp location, opening it with an external viewer, and then I want to delete the file when the user switches back from the app.

like image 951
Pedram Avatar asked Dec 12 '16 19:12

Pedram


1 Answers

The AppState module might be what you are looking for. Have a look at the documentation.

like image 154
martinarroyo Avatar answered Oct 26 '22 13:10

martinarroyo