zyslife/react-native-head-tab-view

initialPage偶发性无效

Synaric opened this issue · 8 comments

Describe the bug

以下是我的代码,页面会偶发显示第0页,华为手机:

let {index} = this.props

...省略代码

 <TabView
          ref={(ref) => {
            this.tabView = ref;
          }}
          tabs={tabs}
          locked={true}
          averageTab={false}
          initialPage={index || 0}
          activeTextStyle={styles.tabActive}
          inactiveTextStyle={styles.tabNormal}
          renderScene={this.renderScene}
          renderTabBar={(props) => {
            return (
              <Tabbar
                {...props}
                lineStyle={styles.lineStyle}
                style={{
                  paddingLeft: rpx(20),
                  paddingRight: rpx(0),
                  paddingBottom: rpx(32),
                }}
                tabItemStyle={{width: rpx(146), height: rpx(50)}}
              />
            );
          }}
        />

诡异的是调试模式无法复现,release包多点几次可以复现

Expected behavior

Package versions

"react-native-head-tab-view": "^4.0.0-rc.11",
"react-native": "^0.63.4",

@Synaric 收到,我抽时间看看。

补充一下导航库版本,不知是否相关:
"react-native-navigation": "^7.11.3",

render()中打印已知this.props.index的值是正常的

@zyslife 你用的是什么标签页组件呢? 我觉得这个应该是该组件的问题,我并没有去操作标签页实际该显示的页面。

标签页组件确实是自己封装的FlatList,显示订单列表
不过问题是,tab的显示也是不正常的,例如以上代码,index打印为1,结果tab第0个高亮

@Synaric 标签页组件如果是你自己封装的,那么你应该是自己去实现一个转换文件吧,类似我提供的react-native-scrollable-tab-view-collapsible-headerreact-native-tab-view-collapsible-header
看看是否这个转换文件 渲染tab的地方有问题。

明白了有版本差异,我是从1.1.4升级的,为了解决点击tab会崩溃的问题

@Synaric 那现在还有问题吗?

没有了,谢谢