【发布时间】:2018-09-06 01:35:21
【问题描述】:
我正在关注 https://github.com/parkerdan/SampleNavigation 将 redux 与 react-navigation 集成。
我有一个问题:嵌套导航器是否应该多次调用addNavigationHelpers?
在示例中:
const routeConfiguration = {
TabOneNavigation: { screen: TabOneNavigation },
TabTwoNavigation: { screen: TabTwoNavigation },
TabThreeNavigation: { screen: TabThreeNavigation },
}
const tabBarConfiguration = {
tabBarOptions:{
activeTintColor: 'white',
inactiveTintColor: 'blue',
activeBackgroundColor: 'blue',
inactiveBackgroundColor: 'white',
}
}
export const TabBar = TabNavigator(routeConfiguration,tabBarConfiguration);
<TabBar
navigation={
addNavigationHelpers({
dispatch: dispatch,
state: navigationState,
})
}
/>
<NavigatorTabOne
navigation={
addNavigationHelpers({
dispatch: dispatch,
state: navigationState
})
}
/>
<NavigatorTabTwo
navigation={
addNavigationHelpers({
dispatch: dispatch,
state: navigationState
})
}
/>
<NavigatorTabThree
navigation={addNavigationHelpers({
dispatch: dispatch,
state: navigationState
})}
/>
addNavigationHelpers 被调用 4 次,一次用于 TabNavigator,另外 3 次用于选项卡。
这是文件推荐的方式吗?
当您嵌套导航器时,导航状态会自动从一个导航器传递到另一个导航器。
【问题讨论】:
标签: react-native react-redux react-navigation