2016-03-02 173 views
0

陣營本地NavigatorIOS錯誤 - 陣營本地

當我嘗試去另一頁我不斷收到此錯誤

goToMenu(){ 
this.props.navigator.push({ 
    component: Menu, 
    title: 'Main Menu', 
    passProps: {navigator: this.props.navigator}, 
}) 
} 

<View style={styles.mainContainer}> 
<TouchableHighlight 
    style={styles.menuButton} 
    onPress={this.goToMenu.bind(this)}> 
    <Text style={styles.buttonText}> Go To Menu </Text> 
</TouchableHighlight> 
</View> 

元素類型無效預期字符串(內置組件)或複合組件的類/函數,但得到對象檢查'navigatorios'的渲染方法

+1

'Menu'組件有問題,你能附上它的代碼嗎? – Cherniv

回答

0

這是一個很常見的錯誤。這通常意味着您正在導入的組件存在問題。檢查您是否正在導出Menu並正確導入(相對文件路徑是否正確)。如果文件路徑是正確的......

默認出口

export default() => (
    ... 
); 

然後導入這樣

import Menu from 'relativeFilePath' 

命名出口

或者文件菜單中有多個命名出口,例如

export const Menu ... 
export const SomeOtherComponent ... 

您必須解構進口和匹配名稱...

import {Menu} from 'relativeFilePath' 

詳見這裏ES6+ javascript module export options

如果這不工作,問題是Menu組件您正試圖導航到。