阵营导航未定义的错误
问题描述:
我有一个有趣的问题:所以我汇入我创建了一个表格, 我把它导入到我要加载的形式类似于下面的屏幕此阵营导航未定义的错误
<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' },
}
}
},
我有什么做的正是
答
你需要的属性,你的子组件传递给
变化
<LoginForm/>
到
<LoginForm navigation={this.props.navigation}/>
对于它在导航运行,使用参考
<Navigator
ref='navigator'
...
/>
然后
<Icon
navigator={this.refs.navigator}
/>
+0
谢谢,这帮助我解决了我的错误!当我在路由器上使用onpress功能时怎么办?我如何将这些属性传递给该特定图标?抛出类似的错误。 –
+0
@DominicGozza查看最新的答案 –
是否有未定义的错误logcat的?如果是这样,请包括它。 – grant