Contents
React Native Animated Splash Screen
This is an Example of an Animated Splash Screen in React Native. The splash screen is the first screen that appears in front of the user when they interact with your application so to make an impactful impression you can create an Animated Splash Screen. This example contains the simple splash screen with some animation in which we will show the image first and then the name of the app.
If you want to explore more then you can also visit Example of Animation Splash Screen with Zoom Effect.
To Make a React Native App
Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli
command line utility. Open the terminal and go to the workspace and run
npm install -g react-native-cli
Run the following commands to create a new React Native project
react-native init ProjectName
If you want to start a new project with a specific React Native version, you can use the --version argument:
react-native init ProjectName --version X.XX.X
react-native init ProjectName --version react-native@next
This will make a project structure with an index file named App.js in your project directory.
Code
Now Open App.js in any code editor and replace the code with the following code
App.js
// Example of Animated Splash Screen in React Native
// https://aboutreact.com/animated-splash-screen/
// import React in our code
import React, {useState, useEffect} from 'react';
// import all the components we are going to use
import {View, Text, Image, StyleSheet} from 'react-native';
const App = () => {
const [align, setAlign] = useState('center');
const [alignsecond, setAlignsecond] = useState(false);
useEffect(() => {
let myTimeout = setTimeout(() => {
setAlign('flex-start'), setAlignsecond(true);
}, 3000);
return () => clearTimeout(myTimeout);
}, []);
return (
<View
style={[
styles.container,
{justifyContent: align}
]}>
<Image
source={{
uri:
'https://raw.githubusercontent.com/AboutReact/sampleresource/master/react_logo.png',
}}
style={{width: 100, height: 100}}
/>
{!alignsecond ? null : (
<View style={{margin: 10}}>
<Text
style={{
color: '#114998',
fontSize: 30,
fontWeight: 'bold',
}}>
About React
</Text>
</View>
)}
</View>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
flexDirection: 'row',
marginHorizontal: 40,
},
});
To Run the React Native App
Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running (macOS only)
react-native run-ios
Output Screenshots
Output in Online Emulator
This is how you can make an animated splash screen in React Native. If you have any doubts or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!
Hope you liked it. 🙂
a good and helpful post
Hi Snehal, I’m learning React native through your posts only,it’s very helpful to a newbies like me.
How can we show multiple images sliding one by one in splash screen. Could you please help me in this situation.
Can you please look into it https://aboutreact.com/react-native-app-intro-slider/
Hello.
Can you create some tutorials on Liquid Swipe same as like
https://www.youtube.com/watch?v=gLopy2MCAqM
Also like Fluid Transition or Shared Element Transition
https://github.com/IjzerenHein/react-navigation-shared-element/tree/navigation-v5
Its look so nice after all this animation. I am struggling to implement all this.
Nice suggestion, Will look into it.
Thanks for this tutorial. I’m enjoying your website. After following the steps in this tutorial line by line, I got this warning message ‘Warning: Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function’. How can I fit it please.
Updated the code for the same.