0

I have Parent component which renders a Child component, and a Child component have method that updates Parent state. Now I need to write additional method that changes other part of Parent state and call previous method after that. Eventually I have two methods that updating state twice in a row which leads to re-rendering Parent component twice too:

handleReset() {
    this.props.onReset(this.props.rule)
    this.handleChange()
}

handleChange() {
    this.props.buttonClick(this.props.rule, !this.props.oldStateVal)
}

Is this a problem or anti-pattern? I have read somewhere that React might combine few setState calls in a single one in order to improve performance but it doesn't happening.

JamesJGoodwin
  • 350
  • 1
  • 3
  • 17

0 Answers0