确认下react-navigation的版本如果是2.0以上版本参考如下代码:
import {createDrawerNavigator, createStackNavigator,SafeAreaView,DrawerItems} from 'react-navigation';
import {createBottomTabNavigator, BottomTabBar} from 'react-navigation-tabs';
class TabBarComponent extends React.Component {
constructor(props) {
super(props);
this.theme = {
tintColor: props.activeTintColor,
updateTime: new Date().getTime()
}
}
render() {
const {routes, index} = this.props.navigation.state;
const {theme} = routes[index].params;
if (theme && theme.updateTime > this.theme.updateTime) {
this.theme = theme;
}
/**
* custom tabBarComponent
* https://github.com/react-navigation/react-navigation/issues/4297
*/
return (
<BottomTabBar
{...this.props}
activeTintColor={this.theme.tintColor || this.props.activeTintColor}
/>
);
}
}
export const AppTabNavigator = createBottomTabNavigator({
Page1: {
...