如何为React-Native Android设置启动屏幕 [英] How to set the splash screen for react-native android

查看:169
本文介绍了如何为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.

  1. 使用其他人编写的npm软件包.

  1. 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/

我在initialRoutecomponentDidMount()中有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆