4

The react-native application checks the local storage for an auth token, and if the token is available the app will navigate to the main page, but the application crashes when trying to call this.props.navigator.push. This only happens when the app is cold launched (works as expected when launched from the background)

AsyncStorageHelper.getUserToken().then((userToken)=>{
if (userToken !== null) {
    this.props.navigator.push({
        component: MainPage
    });
 } else {
  this.showLoginControls();
 }
})

The following code is called on componentDidMount() Method

Edit

Also note the application crashes only on release version So unable to get a stack-trace for the crash.

Ismail Iqbal
  • 2,774
  • 1
  • 25
  • 46
  • 1
    What's the error message ? – Gabriel Bleu Nov 03 '17 at 09:04
  • 2
    componentDidMount does not get triggered when you come from background. Therefore, the issue is persistent. Please provide us with a stacktrace, error messages, native errors, whatever you can get your hands on. Also, could you try wrapping the ```navigator.push``` in a ```InteractionManager.runAfterInteractions``` and after that setTimeout of 500? That would help us determine if it is about the transition itself. – Tukan Nov 03 '17 at 10:52
  • @GabrielBleu cos this happens only on release builds I am unable to get stack-trace for the crash – Ismail Iqbal Nov 04 '17 at 08:54
  • @htkibar look updated question, and also the application crashes when it is cold launched, works fine when it is launched from the background. Adding a timeout fixes the problem, but I don't think that's the cleanest way. Just wanted to know what causes this issue, and find a proper solution for this problem. – Ismail Iqbal Nov 04 '17 at 08:57
  • @IsmailIqbal Could you bring us the native stack trace? (Run as release scheme however connected to xcode, with debug executable on) It is probably about trying to transition before the previous transition is not over, iOS doesn't like that. – Tukan Nov 04 '17 at 15:59
  • I see a couple of things that could be messing with your code but before that, please post your helper class, specially the getUserToken method. – sebastianf182 Nov 05 '17 at 03:57

0 Answers0