React-native-router-flux: Navigation state is lost when sending the app to background

Created on 27 Feb 2017  路  12Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux 3.37.0
  • react-native 0.41.2

Expected behaviour

When switching between applications, like the browser or whatsapp, when returning to the application that uses react-native-router-flux it stays in the current navigation state I'm currently in,

Actual behaviour

It will always return to "root" Scene and lose every data placed in forms

Steps to reproduce

  1. Install and build the Example from this repo on a device
  2. Run it, navigate, let's say, "Go to Login page"
  3. Press Home button or the window switch physical button
  4. Come back to the app, it's now in the "Launch page" again
bug

Most helpful comment

As long as the phone only suspends the application, state will be preserved. But if they leave the app, it will reset navigationState.

All 12 comments

@pocesar Can you try with the latest release?

same thing

Is this in the device or emulator? Do you have free memory?

This is very bizarre.

yes, on a Samsung J7, android 6.0.1

my bad, I forgot I left "Do not keep activities" on "Developers options" turned on, on the device, it's fine now.

@pocesar I'm having some trouble with this. I've ran through the same steps as you, and have "Do not keep activities" off. I have also not been able to get this to work with my own examples and various other version combinations.

Does keeping nav app state require a specific run environment?

I've tried via react-native run-android and an APK build. I also can't get it to work on Genymotion.

Device: Huawei Nexus 6p, version 7.0

"react-native": "0.41.2",
"react-native-router-flux": "^3.37.0",

@win45 not that I'm aware of. although I'm using redux and redux-persist, and 'hacking' the createReducer to try to keep at least the minimal state required for the app to funcion

@pocesar Ok, I really wasn't understanding this correctly. I was expecting nav state to persist out of the box using the example code, but by hacking the createReducer your then explicitly storing the nav state before 'background', and fetching it at 'foreground' - correct?

@win45 yes, after you leave the app or restart your phone, the state will be lost, the only way is to persist the current scene somewhere

As long as the phone only suspends the application, state will be preserved. But if they leave the app, it will reset navigationState.

We are facing the same issue with our app. Always start from the root view

I have the same behavior but I am not using RNRF, I am using React Navigation. Not sure this is a RNRF issue but more of needing to persist the app state in React Native to keep it alive. I am guessing the Redux state could be stored on the device using Async Storage? Not sure what the best way would be.

Was this page helpful?
0 / 5 - 0 ratings