Show splash screen before show main screen in react native without using 3rd party library

前端 未结 5 1297
忘掉有多难
忘掉有多难 2021-01-31 10:47

I am beginner in react native so may be my question seems silly to all experts.

but I am struggling with a basic feature that i want to implement that i want to start my

5条回答
  •  野的像风
    2021-01-31 11:44

    Just Follow this Simple Code.

    App.js

    import { createStackNavigator,createAppContainer } from "react- 
    navigation";
    import Splash from "./Controller/Splash";
    import Login from "./Controller/Login";
    import Register from "./Controller/Register";
    
     const Navigator = createStackNavigator ({
     main: { screen: Splash },
     LoginScreen: { screen : Login },
     });
    
    const AppNavigator = createAppContainer(Navigator);
    
      export default class App extends Component {
      render() {
      return ;
      }
     }
    

    Splash.js

    import React, { Component } from "react";
    import {View, Text } from "react-native";
    
    export class Splash extends Component {
    
     componentDidMount() {
        setTimeout(() => {
           this.load();
              }, 4000);
        }
    
       load = () => {
            this.props.navigation.push("LoginScreen");
        };
    
        render() {
            return (
         
           Splash Screen
      
      );
     }
    }
     export default Splash;
    

    Hope this Helps :)

提交回复
热议问题