2

i'm using RN 0.46.0 and after setup the login component i'm trying to use the navigator to push another component. but shows this

Cannot read property 'push' of undefined

When i click at the button

Even the docs just have this way to get another component.

Someone know if this is related to the version?

Or for Navigation need to create a route?

import React, {Component} from 'react';
import { Text,  View, Navigator, TouchableHighlight } from 'react-native';
import { Card, CardSection, Input, Button } from './common';
import Signup from './Signup';

class Login extends Component {



     goToSignup(){
    this.props.navigator.push({
      component: Signup
    });
  }




    render() {


        return(

            <Card>            

            <CardSection>

            </CardSection>

            <CardSection>
            <Input

            placeholder="Email"
            />

            </CardSection>

            <CardSection>
            <Input
            secureTextEntry

            placeholder="Password"
            />


            </CardSection>

            <CardSection>

            <Button>
            Log In
            </Button>        
            </CardSection>   
            <CardSection>

   <TouchableHighlight onPress={this.goToSignup.bind(this)}>

<Text >
    Go to Sign up
      </Text>       


    </TouchableHighlight>


</CardSection>


</Card>





);

}


}



export default Login;

2 Answers 2

2

React-Native v0.46 doesn't have the Navigator component. It has been removed since v0.44. You have to use other navigation solutions.

React-Navigation ( Recommended, created by the react community )

Other 3rd party solutions:

React Native Navigation

Native Navigation

Sign up to request clarification or add additional context in comments.

2 Comments

I think Wix navigator is better, at least it's recommended by Airbnb. github.com/wix/react-native-navigation
Thank you very much @shubhniksingh
0

here this.props.navigator is undefined make sure this.props.navigator is available to avoid this error you can put one check

goToSignup(){
 if(typeof this.props.navigator !== "undefined"){
   this.props.navigator.push({
             component: Signup
   });
  }
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.