Implementing pull to refresh
The pull to refresh gesture is a common action on mobile devices. It allows users to refresh the content of a view without having to lift a finger from the screen or manually reopen the app, just by pulling it down to trigger a page refresh. Loren Brichter, the creator of Tweetie (later Twitter for iPhone) and Letterpress, introduced this gesture in 2009. This gesture has become so popular that Apple integrated it into its SDKs as UIRefreshControl
.
To use pull to refresh in the FlatList
app, we just need to pass a few props and handlers. Let's take a look at our List
component:
export default function List({ data, fetchItems, refreshItems, isRefreshing }) { return ( <FlatList data={data} renderItem={({ item }) => <Text style={styles.item}>{item.value}</Text>}...