I have MyComponent using setData() to write data in state and getData() to read the state. Is it best practice in React ? It works fine for me but not sure if what I am doing is the simplest possible way, please advice

```
class MyComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data: []
    };

  }

  setData(){    
    this.setState({data:"123"});   
  }

  getData() {
    console.log(this.state.data); // 123 OK !!!   
  }

  componentDidMount() {    
    this.setData();  

  }
  componentDidUpdate() { 
    this.getData();
  }
  render() {
    return (                     
       <div>           
          {this.state.data} // 123 OK !!!
       </div>                        
    );
  }
}

```