How to set the splash screen for react-native android

后端 未结 3 1940
北海茫月
北海茫月 2020-12-04 17:59

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

3条回答
  •  余生分开走
    2020-12-04 18:20

    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.

提交回复
热议问题