I am using functional component, in that I am using Flatlist with redux data. I am managing all the state with Redux store. Here is the solution to update the Flatlist data after the api call.
I was first doing like this:-
const DATA = useSelector((state) => state.address.address);
<FlatList
style = {styles.myAddressList}
data = {DATA}
renderItem = {renderItem}
keyExtractor = {item => item._id}
ListEmptyComponent = {EmptyList}
ItemSeparatorComponent={SeparatorWhite}
extraData = {refresh}
/>
but the data was not re-rendering my Flatlist data at all.
As a solution I did like given Below:-
<FlatList
style = {styles.myAddressList}
data = {useSelector((state) => state.address.address)}
renderItem = {renderItem}
keyExtractor = {item => item._id}
ListEmptyComponent = {EmptyList}
ItemSeparatorComponent={SeparatorWhite}
/>
I am passing the Redux state directly to the Flatlist Datasource rather than allocating it to the variable.
Thank you.