Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ListsScreen extends React.Component {
state = {
data: [0, 1, 2, 3, 4],
isRefreshing: false
};
refreshData = () => {
this.setState({ isRefreshing: true });
const data = this.state.data.map(x => x * 2);
this.setState({ data, isRefreshing: false });
};
render() {
return (
<View>
<FlatList
data={this.state.data}
renderItem={({ item }) => <Text>{`item ${item}`}</Text>}
keyExtractor={(item, index) => `key-${index}`}
onRefresh={this.refreshData}
refreshing={this.state.isRefreshing}
/>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.