reactjs
React native ex-navigation chnaging routers
Hey Guys I have a problem in switching pages with react-native ex-navigation: Error: undefined is not an object (evaluating 'this.props.navigator' this is the code: import React, { Component } from 'react'; import {AppRegistry, StyleSheet, Text, View, Navigator, Button } from 'react-native'; import {createRouter, NavigationProvider, StackNavigation, TabNavigation,TabNavigationItem as TabItem,}from '#exponent/ex-navigation'; import * as firebase from "firebase"; firebase.initializeApp(config); import Login from 'auth/firstPage' var Register = require('auth/register') var Tab = require('./src/components/tab/mainTab'); const Router = createRouter(() => ({ login: () => Login, register: () => Register, tab: () => Tab, })); export default class main extends Component { componentWillMount(){ this.setState({ name:'login'}); } constructor(props) { super(props); this.state = { name: 'tab' }; } render(){ return( <NavigationProvider router={Router}> <StackNavigation initialRoute={Router.getRoute(this.state.name)} /> </NavigationProvider> ) } } this is the code I used to navigate: this.props.navigator.push({name:'register'})
Did you call this.props.navigator in another function in your new page component? You will need to add the following in your new page constructor which gives you access to this.props.navigator: constructor(props){ super(props); this.FUNCTION_CALL_NAV = this.FUNCTION_CALL_NAV.bind(this); } FUNCTION_CALL_NAV() { this.navigator.push({name: 'register'}); }
Related Links
Why can't I set React component state in a life Cycle method
Not able to set state in componentWillReceiveProps in React
How to update the table content of using React bootstrap table?
html tags does not work inside jsx made tags
How to use gulp with browserify for React project
Material-ui React components not working
React Router no input file specified
Why React event handler is not called on dispatchEvent?
InputText bottom border disappears automatically all of sudden
What is the recommended threshold for duplication in redux/react apps in code climate?
How to pass object to hashHistory.push() in react
Karma chrome launcher starts, but crashes immediately
React router get current route outside component
How should I write my action creator to pass value from my component?
How to pass AJAX data to child through props
ReactJS + Redux + Reduc-thunk Can't dispatch promise