I'm using the setState to increment the score of a quiz I made. I'm using the callback method so I don't mutate the data but it's only showing me a score of 2. I don't get what i'm doing wrong here.. I'm calling the calculateScore function whenever the form is submitted onSubmit={this.calculateScore}.
if(this.state.question1 === '1996') {
this.setState((curr)=>{
return {score: curr.score++}
})
}
if(this.state.question2 === 'NWA') {
this.setState((curr)=>{
return {score: curr.score++}
})
}
if(this.state.question3 === 'bad-boy') {
this.setState((curr)=>{
return {score: curr.score++}
})
}
if(this.state.question4 === 'big-l') {
this.setState((curr)=>{
return {score: curr.score++}
})
}
if(this.state.question5 === 'snoop-dogg') {
this.setState((curr)=>{
return {score: curr.score++}
})
}
console.log(this.state);
console.log('calculating')
}