请稍等 ...
×

采纳答案成功!

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

tabNavigator改变主题报错未定义的width

在render里面获取them的时候 老师的代码是这么写的 const { routes, index } = this.props.navigationState 但是我看this.props里面没有navigationState这个属性 所以我是这么写的const { routes, index } = this.props.navigation.state然后再去找里面的theme

但是这样写的就出现了下面的问题 这个在网上都找不到解决办法:

//img1.sycdn.imooc.com//szimg/5b27a71900010d7906661185.jpg

正在回答

1回答

新版本的tabNavigator的api有所变更,可以参考一下代码:

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}
        />
    );
}


0 回复 有任何疑惑可以回复我~
  • 提问者 慕仔3427096 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2018-06-19 11:39:10
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号