Closed
Description
With FlatList and react-native-big-list the ViewableItems works fine but with FlashList does't works
When the items change the FlashList it's not passing the new state to Component inside of the renderItem
How can I fix It ?
This is a Android APP expo 46 and Expo GO
const onViewRef = React.useRef(({ viewableItems, changed }) => {
if (viewableItems && viewableItems.length > 0) {
setItemState(viewableItems[0]);
}
});
const viewConfigRef = React.useRef({
viewAreaCoveragePercentThreshold: 50,
});
const keyExtractor = useCallback(
(item, index) => `${item.hash}${index}${item.post_id}`,
[]
);
const renderItemFinal = ({ item, index }) => {
if (item?.post_type == "video") {
return (
<Video
patrocinado={item?.patrocinado}
index={index * page}
userStorage={userStorage}
postUnlike={postUnlike}
postLike={postLike}
onViewRef={
itemState?.item?.post_id == item?.post_id && itemState?.isViewable
? true
: false
}
item={item}
/>
);
}
};
const itemRender= useMemo(() => renderItemFinal, [itemState]);
<FlashList
refreshControl={refreshingjsx}
data={videos}
onEndReachedThreshold={0.2}
onEndReached={reachedJsx}
renderItem={itemRender}
onViewableItemsChanged={onViewRef.current}
viewabilityConfig={viewConfigRef.current}
keyExtractor={keyExtractor}
snapToAlignment={"start"}
decelerationRate={"fast"}
snapToInterval={win.height}
itemHeight={win.height}
estimatedItemSize={100}
/>