React this.state is undefined?

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

    I had the same problem but my issue was trying to access this.state before the this.state = { ... } call finished. Was doing something like this this.state = { ...this.function1() } and function1 = () => { a: this.state.b }. Hope this helps someone

提交回复
热议问题