[英]React Native Flatlist ListHeaderComponent is not rendered on state change
I have Flatlist with ListHeaderComponent.我有带有 ListHeaderComponent 的 Flatlist。 When state is updated ListHeaderComponent is not updating.
当 state 更新时,ListHeaderComponent 不会更新。 Any suggestion would be helpful.
任何建议都会有所帮助。
<Animated.FlatList data={this.props.store.homeStore.formattedEspeciallyProducts}
contentContainerStyle={styles.flatList}
ref={(ref) => this.flatList = ref}
onScroll={
Animated.event(
[{nativeEvent: {contentOffset: {y: this.scrollY}}}],
{
useNativeDriver: true
}
)
}
renderItem={({ item, index }) => {
return(
<SpecialProduct product={item} even={(index + 1) % 2 === 0}/>
)
}}
showsVerticalScrollIndicator={false}
keyExtractor={item => item.id}
numColumns={2}
onEndReached={this._onEndReached}
onEndReachedThreshold={0.5}
ItemSeparatorComponent={this._itemSeparatorComponent}
removeClippedSubviews={true}
columnWrapperStyle={{paddingHorizontal: 15}}
extraData={language}
ListHeaderComponent={
<View style={CssHelper['flex']}>
<View style={styles.top}>
Since Flatlist is a PureComponent
it will not rerender on state changes.由于 Flatlist 是一个
PureComponent
,它不会在 state 更改时重新呈现。 Pass your state to the data
property to achieve state awareness https://reactnative.dev/docs/flatlist#data将您的 state 传递给
data
属性以实现 state 感知https://reactnative.dev/docs/flatlist#data
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.