React form onChange->setState one step behind

前端 未结 7 1520
南方客
南方客 2020-12-02 12:21

I encountered this problem building a webapp and I replicated it in this jsfiddle. Essentially, I would like an input to call this.setState({message: input_val})

相关标签:
7条回答
  • 2020-12-02 12:54

    Knowing the problem is with not having asyncronous behaviour of setState I solved my issue with async await

    onChangeEmail=async x =>{
    await this.setState({email:x})
    }
    
    0 讨论(0)
提交回复
热议问题