首页 > 解决方案 > React Native - 在 Android 上切换选项卡时 ScrollableTabView 很慢

问题描述

最近开始学习 React Native。我正在使用这个“react-native-scrollable-tab-view”组件,并在里面放置了“react-native-complete-flatlist”组件。我有大约 10 个标签(动态)并且切换标签很慢。

这是我的代码:

<ScrollableTabView 
scrollWithoutAnimation={true}
renderTabBar={() => <ScrollableTabBar />}
onChangeTab={(event)=> this.changeTab(event.i)}
>
    {tabArray.map((data, index) => {
     return <View key={index+1} tabLabel={data} style={{flex:1}}>

         <View style={styles.container}>

          <Spinner visible={this.state.spinner} />

          <CompleteFlatList
          searchKey={['key','imageKey']}
          //highlightColor="yellow"
          pullToRefreshCallback={() => {
          // alert('refreshing');
          }}
          data={FlatListItems}
          ref={c => this.completeFlatList = c}
          renderSeparator={null}
          renderItem={this.cell}
          onEndReached={() => console.log("reach end")}
          onEndReachedThreshold={0}
          //stickyHeaderIndices={[0]}
          />  

        </View>
      </View> 
     })}

</ScrollableTabView>

我打开了 JS Dev Mode -> OFF (Android) 它比以前更好。尽管如此,切换标签时的延迟还是很明显的。请提供有关改善这种滞后的任何建议?

标签: androidiosreactjsreact-native

解决方案


推荐阅读