Ожидаемое поведение: должен быть открыт ящик с значком меню в заголовке.
Текущее поведение: сообщение об ошибке undefined is not an object ('evaluating this.props.navigation')
Поиск ошибки мне не помог.
Я разделил навигацию на два файла: RootNavigation.js и MainTabNavigation
RootNavigation.js
const AppNavigator = createSwitchNavigator({
Main: MainTabNavigator,
});
const DrawerStack = createDrawerNavigator({
Home: {
screen: AppNavigator
},
Login: {
screen: login
},
Signup: {
screen: signup
}
});
export default class RootNavigation extends React.Component {
componentDidMount() {
this._notificationSubscription = this._registerForPushNotifications();
}
MainTabNavigation.js
const HomeStack = createStackNavigator({
Home: HomeScreen,
});
HomeStack.navigationOptions = {
tabBarLabel: 'Home',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
name={
Platform.OS === 'ios'
? `ios-home${focused ? '' : '-outline'}`
: 'md-home'
}
/>
),
};
const LinksStack = createStackNavigator({
Links: LinksScreen,
});
LinksStack.navigationOptions = {
tabBarLabel: 'Shops',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
name={Platform.OS === 'ios' ? `ios-list${focused ? '' : '-outline'}` : 'md-list'}
/>
),
};
const SettingsStack = createStackNavigator({
Settings: SettingsScreen,
});
SettingsStack.navigationOptions = {
tabBarLabel: 'Cart',
tabBarIcon: ({ focused }) => (
<TabBarIcon
focused={focused}
name={Platform.OS === 'ios' ? `ios-cart${focused ? '' : '-outline'}` : 'md-cart'}
/>
),
};
export default createBottomTabNavigator({
HomeStack,
LinksStack,
SettingsStack,
});
MainTab файл, который отображает значок в заголовке
static navigationOptions = ({navigation}) =>({
title: 'Home',
headerLeft: <Ionicons
name="md-menu"
size={25}
color="blue"
style={{ margin: 7,}}
onPress={() => this.props.navigation.navigate('DrawerOpen')}
/>
});