I'm using functional components, and using Flatlist to render list of datas, it's working ok, but each time state get additional data it always re-rendering existing and it will cause performance problem, I have read these articles from SO but still has no clues
here is my code that using main Flatlist
<FlatList
horizontal={false}
showsHorizontalScrollIndicator={false}
data={users}
keyExtractor={(item, index) => String(index)}
renderItem={RenderUser}
onEndReachedThreshold={0.7}
onEndReached={callBackMoreData}
/>
and here is working RenderUser but the problem it re render existing item if state has additional data, what I would like to achieve is only render additional data
import React from 'react';
import { ListItem } from 'react-native-elements';
const RenderUser = ({ item, index }) => {
return (
<React.Fragment>
{ console.log('index: ', index)}
<ListItem
title={item.attributes.name}
/>
</React.Fragment>
);
};
export default RenderUser;
and I did tried using this code below (but I get an error message saying TypeError: renderItem is not a function. (in 'renderItem(props)', 'renderItem' is an instance of object))
import React, { memo } from 'react';
import { ListItem } from 'react-native-elements';
const RenderUser = ({ item, index }) => {
return (
<React.Fragment>
{ console.log('index: ', index)}
<ListItem
title={item.attributes.name}
/>
</React.Fragment>
);
};
export default memo(RenderUser);