React this.state is undefined?

前端 未结 9 2385
孤城傲影
孤城傲影 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:04

    The problem is in this context, so use

    this.addUser(event)}> // Inputs
    addUser(event){ event.preventDefault() // Code this.state }

提交回复
热议问题