Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native refresh flatlist on swipe down

export default function App() {
  const [isFetching, setIsFetching] = React.useState(false);
  const renderItem = ({ item }) => <Item title={item.title} />;

  const onRefresh = async () => {
    setIsFetching(true);
    await yourAsyncFunction;
    setIsFetching(false);
  };

  return (
    <View>
      <FlatList
        data={flatListItems}
        onRefresh={onRefresh}
        refreshing={isFetching}
        renderItem={renderItem}
        keyExtractor={(item) => item.id}
      />
    </View>
  );
}
 
PREVIOUS NEXT
Tagged: #react #native #refresh #flatlist #swipe
ADD COMMENT
Topic
Name
4+4 =