2017-10-14 2 views
1

Ich bin neu mit react-native und ich versuche StackNavigator zu verwenden, aber es funktioniert nicht Ich versuche zu rufen eine Komponente und render es, wenn Sie auf eine Schaltfläche klicken. Aber ich bin immer diese Fehlermeldung: undefined is not an object (evaluating '_this2.props.navigation.navigate')reagieren native: undefined ist kein Objekt (Bewertung '_this2.props.navigation.navigate')

Das ist meine Hauptkomponente:

Auf meinem App.js ich nicht angerufen habe:

export default class Home extends Component<{}> { 

    constructor(props) { 
     super(props); 
     this.email = null; 
     this.amount = null; 
     this.device = null; 
    } 

    render() { 
     return (
      <ScrollView style={styles.styleSV}> 
       <Text 
        style={styles.styleLogin}> 
        Login 
       </Text> 
       <View style={styles.styleForm}/> 
       <TextInput placeholder='email' onChangeText={(text) => this.email }/> 
       <TextInput placeholder='amount' onChangeText={(text) => this.amount }/> 
       <TextInput placeholder='device' onChangeText={(text) => this.device }/> 
       <View style={styles.styleButtonSignup}/> 
       <Button 
        onPress={() => 
         this.props.navigation.navigate('PaypalPayment', { email: this.email }) 
        } 
        title='Next' 
       /> 
      </ScrollView> 
     ); 
    } 

} 

const NavigationScreen = StackNavigator({ 
    PaypalPayment: { screen: PaypalPayment }, 
    Home: { screen: Home} 
}); 

AppRegistry.registerComponent('paypal',() => NavigationScreen); 
+0

prüfen package.json & geben Sie mir die Version von reagieren-Navigation, werde ich Ihnen danach helfen. –

+0

"react-navigation": "^ 1.0.0-beta.13" –

+0

Sind Sie sicher, dass Sie 'PaypalPayment' oder' Home' nicht an anderer Stelle gerendert haben? –

Antwort

0

ich, was mein Fehler war, fand heraus, mein StackNavigator

export const RootNavigation = StackNavigator({ 
    Home: { screen: Home }, 
    PaypalPayment: { screen: PaypalPayment } 
}); 

AppRegistry.registerComponent('paypal',() => RootNavigation); 

export default class App extends Component<{}> { 

    render() { 
     return (
      <RootNavigation/> 
     ) 
    } 
} 

Jetzt arbeitet es.

habe ich diese Dokumentation: https://reactnavigation.org/docs/intro/#Introducing-Stack-Navigator

Verwandte Themen