I'm getting started with react-navigation.
How do I change the tabBar background color when I change tab?
Here is some pseudo-code showing what I'm hoping for:
_backgroundColor = function() {
switch (this.routeName) {
case 'tabHome': return { backgroundColor: '#002663' };
case 'tabRewards': return { backgroundColor: '#3F9C35' };
default: return { backgroundColor: 'white' }
}
}
// Tabs setup
export const TabStack = TabNavigator({
tabHome: { screen: HomeStack, },
tabRewards: { screen: RewardsStack, },
}, {
tabBarOptions: {
style: _backgroundColor(),
}
});
At the minute it's always defaulting to white ( which is fine because my code is wrong :-) so how do I pass in something which triggers this logic either on routeName or iconLabel or whatever.
Any help would be most appreciated.
Thanks in advance.
Cheers
Output