Updating name of variable to which returned value of setState is assigned (#3701)

in CodePen it is 'prevState' and in the tutorial, it is 'state', which creates confusion.
This commit is contained in:
CodeChari
2021-05-28 11:51:10 +05:30
committed by GitHub
parent f6c2e0690e
commit ec2d0adcb4

View File

@@ -71,8 +71,8 @@ class Toggle extends React.Component {
}
handleClick() {
this.setState(state => ({
isToggleOn: !state.isToggleOn
this.setState(prevState => ({
isToggleOn: !prevState.isToggleOn
}));
}