feat(curriculum): update handleclick method to use state function (#42225)

* Updated the handleClick method to use updater function in react tutorial english

* Update comments in the seed code of curriculum/challenges/english/03-front-end-libraries/react/render-conditionally-from-props.md

Changing comments in the seed code according to the list of [agreed-upon comments](https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/dictionaries/english/comments.json)

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
suburban-daredevil
2021-05-27 22:12:55 +05:30
committed by GitHub
parent 3c36bda9ab
commit d70b17bca7

View File

@ -240,8 +240,11 @@ class GameOfChance extends React.Component {
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
} }
handleClick() { handleClick() {
this.setState({ this.setState(prevState => {
counter: 0 // Change this line // Complete the return statement:
return {
counter: prevState
}
}); });
} }
render() { render() {
@ -280,8 +283,10 @@ class GameOfChance extends React.Component {
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
} }
handleClick() { handleClick() {
this.setState({ this.setState(prevState => {
counter: this.state.counter + 1 return {
counter: prevState.counter + 1
}
}); });
} }
render() { render() {