Skip to content

Commit be1265d

Browse files
authored
Replace deprecated lifecycle method in README
Since React 16.3 deprecates `componentWillReceiveProps`, it would be nice to replace it with `componentDidUpdate`
1 parent 4f96ec0 commit be1265d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ class SandwichShop extends Component {
262262
);
263263
}
264264

265-
componentWillReceiveProps(nextProps) {
266-
if (nextProps.forPerson !== this.props.forPerson) {
265+
componentDidUpdate(prevProps) {
266+
if (prevProps.forPerson !== this.props.forPerson) {
267267
this.props.dispatch(
268-
makeASandwichWithSecretSauce(nextProps.forPerson)
268+
makeASandwichWithSecretSauce(this.props.forPerson)
269269
);
270270
}
271271
}

0 commit comments

Comments
 (0)