We are displaying product cards in a list, we tried flatlist, recyclerlistview and finally flashlist from shopify, although the scroll performance has improved but its not smooth on all devices. What we noticed is The FlashList is rendering all elements in the initial render even though they are not in view,Also note that the FlashList is wrapped inside a <Animated.ScrollView/> from react native reanimated 2. Also our array is a nested array, rendering FlashList inside FlashList's, The main issue is when we are applying some filter and changing the datasource value the rerender is taking almost 3s and the JS thread is seems to be hanging, This issue happens only for large data sets. We are kind of stuck on this issue and thinking about writing our own native ui component to render list. I have attached the code, please suggest any tweaks or changes we can do to improve performance.
<FlashList
showsVerticalScrollIndicator={false}
contentContainerStyle={{
backgroundColor: Colors.bg_gray,
}}
data={menu}
estimatedItemSize={height}
scrollEventThrottle={16}
renderItem={renderContainerFlatList}
keyExtractor={item => item?._id[0]?.name}
/>
const renderContainerFlatList = useCallback(({item, index}) => {
return (
<View
onLayout={handleOnLayout.bind(this, index)}
style={{
backgroundColor: Colors.bg_gray,
marginTop: 35,
}}>
<Text
style={[
Typography.default[700],
Typography.default.headerSmall,
Typography.default.black,
{
marginTop: 10,
paddingHorizontal: 10,
padding: 10,
backgroundColor: '#fff',
},
]}>
{item?._id[0]?.name} ({item?.products?.length})
</Text>
{item?.products?.length > 0 && (
<FlashList
showsVerticalScrollIndicator={false}
data={item?.products}
renderItem={renderFlatList}
estimatedItemSize={0.4 * width + 50}
/>
)}
</View>
);
}, []);
const renderFlatList = ({item, index}) => {
return <ItemCard data={item?.product} />;
};
Also is it due to our rendering component itself, we do some computation in the component and everycomponent has its own Modalize and Modal component, Is it causing a memory issue ?