我正在使用react-navigation中的createBottomTabNavigator创建底部标签栏。我需要从选项卡屏幕之一(配置文件)内部使用的内部组件访问导航道具。为此,我在主屏幕中使用了NavigationFocus。
//HomeScreen.js
//Tab navigator
const TabScreens = createBottomTabNavigator(
{
Profile: {
screen: ProfileTab,
path: 'Profile'
},
// other screens
},
{
// Tab bar configs
}
);
// Usage of withNavigation
export default withNavigation(
connect(mapStateToProps)(withNavigationFocus(HomeScreen))
);
但是我在内部组件中获得undefined
的导航。