我想在我的DrawerNavigator和TabNavigator之間有一個嵌套視圖,但是我無法使其工作。如何使用環繞嵌套導航器在React native中使用視圖
代碼:
const SubNavigation = TabNavigator({
SubOne: { screen: SubOne },
SubTwo: { screen: SubTwo },
}, {
tabBarComponent: TabBarTop,
tabBarPosition: 'top',
initialRouteName: 'SubOne',
});
class SubScreen extends Component {
static navigationOptions = {
title: 'Subscreen',
};
render() {
const { navigation } = this.props;
return (
<View>
<Header navigation={navigation} />
<SubNavigation navigation={navigation} />
</View>
);
}
}
const PrimaryNav = DrawerNavigator({
StartScreen: { screen: StartScreen },
SubScreen: { screen: SubScreen },
}, {
initialRouteName: 'StartScreen',
});
我不喜歡這樣,因爲我要爲每個PrimaryNav屏幕自定義標題。我真的不知道這是否是最佳做法,我習慣使用react-router來定義與此類似的容器組件。
我得到上面的代碼錯誤Cannot read property 'forEach' of undefined
。
從錯誤日誌,你可以看到,如果異常是從反應導航調用堆棧或從自己的代碼來了嗎?發佈錯誤屏幕會很有幫助。 – dotcomXY