Skip to content

Instantly share code, notes, and snippets.

@aloukissas
Created January 8, 2019 06:36
Show Gist options
  • Save aloukissas/e392dfd64e355a27de42566360431de5 to your computer and use it in GitHub Desktop.
Save aloukissas/e392dfd64e355a27de42566360431de5 to your computer and use it in GitHub Desktop.
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