3 Matching Annotations
  1. Sep 2022
    1. Do Not Modify State Directly For example, this will not re-render a component: // Wrong this.state.comment = 'Hello'; Instead, use setState(): // Correct this.setState({comment: 'Hello'}); The only place where you can assign this.state is the constructor.

      Change state using setState() or with the hooks, changing the state out of this will NOT re-render the component.