cd android && ./gradlew clean npm start -- --reset-cache ( if you are using npm ) react-native run-android if you are using yarn then after clean run yarn android
Here is what the above code is Doing:
1. We are importing the react-native-splash-screen package.
2. We are creating a SplashScreen component which is going to do the following:
a. Hide the splash screen
b. Check if the token is set or not.
c. If the token is set then we will redirect the user to the home screen.
d. If the token is not set then we will redirect the user to the login screen.
3. We are using the useEffect hook which will check the token on load of the SplashScreen.
4. We are using the AsyncStorage to get the value of the token.
5. We are using the setTimeout function to hide the SplashScreen after 3 seconds.
6. We are using the NavigationActions to navigate the user to the home screen or the login screen.