React-native-splash-screen: Bug with BACK on Android!!!

Created on 4 Aug 2017  Â·  9Comments  Â·  Source: crazycodeboy/react-native-splash-screen

Hello. I have a mistake. If I exit the application via the android back button, after I reopen the application, started the splashscreen and the application hangs. How do I fix the error? React native as it has already started, and does not work SplashScreen.hide() Please HEELP

Most helpful comment

I found a workaround, is as follows:
on MainActivity.java

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ReactContext ctx = getReactInstanceManager().getCurrentReactContext();

        if(ctx == null) {
            SplashScreen.show(this);
        }

        super.onCreate(savedInstanceState);
    }

All 9 comments

I have the same problem

+1

+1

+1

I found a workaround, is as follows:
on MainActivity.java

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ReactContext ctx = getReactInstanceManager().getCurrentReactContext();

        if(ctx == null) {
            SplashScreen.show(this);
        }

        super.onCreate(savedInstanceState);
    }

You should check which component get loaded when opened, in my case when the app open on the first time it load the SplashPage component, but after close it with back button, the MainPage component get loaded, not the SplashPage. So i add SplashScreen.hide() on both component

I have this issue as well. Kills the UX of the app :(

same problem here

i am using react-native-router-flux
and fix this problem with it's reducer

case 'Navigation/INIT':
       SplashScreen.hide();
       break;

createReducer example in react-native-router-flux:
https://github.com/aksonov/react-native-router-flux/blob/master/Example/Example.js#L48

i think there is similar solution if you use other navigation library

Was this page helpful?
0 / 5 - 0 ratings