TabNavigator, TabBarBottom在react-navigation 新版本里也被抛弃了?
来源:2-8 TabNavigator精讲-3
lincolnhuj
2018-06-26
2-7里面讲到的 TabNavigator在使用的时候都会警告。找到用createBottomTabNavigator 替代TabNavigator, 但是2-8里TabBarBottom又不能用了。。
写回答
1回答
-
CrazyCodeBoy
2018-06-27
参考代码:
//这里改动 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({//这里改动 ...
其他地方不变。
00
相似问题