By Harish Penta


2019-01-11 12:05:34 8 Comments

I have created Mobile application in React native.

My problem is that whenever i open my app from launcher icon and minimize for sometime (eg: 10 minutes) then if i re-open my application from recent apps or else on clicking launcher icon again it should restart the application as it opening for the first time.

But doesn't matter how much time i minimize the application when i open it again it will open as a previous state.

How to solve this issue.

2 comments

@Jeff Gu Kang 2019-01-11 13:28:03

Normally, application has their inherent state as snapshot when it go to background if the user do not close directly.

If you are testing on android, pressing backbutton on top of the navigation makes close the application. (you can control this if you want.)

In iOS, pressing home button always send the application into background instead of close.

I am not sure what OS you are using for development. But refer it.

@Andrei Vedovato 2019-01-11 12:09:24

What Navigation module are you using? Depending on it, you need to call a method to init the app and that method must be called again when you switch back to the app.

@Harish Penta 2019-01-11 12:13:41

i am using the react-navigation.

@Andrei Vedovato 2019-01-11 12:17:06

Ok so start by using this to see if the app is on background or so. Depending on what you get from AppState, call the Navigator createStackNavigator again. It should work.

@Harish Penta 2019-01-11 12:57:19

ok i have used AppState, but how to re-launch app again with createStackNavigator code.. what should i write for that

@Andrei Vedovato 2019-01-11 13:22:33

Try to make the createStackNavigator an exportable function. Then, import that function in the file where you compare the AppState. Depending on AppState's return, call the imported function.

Related Questions

Sponsored Content

3 Answered Questions

Some react-native vector icons are not shown

  • 2017-03-26 06:15:22
  • vu.martin
  • 474 View
  • 1 Score
  • 3 Answer
  • Tags:   react-native

0 Answered Questions

Android app not minimizing as expected when clicking the home button

0 Answered Questions

Open Android/iOS default Alarm app from react native

0 Answered Questions

0 Answered Questions

White screen when opening React Native from existing android app

1 Answered Questions

1 Answered Questions

[SOLVED] How long does redux state persist in memory in react native

1 Answered Questions

[SOLVED] React-Native: Passing data when opening the app from a browser

1 Answered Questions

Sponsored Content