DEV Community

amlan
amlan

Posted on

[React-Native]Run a code before close

I want to run a code before a React-native app close. So when we close the app, before it closes, I want to run a JS code. Does anyone know a way to achieve that? I used useState clean up but doesnt seem to be firing when I close the app.

Top comments (4)

Collapse
 
256hz profile image
Abe Dolinger •

Pretty sure AppState - background will fire when you close the app. reactnative.dev/docs/appstate

Collapse
 
amlana24 profile image
amlan •

Thats really helpful..Didnt know about this..Thanks Abe..

Collapse
 
256hz profile image
Abe Dolinger •

No problem, let me know if it works out for you!

Collapse
 
seanmclem profile image
Seanmclem •

it doesn't