flatlist reload react native code example
Example 1: react native flatlist pull to refresh
<FlatList
data={ this.state.FlatListItems }
onRefresh={() => this.onRefresh()}
refreshing={this.state.isFetching}
/>
Example 2: flatlist onrefresh react native
const [isFetching, setIsFetching] = useState(false);
const fetchData = () => {
dispatch(getAllDataAction(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." />}
/>;