2016-11-15 38 views
0

我能夠定義初始路線(主頁),並且該應用程序導航到該路線。在家裏,我打電話給另一個名爲BoxLists的組件,它按預期顯示。我遇到的問題是從BoxLists中調用另一個名爲StationOne的組件。React Native - 導航到子組件的錯​​誤

我收到以下錯誤:未捕獲的錯誤:不確定是不是(評估「this.props.navigator.push」

所以現在的問題是一個對象?我怎樣才能從BoxLists到StationOne導航

注意:我打算導航到BoxLists附加組件(StationOne,StationTwo,StationN + 1)

下面是代碼雖然可以在https://rnplay.org/apps/rLB5HQ去RNPlayground感謝

回答

0
class Home extends React.Component { 
    render() { 
    return (  
    <View style={{flex: 1}}> 
     <View style={styles.header}> 
     <Text style={styles.headerText}>AdView</Text> 
     </View> 
     <BoxLists author="station one" navigator={this.props.navigator} /> 
    </View>    
    ); 
    } 
} 

您需要通過this.props.navigator爲BoxLists組件如上圖所示

+0

這是它,它的工作!爲什麼不按照文檔中的解釋導航器= {navigator}? – Joel

+0

如果它在文檔中所示的renderNavigationScene內部使用,則導航器作爲該函數的參數。傳遞給組件時,它位於該組件的道具對象中 –