Я использую контекстный API.
Я хочу отобразить другой значок панели вкладок с контекстным API.
const activityIconHandler = () => {
const {isNewActivity} = useContext(ProfileContext);
if (isNewActivity) {
return <ActivityIcon color={tintColor} />;
} else {
return <ActivityWithYellowSVG />;
}
};
Я пытался сделать это, но это не компонент, поэтому useContext не реализовано.
const TabNavigator = createBottomTabNavigator(
{
Feed: {
screen: Feed,
navigationOptions: {
tabBarIcon: ({tintColor}) => <FeedIcon color={tintColor} />,
tabBarOnPress: async props => {
await props.defaultHandler();
},
title: I18n.t('feed'),
},
},
Activity: {
screen: Activity,
navigationOptions: {
tabBarIcon: ({tintColor, focused}) => activityIconHandler,
tabBarOnPress: async props => {
await props.defaultHandler();
},
title: I18n.t('activity'),
},
},