ReactJS Array.push function not working in setState

前端 未结 5 1341
粉色の甜心
粉色の甜心 2021-01-17 22:18

I\'m making a primitive quiz app with 3 questions so far, all true or false. In my handleContinue method there is a call to push the users input from a radio fo

5条回答
  •  一生所求
    2021-01-17 22:43

    Array.push does not returns the new array. try using

    this.state.userAnswers.concat([this.state.value])
    

    this will return new userAnswers array

    References: array push and array concat

提交回复
热议问题