【发布时间】:2021-09-07 13:21:41
【问题描述】:
我正在使用 react native 并且有带有模态的父组件。当模式打开时,我的带有列表的子组件会重新呈现一次,但界面冻结约 1 或 2 秒取决于列表中的元素。列表的平均大小为 50 个元素。可能是什么问题?
<View style={styles.screenWrapper}>
<View style={styles.container}>
<List
onChoose={onChoose}
flightOffers={paginatedFlightOffers}
isRequesting={isLoadingOffers}
isLoadingMore={isLoadMore}
isLoadingResults={!paginatedFlightOffers.length}
currency={{ value: searchId?.searchId.currencyRates[body.currency], name: body.currency }}
showMoreFlightOffers={showMoreFlightOffers}
/>
</View>
<NativeModal
visible={isDetails}
onClose={onDetailsClose}
animationType="fade"
>
<View>
<Text>asdf</Text>
</View>
</NativeModal>
</View>
Insinde List 组件有 FlatList,有时它会写关注消息和我使用的建议。也许可以避免重新渲染,因为List 组件中的道具保持不变。我曾尝试使用 React.memo,但仍然存在重新渲染
【问题讨论】:
标签: javascript reactjs react-native optimization react-native-flatlist