Home > Blockchain >  How to Refresh Flatlist data in react-native?
How to Refresh Flatlist data in react-native?

Time:03-27

I want to refresh my flatlist in react-native, i didn't get much answer's from internet .

I am new in react native please help me to get answer.

CodePudding user response:

You can use this answer :

const [isFetching, setIsFetching] = useState(false);

const fetchData = () => {
dispatch(getAllTopicAction(userParamData));
setIsFetching(false);
};

const onRefresh = () => {
setIsFetching(true);
fetchData();
};

<FlatList
data={topics}
keyExtractor={(item) => item.id.toString()}
renderItem={renderItem}
onRefresh={onRefresh}
refreshing={isFetching}
progressViewOffset={100}
ListEmptyComponent={<Empty message="No data found." />}
/>;

One can also use these methods : Flat-list rerender

  • Related