React Native,Android,undefined不是对象(评估'this.props.navigator.push')与TouchableHighlight

问题描述:

iam new in react native这是我的第一个项目,我的问题是当我试图启动另一个屏幕成反应本机我得到这个错误 :undefined不是一个对象(评估'this.props.navigator.push') 我不知道为什么因为我没有任何经验与反应原生
这是我的代码,如果有人有主意!React Native,Android,undefined不是对象(评估'this.props.navigator.push')与TouchableHighlight

class loginApp extends Component { 
    render() { 
     return (
      <View style={styles.container}> 
       <Text style={styles.title}> 
        Welcome Sign Up Here 
       </Text> 
       <View> 

        <TextInput 
         placeholder="Name" 
         style={styles.formInput} 
         /> 
        <TextInput 
         placeholder="Password" 
         secureTextEntry={true} 
         style={styles.formInput} 
         /> 
         <TextInput 
         placeholder="UserName" 
         style={styles.formInput} 
         /> 
          <TextInput 
         placeholder="Email" 
         style={styles.formInput} 
         /> 
        <TouchableHighlight onPress={this.onPress.bind(this)} style={styles.button}> 
         <Text style={styles.buttonText}>Submit</Text> 
        </TouchableHighlight>   
       </View> 
      </View> 
     ); 
    } 
    onPress() { 
    this.props.navigator.push({ 
    title: "Secure Page", 
    component: SecureView, 
    }); 
}; 
}; 
+0

这是http://*.com/questions/39928565/this2-props-navigator-push-is-not-a的更多钞票副本功能/ 39958933?noredirect = 1#comment67436731_39958933 –

+0

不,请另一种情况! –

您的props不包含navigator对象。确保在制作loginApp的实例时提供navigator对象。您可以确保你已经通过navigator用下面的代码:

class loginApp extends Component{ 

    constructor(props){ 
    super(props); 

    console.log(props.navigator) // <- this will print in console if you are passing a navigator object. 
    } 

    ... 
} 
+0

谢谢你的工作:) –