React native react-native-scrollable-tab-view ScrollableTab 默认不显示指示器问题

本文介绍了一种解决ScrollableTabBar组件初始化后出现滚动异常的方法,通过修改源码中scrollValue的获取方式,从使用_value属性更改为使用__getValue()方法,从而解决了组件在特定情况下的显示错误。

在初始化过后可能会出现此问题,解决方案参考一位 GitHub 的 Issues

需要修改ScrollableTabBar源码:
将this.updateView({value: this.props.scrollValue._value, });
替换为:
this.updateView({value: this.props.scrollValue.__getValue(), });


   measureTab(page, event) {
     const { x, width, height, } = event.nativeEvent.layout;
     this._tabsMeasurements[page] = {left: x, right: x + width, width, height, };
-    this.updateView({value: this.props.scrollValue._value, });
+    this.updateView({value: this.props.scrollValue.__getValue(), });
   },

   render() {
@@ -209,12 +209,12 @@ const ScrollableTabBar = React.createClass({
       width = WINDOW_WIDTH;
     }
     this.setState({ _containerWidth: width, });
-    this.updateView({value: this.props.scrollValue._value, });
+    this.updateView({value: this.props.scrollValue.__getValue(), });
   },

   onContainerLayout(e) {
     this._containerMeasurements = e.nativeEvent.layout;
-    this.updateView({value: this.props.scrollValue._value, });
+    this.updateView({value: this.props.scrollValue.__getValue(), });
   },
 });

链接:https://github.com/skv-headless/react-native-scrollable-tab-view/commit/4312d6cca2fe7859caa5219f2ee8b61edcf04884

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值