Warning: This synthetic event is reused for performance reasons happening with <input type=“checkbox” />

后端 未结 5 797
故里飘歌
故里飘歌 2021-01-31 07:25

I\'ve been working on a simple react-redux todo example for a class and I came across several warning messages that show in the console everytime I check and uncheck a checkbox

5条回答
  •  感情败类
    2021-01-31 08:19

    I'd suggest trying two solutions:

    First change

    onChange={this.handleCheckbox}
    

    to

    onChange={() => this.handleCheckbox()}
    

    If that won't work, in 'handleCheckbox' add event.persist(); Like this:

    handleCheckbox = (event) => {
      event.persist();
      this.setState({
        isChecked: !this.state.isChecked
      });
    };
    

提交回复
热议问题