React this.state is undefined?

前端 未结 9 2384
孤城傲影
孤城傲影 2020-12-01 11:29

I am following a beginner tutorial from Pluralsight, on form submit a value is passed to addUser component method and I need to push userName to this.stat

9条回答
  •  粉色の甜心
    2020-12-01 12:05

    Simpley use async in function

    addUser =async (userName) => { console.log(this.state.users) }

    this will works fine

提交回复
热议问题