Skip to content

Commit 9e06423

Browse files
lukebrowneClaudéric Demers
authored and
Claudéric Demers
committed
docs: use this.setState functional style in example (#485)
1 parent c2ce3a8 commit 9e06423

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class SortableComponent extends Component {
7373
items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'],
7474
};
7575
onSortEnd = ({oldIndex, newIndex}) => {
76-
this.setState({
77-
items: arrayMove(this.state.items, oldIndex, newIndex),
78-
});
76+
this.setState(({items}) => ({
77+
items: arrayMove(items, oldIndex, newIndex),
78+
}));
7979
};
8080
render() {
8181
return <SortableList items={this.state.items} onSortEnd={this.onSortEnd} />;

0 commit comments

Comments
 (0)