我在使用 react-native ex-navigation 切换页面时遇到问题:错误:未定义不是对象(评估'this.props.navigator'
这是代码:
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.props.navigator.push({name:'register'})