Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react navigation splash screen to login screen

I have created a splash screen and a login screen. I would like that after 2 second my screen goes splash to log in but it's showing: undefined is not an object(evaluating '_this.props.navigation.push ')

In this project I am using react-navigation

componentWillMount(){
setTimeout(
    () => {
        this.props.navigation.push({
            screen:'smartbill.login',
            title:'LOGIN SCREEN'
        });
    }
, 1000);

}

like image 986
Suvasis Samantaray Avatar asked Dec 06 '25 22:12

Suvasis Samantaray


2 Answers

Hope you have created a stack navigator

 const App = createStackNavigator({
  Splash: { screen: SplashScreen },
  Login: { screen: LoginScreen },
});

In Splash Screen

setTimeout(()=> {
   navigate('Login', { name: 'Jane' })
 },1000);
like image 119
Asha Avatar answered Dec 08 '25 14:12

Asha


Below is an example of me navigating to a home screen from splash

 setTimeout(
            ()=> {
              this.props.navigation.navigate("Home");
                },1000
        );

For Navigation you should use StackNavigator in react-native thats the proper method

Where did you get this this.props.navigation.push thats not proper.

Or

I have an excepted answer in the below question.

How to navigate from splash screen to login screen in react native?

There is a google drive link on it from where you can download a sample project, its a simple app figure it out from the sample app how you should set up the App.js.

I suggest You should use StackNavigator for navigation its the best method to follow in my app App.js is configured using StackNavigator.

like image 25
Amal p Avatar answered Dec 08 '25 15:12

Amal p



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!