反应导航未定义错误

React-navigation undefined Error

我有一个有趣的问题:所以我导入这个

<TouchableOpacity onPress={() => this.props.navigation.navigate('Feed')} style={styles.buttonContainer}>
   <Text  style={styles.buttonText}>
        LOGIN
   </Text>                 
</TouchableOpacity>   

我创建的表单中的按钮, 我将它导入到一个屏幕,我想像这样加载表单:

<KeyboardAvoidingView behavior='padding' style={styles.container}>

              <View style={styles.logo}>
                <Text style={{fontSize: 64, color: '#34B3E4'}}>Partner<Text style={{fontSize: 64, color: '#0077B5'}}>Up</Text></Text>
                <Text style={{fontSize: 13, opacity: 0.8, color: '#0077B5'}}>We connect you. You work easier.</Text>
              </View>
              <LoginForm/>           <-------------------Here is the import
              <View style={styles.accountLogin}>
                    <TouchableOpacity onPress={() => this.props.navigation.navigate('Forgot')}>
                        <Text style={{opacity: 0.9,color:'#34B3E4'}} >Forgot your password? </Text>
                    </TouchableOpacity>
              </View>  
</KeyboardAvoidingView>

但是我的转换屏幕的 onpress 函数不想中继并抛出一个未定义的错误 即使在我的路由器中也无法在任何地方导入某些内容并呈现 onpress 功能:

Feed: {
     screen: Feed,
     navigationOptions: {
       title: 'Mentor',
       header:{
         right: //Going to be the users profile picture
       <Icon  
       onPress={() => this.props.navigation.navigate('Profile')}
       name="user" 
       color='#0077B5'
       size={30}
        />,
        left: //Messages
       <Icon  
       name="message" 
       color='#0077B5'
       size={30}
        />,
       titleStyle: { color: '#0077B5' },
      }
     }
   },

我具体需要做什么

Here be the logcat error msg

您需要将子组件的属性传递给

改变

<LoginForm/>

<LoginForm navigation={this.props.navigation}/>

要使其在导航器中工作,请使用参考

<Navigator
 ref='navigator'
 ...
/>

然后

<Icon
  navigator={this.refs.navigator}
/>