The state object

The state object contains the main data object of the application. Anything that changes in the state object will re-render the component.

The related method to set a specific key in the state is setState. The set state could be called after componentDidMount is called.

 

    constructor(props) {
      super(props);
      this.state = { products: [...] };
    }

    componentDidMount() {
      ....
      this.setState({products});
      .....
    }