Skip to content

Commit

Permalink
docs: use this.setState functional style in example (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebrowne authored and Claudéric Demers committed Jan 18, 2019
1 parent c2ce3a8 commit 9e06423
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class SortableComponent extends Component {
items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'],
};
onSortEnd = ({oldIndex, newIndex}) => {
this.setState({
items: arrayMove(this.state.items, oldIndex, newIndex),
});
this.setState(({items}) => ({
items: arrayMove(items, oldIndex, newIndex),
}));
};
render() {
return <SortableList items={this.state.items} onSortEnd={this.onSortEnd} />;
Expand Down

0 comments on commit 9e06423

Please sign in to comment.