请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

TabNavigator, TabBarBottom在react-navigation 新版本里也被抛弃了?

2-7里面讲到的 TabNavigator在使用的时候都会警告。找到用createBottomTabNavigator 替代TabNavigator, 但是2-8里TabBarBottom又不能用了。。


https://img1.sycdn.imooc.com//szimg/5b31cd96000126a103330558.jpg

正在回答 回答被采纳积分+3

1回答

CrazyCodeBoy 2018-06-27 10:07:03

参考代码:

//这里改动
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({//这里改动
...

其他地方不变。

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信