Skip to content
tezvyn:
Menu

Managing Splash Screens in React Native

Source: github.comMediumHow cards are made

A splash screen bridges the gap between tapping your app icon and your React Native bundle finishing its load, preventing a jarring white screen. Use it to improve perceived performance during launch.

Why it exists

React Native apps have a startup latency. The native shell launches, but then it must load and parse the JavaScript bundle before any UI can render. This can result in a blank white screen for several seconds, creating a poor user experience. A native splash screen provides an immediate visual placeholder to cover this loading time.

The mental model

Think of a splash screen as a native curtain that goes up instantly when the show (your app) starts. The JavaScript code is the stage crew setting up behind the curtain. Once the set is ready—your app has loaded its data and initial components—your JS code sends a signal to drop the curtain, revealing the fully rendered application.

How it works

A native splash screen is implemented using native iOS (e.g., LaunchScreen.storyboard) and Android (e.g., launch_screen.xml) UI components. These are displayed by the operating system immediately upon app launch. A library like react-native-splash-screen provides a bridge, allowing your JavaScript code to call a native method (e.g., SplashScreen.hide()) to dismiss this native view once the React Native part of your app has mounted and is ready to be displayed.

When to use it

Always use a native splash screen for production mobile apps. It significantly improves the perceived launch performance and provides a professional feel. It's the correct way to handle the time between the user tapping the icon and your root React component rendering.

When not to use it

There is rarely a reason to omit a splash screen in a user-facing React Native app. However, you would not need a programmatically controlled splash screen if your app's load time is negligible and the default OS launch screen is sufficient. For complex apps, programmatic control is almost always necessary to hide it at the right moment.

One canonical example

Using the react-native-splash-screen library, you first configure the native Android and iOS projects to show a custom launch screen. Then, in your root React component (e.g., App.js), you would use a useEffect hook. Inside this hook, once your app has finished its initial data fetching or setup, you call SplashScreen.hide() to dismiss the native view and reveal your React-rendered UI.

Interview question

When should a native splash screen in a React Native application typically be dismissed?

  • a.When the user navigates to the first interactive screen of the application.
  • b.Immediately upon the native shell launching, to quickly transition to the JavaScript UI.
  • c.After the React Native application has fully loaded its JavaScript bundle and rendered its initial components.Correct
  • d.Once all network requests and data fetching for every screen in the application are completed.
Why?

The card explains that the splash screen is dismissed "once the React Native part of your app has mounted and is ready to be displayed" and after "initial data fetching or setup." Option C accurately reflects this timing, which occurs after the JavaScript bundle loads and initial components render. Option B describes when the splash screen appears, not when it is dismissed.

Just read this? Test yourself on what you have been reading.

Read the original → github.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on react native — each one lists the topics its interview covers.

See open roles