2017-07-07 65 views
0

以下是示例代码,我正在尝试react-native-navigationundefined不是一个对象(评估'_this.props.navigator.push')反应本机,当我试图从一个页面导航到另一个

我用反应本土的init导航启动项目 事后我安装

纱增加反应本地导航@最新

代码运行完美的第一屏幕,但我想提出来showNextScreen函数的调用它引发错误

未定义不是一个对象(评价“this.props.navigator.push”)反应天然

import React, { Component } from 'react'; 
    import { 
     AppRegistry, 
     StyleSheet, 
     Text, 
     View 
    } from 'react-native'; 
    import {Navigation} from 'react-native-navigation'; 
    import firstPage from './app/components/firstPage'; 
    export default class navigate extends Component { 
    //function to move to next screen 
     showNextScreen =() =>{ 
     this.props.navigator.push({ 
      screen: 'firstPage', 
      title: 'firstScreen' 
     }) 
     } 
     render() { 
     return (
      <View style={styles.container}> 
      <Text style={styles.welcome}> 
       Welcome to React Native! 
      </Text> 
      <Text style={styles.instructions}> 
       To get started, edit index.android.js 
      </Text> 
      <Text onPress={this.showNextScreen.bind(this)} 
      style={styles.instructions}> 
       Double tap R on your keyboard to reload,{'\n'} 
       Shake or press menu button for dev menu 
      </Text> 
      </View> 
     ); 
     } 
    } 

    const styles = StyleSheet.create({ 
     container: { 
     flex: 1, 
     justifyContent: 'center', 
     alignItems: 'center', 
     backgroundColor: '#F5FCFF', 
     }, 
     welcome: { 
     fontSize: 20, 
     textAlign: 'center', 
     margin: 10, 
     }, 
     instructions: { 
     textAlign: 'center', 
     color: '#333333', 
     marginBottom: 5, 
     }, 
    }); 

    AppRegistry.registerComponent('navigate',() => navigate); 

回答

2

使用阵营本地导航,你必须以不同的方式引导你的应用程序比它最初是如何完成的。本机导航不使用registerComponent设置,因为它是本机导航器。

的步骤完全建立在自己的文档https://wix.github.io/react-native-navigation/#/usage

+0

上市等是它必须要在标签视图我的申请?,按您的参考链接 – devanshsadhotra

+0

@devanshsadhotra有两种方式来启动。 TabBased - https://wix.github.io/react-native-navigation/#/top-level-api?id=starttabbasedappparams SingleScreen - https://wix.github.io/react-native-navigation /#/顶级的API?ID = startsinglescreenappparams –

相关问题