如何为React-Native Android设置启动屏幕 [英] How to set the splash screen for react-native android
问题描述
一个人如何为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.
谢谢
推荐答案
我尝试了以下三种方法.第一个是我目前用于本地反应项目的android启动画面.
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.
-
使用其他人编写的npm软件包.
Using a npm package written by other.
参考: https://github.com/remobile/react-native-splashscreen
创建一个SplashScreen
组件,然后重定向.
Create a SplashScreen
component and redirect afterward.
参考:本地使用java
代码.
参考: https://www.bignerdranch.com/blog/splash-screens-the-right-way/
我在initialRoute
的componentDidMount()
中有一个fetch
请求.
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.
第二种方法是,需要等到SplashScreen
组件卸下.
Whereas the second way, needs to wait until the SplashScreen
component get unmounted.
第三种方法是编写和维护更多的代码.
Third way is slightly more codes to write and maintain.
这篇关于如何为React-Native Android设置启动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!