ReactJS: Warning: setState(…): Cannot update during an existing state transition

后端 未结 11 1125
一个人的身影
一个人的身影 2020-11-27 10:32

I am trying to refactor the following code from my render view:

11条回答
  •  隐瞒了意图╮
    2020-11-27 10:55

    Looks like you're accidentally calling the handleButtonChange method in your render method, you probably want to do onClick={() => this.handleButtonChange(false)} instead.

    If you don't want to create a lambda in the onClick handler, I think you'll need to have two bound methods, one for each parameter.

    In the constructor:

    this.handleButtonChangeRetour = this.handleButtonChange.bind(this, true);
    this.handleButtonChangeSingle = this.handleButtonChange.bind(this, false);
    

    And in the render method:

    
    
    

提交回复
热议问题