JavaScript navigation between component in react native navigation component between activities,android navigation component between activities

I need to navigate between two view in React Native. But the problem is my component where the button to navigate is on an other component. I use the react-navigation.

Let me show you :

I have my component MainPage here

class MainPage extends Component {
  render() {
    return <View style={styles.container}>
              <ComponentWithButton /> 
          </View>
  }
}

So in my component ComponentWithButton :

class ComponentWithButton extends Component {
      goToComponent(){
         this.props.navigation.push('Next')
      }
      render() {
        return <View style={styles.container}>
                  <Button onPress={this.goToComponent.bind(this)}/> 
              </View>
      }
    }

My next component is called NextComponent.

I have the error undefined is not an object (evaluating "this.props.navigation.push")

My stack navigator is this :

const RootStack = StackNavigator(
  {
    Main: {
      screen: MainPage
    },
    Next: {
      screen: NextComponent
    }
  },
  {
    initialRouteName: "Main"
  },
  {
    navigationOptions: {
      header: { visible: false }
    }
  }
);

I try to run my code with just one component it's working perfectly. I think there is problem because ComponentWithButton is not called in my RootStack or something like that. I don't know I am a newbie

Answer:1

So this time I have a HTML table and when I click in a anchor that is located in a tag it opens a modal, where we can change a user password. But to update the password in the users table I need to ...

So this time I have a HTML table and when I click in a anchor that is located in a tag it opens a modal, where we can change a user password. But to update the password in the users table I need to ...

  1. html table modal
  2. html table inside modal
  3. html table in bootstrap modal

I have a few html pages that share the same navbar. Therefore I wrote one html file - topnav.html and I used the following jQuery code to load it into every page. javascript <script type="text/...

I have a few html pages that share the same navbar. Therefore I wrote one html file - topnav.html and I used the following jQuery code to load it into every page. javascript <script type="text/...

Within a redux saga I am sending a half dozen fetch requests to different systems. I want to wait until all those requests return, then do some final processing on the results. To this end I have an ...

Within a redux saga I am sending a half dozen fetch requests to different systems. I want to wait until all those requests return, then do some final processing on the results. To this end I have an ...

I would like to change my navigationbar background color , but return to me : TypeError: Object is not a function(evaluating 'renderHeader'); How can i fix this error? static navigationOptions = ({...

I would like to change my navigationbar background color , but return to me : TypeError: Object is not a function(evaluating 'renderHeader'); How can i fix this error? static navigationOptions = ({...

  1. react native navigation bar height
  2. react native navigation bar example
  3. react native navigation bar color
  4. react native navigation bar hide
  5. react native navigation bar style
  6. react native navigation bar title
  7. react native navigation bar right button
  8. react native navigation bar bottom
  9. react native navigation bar shadow
  10. react native navigation bar background image
  11. react native navigation bar back button
  12. react native navigation bar android
  13. react native navigation bar custom
  14. react native navigation bar transparent
  15. react native navigation bar background color
  16. react native navigation bar left button
  17. react native navigation bar tutorial
  18. react-native-navigation-bar npm
  19. react native navigation bar image
  20. react native navigation bar blur