📜  超时后的 setstate 反应 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:48.935000             🧑  作者: Mango

代码示例1
this.setState( prevState => ({
  score: prevState.score + 10,
  rightAnswers: prevState.rightAnswers + 1
}));

setTimeout( () => {
  this.setState( prevState => ({
    currentQuestion: prevState.currentQuestion + 1
  }));
}, 2000);