React setState not updating state

前端 未结 9 642
慢半拍i
慢半拍i 2020-11-22 05:41

So I have this:

let total = newDealersDeckTotal.reduce(function(a, b) {
  return a + b;
},
0);

console.log(total, \'t         


        
9条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 06:04

    Using async/await

    async changeHandler(event) {
        await this.setState({ yourName: event.target.value });
        console.log(this.state.yourName);
    }
    

提交回复
热议问题