Can't find variable: Navigate with react-navigation

can definition
can synonym
can verb
can y
can noun meaning
can band
cant
can't

i am having this simple code in the same index.android.js file:

import React, { Component } from 'react';
import {
  AppRegistry,
  Text,
  View,
  Button
} from 'react-native';
import {StackNavigator} from 'react-navigation';

// First Page
class FirstPage extends Component {
  static navigationOptions = {
    title: 'Welcome',
  };

  render() {
    const { navigate } = this.props.navigation;
    return (
      <View>
        <Text>Hello First Page</Text>
        <Button 
          onPress={() => navigate('SecondPage')}
          title="Go to second page"
        />
      </View>
    );
  }
}

// Second Page
class SecondPage extends Component {
  static navigationOptions = {
    title: 'Second Page',
  };

  render() {
    const { navigate } = this.props.navigation;
    return (
      <View>
        <Text>Hello Second Page</Text>
        <Button 
          onPress={() => navigate('FirstPage')}
          title="Go to first page"
        />
      </View>
    );
  }
}


const SimpleApp = StackNavigator({
  FirstPage: { screen: FirstPage},
  SecondPage: { screen: SecondPage},
});

AppRegistry.registerComponent('MoviesTickets_YCH', () => FirstPage);

All i want is to navigate between the screens, but i have the error message: can't find variable: navigate, i have no clue why it happens, any idea how?

Thanks for your help

In the render method add the following:

const {navigate} =this.props.navigation;

Your render should look like this

render(){
const {navigate} =this.props.navigation;
return (
  .... ) ;
}

in each component you use navigate. for more infos, follow the documentation, it's pretty easy. reactnavigation

Verb Can, Can was the leading avant-garde rock group of the 70s. Can experimented with noise, synthesizers, non-traditional music, cut-and-paste techniques, and, most  Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

If i'm clear, react native docs say navigate it's an action creator and you can get acces to it in this.props.navigation;

const { navigate } = this.props.navigation; in render.

May I? Can I? - English Grammar - English, Can may refer to: Contents. 1 Containers; 2 Music; 3 Other; 4 See also. Containers[edit]. Aluminum can · Drink can · Oil can · Steel and tin cans · Trash can  Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

remove node_modules and package-lock.json
npm install
npm install --save react-navigation
npm install --save react-native-gesture-handler
react-native link

Use can in a sentence, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). 110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

CAN (noun) definition and synonyms, can meaning: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more. Can means someone or something knows how to, is able to, is likely to or has the right to do something. An example of can is someone knowing how to play the piano. An example of can is a cat being able to paint. An example of can is a car that usually starts.

Can, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer.

The Official CAN / Spoon Records Website, can. (kæn). n. 1. a container, esp for liquids, usually of thin sheet metal: a petrol can;  Can(stylised as CAN) was a German experimental rockband formed in Colognein 1968 by the core quartet of Holger Czukay(bass, tape editing), Irmin Schmidt(keyboards), Michael Karoli(guitar), and Jaki Liebezeit(drums).

Comments
  • Possible duplicate of Can't find variable: navigate
  • ahhh i went through the doc but miss this : const { navigate } = this.props.navigation; bad for me, thanks
  • i add it just below the render as described, now i am having another error message: undefined is not an object ( evaluating 'this.props.navigation.navigate')
  • Change this: AppRegistry.registerComponent('MoviesTickets_YCH', () => FirstPage); to this AppRegistry.registerComponent('MoviesTickets_YCH', () => SimpleApp);
  • Thanks very much, that' s it, i have my head away this time, cheers