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

Categories

HOME
c#
joomla
stanford-nlp
domain-driven-design
dynamic
conceptual
hiveql
ebay
thermal-printer
sugarcrm
markdown
rethinkdb
android-webview
webpack-dev-server
box-api
software-collections
comma
opendaylight
aggregate
box2d
luis
amazon-data-pipeline
project-reactor
loader
accordion
computation-theory
pushbullet
launchd
typeorm
javapns
ocl
drawrect
postgresql-9.6
unity3d-5
sampling
device-driver
libconfig
jquery-inputmask
nsdateformatter
jslider
usernotifications
android-graphview
php-mongodb
colorbox
text-extraction
smooth-streaming
risc
django-cors-headers
spring-ide
google-cloud-shell
px4
disassembly
suitesparse
qudpsocket
android-tabs
papyrus
dimensionality-reduction
virtualenvwrapper
scriptengine
angularfire
hotkeys
boost-propertytree
usps
pyshark
sqlxml
video-embedding
google-app-engine-php
cascading
windows-phone-8-emulator
cyberduck
litedb
jad
cl.exe
caption
novell
xpand
pyalgotrade
jsmpp
xps
internet-radio
infor-eam
ojb
playing-cards
qgraphicsscene
mandelbrot
uikit-dynamics
system.transactions
microsoft-speech-platform
urlfetch
gpl
metapost
certificate-revocation
reflexil
jmesa
inserthtml
visual-leak-detector
mscorlib
openwrap
arraycollection
table-valued-parameters
glassfish-embedded
file-storage
time-management
manuals
office-2003
ironpython-studio

Resources

Encrypt Message