Complete the code to import the React Native component used for pull-to-refresh.
import { FlatList, [1] } from 'react-native';
The RefreshControl component is used to add pull-to-refresh functionality in React Native.
Complete the code to set the refreshing state in the component.
const [refreshing, [1]] = React.useState(false);The setter function for the refreshing state is conventionally named setRefreshing.
Fix the error in the RefreshControl usage by completing the missing prop name.
<FlatList
data={data}
renderItem={renderItem}
refreshControl={<RefreshControl refreshing={refreshing} onRefresh=[1] />}
/>The onRefresh prop expects a function to call when the user pulls to refresh. Here, handleRefresh is the function name.
Fill both blanks to complete the pull-to-refresh handler that sets refreshing state correctly.
const handleRefresh = () => {
[1](true);
setTimeout(() => {
[2](false);
}, 2000);
};The function setRefreshing is called to update the refreshing state to true and then back to false after 2 seconds.
Fill all three blanks to complete the FlatList with pull-to-refresh using RefreshControl.
<FlatList
data={data}
renderItem={renderItem}
keyExtractor={item => item.id}
refreshControl={<RefreshControl refreshing=[1] onRefresh=[2] colors={["blue"]} />}
contentContainerStyle={styles.[3]
/>The refreshing state controls the spinner, handleRefresh is the function called on pull, and container is a style for the content container.