james murphy
james murphy

Reputation: 1785

React Native Android - Lifecycle methods

Ive found some very odd behavior in RN (Android).

I hit center/circle button to put app in background.....then I click the app icon to bring back to foreground and sometimes it runs constructor/componentdidmount etc and sometimes it doesnt??

If I use left/arrow button to exit app it always runs constructor....and if I use right/square button to bring it back, it never runs constructor.....but the center/circle button seems to vary based on ??.

Any ideas? Very strange indeed

Upvotes: 2

Views: 908

Answers (1)

Lenoarod
Lenoarod

Reputation: 3610

as for first appearance when you use center/circle button to put the app in the background; if the time is long, the app is killed by the system, so it runs constructor/componentdidmount, if the time is short, it will not runs.

when you use the left/arrow button, the android native will execute it Activity lifecycle:onPause-OnStop-OnDestory, the React Native host Activity is destroyed, it always runs constructor.

you use right/square button to bring it back; it is the same with the first appearance, the app is run in the background, so it never runs constructor

Upvotes: 2

Related Questions