小编gam*_*mar的帖子

在 React Native 中使用初始索引渲染巨大列表的高性能方法

我正在尝试使用使用 Flatlist 的react-native-snap-carousel呈现大量项目。

我的问题是,如果它的索引是 100,我如何立即呈现该项目?如果我下面的代码的 firstItem 索引更高,则性能会很慢。考虑到我已经有了需要渲染的数据。

<Carousel
        data={this.state.data}
        renderItem={this._renderItem}
        itemWidth={WINDOW_WIDTH}
        sliderWidth={WINDOW_WIDTH}
        removeClippedSubviews={true}
        initialNumToRender={this.state.initialIndex + 1}
        maxToRenderPerBatch={3}
        firstItem={this.state.initialIndex}
      />
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-flatlist

6
推荐指数
0
解决办法
821
查看次数