React-native-navigation: React instance destroy unexpected (Android)

Created on 6 Dec 2017  路  2Comments  路  Source: wix/react-native-navigation

We hold the currentActivity (resume->pause) so we know when we need to destroy the javascript context (when currentActivity is null, ie pause and destroy was called without resume).

If an activity start immediately after NavigationActivity, the NavigationActivity's onResume will not called, and the last NavigationActivity's onDestroy will destroy the Js instance, which is unexpected.

Most helpful comment

Override clearHostOnActivityDestroy in your MainApplication.

@Override
    public boolean clearHostOnActivityDestroy() {
        return false;
    }

You'll also need to modify your startup code a bit as described here https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=compatibility-with-headlessjs

All 2 comments

Override clearHostOnActivityDestroy in your MainApplication.

@Override
    public boolean clearHostOnActivityDestroy() {
        return false;
    }

You'll also need to modify your startup code a bit as described here https://wix.github.io/react-native-navigation/#/android-specific-use-cases?id=compatibility-with-headlessjs

Has this changed in master. I can't seem to find clearHostOnActivityDestroy anywhere in the repo on the latest version. If so, has it moved or been replaced? Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

henrikra picture henrikra  路  3Comments

kiroukou picture kiroukou  路  3Comments

switchtrue picture switchtrue  路  3Comments

swingywc picture swingywc  路  3Comments

yedidyak picture yedidyak  路  3Comments