2016-11-14 89 views
1

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://stackoverflow.com/questions/39928565/this2-props-navigator-push-is-not-a的更多鈔票副本功能/ 39958933?noredirect = 1#comment67436731_39958933 –

+0

不,請另一種情況! –

回答

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

謝謝你的工作:) –

相關問題