2017-04-06 147 views
1

我有一個有趣的問題:所以我匯入我創建了一個表格, 我把它導入到我要加載的形式類似於下面的屏幕此陣營導航未定義的錯誤

<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

+0

是否有未定義的錯誤logcat的?如果是這樣,請包括它。 – grant

回答

0

你需要的屬性,你的子組件傳遞給

變化

<LoginForm/> 

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

對於它在導航運行,使用參考

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

然後

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

謝謝,這幫助我解決了我的錯誤!當我在路由器上使用onpress功能時怎麼辦?我如何將這些屬性傳遞給該特定圖標?拋出類似的錯誤。 –

+0

@DominicGozza查看最新的答案 –