Search code examples
androidreact-nativesplash-screen

How to set the splash screen for react-native android


How does one set a splash screen for react-native android, I can't find anything on the topic and I thought it was odd.

Thanks


Solution

  • I had tried 3 of the following ways. The first one is what I am currently using for android splash screen for react-native projects.

    1. Using a npm package written by other.

      reference: https://github.com/remobile/react-native-splashscreen

    2. Create a SplashScreen component and redirect afterward.

      reference: How to create some kind of Splash screen/Launching screen, which disappears after App loaded? (React Native)

    3. Natively in java code.

      reference: https://www.bignerdranch.com/blog/splash-screens-the-right-way/

    I have a fetch request in the componentDidMount() of initialRoute.

    Using the first way from the list above performs the request while showing the splash screen.

    Whereas the second way, needs to wait until the SplashScreen component get unmounted.

    Third way is slightly more codes to write and maintain.