title: How to call a method in render instead of componentDidUpdate?
body: <p>I want to avoid componentDidUpdate lifecycle and want to call a method within render. Since I am not loading data in this component I want to get rid of componentDidUpdate.</p>
  
  <p>Below is the code,</p>
  
  <pre><code>export default class child extends React.Component {
      state = {
          query: '',
          data: null,
      };
      empty_id = 0xffffffff;
  
      componentDidMount() {
          this.set_open_data();
      }
  
      componentDidUpdate(prevProps) {
         if (prevProps.id !== this.props.id) {
              this.set_data();
         }
      }
  
      set_data = () =&gt; {
          if (!this.props.info) {
              return;
          }
          if (this.props.id === this.empty_id) {
              this.setState({data: null});
              return;
          }
  
          let data = {
              info: [],
              values: [],
          };
          const info = this.props.info;
          for (let i=0, ii=info.length; i &lt; ii; i++) {
              if (info[i].meshes.includes(this.props.id)) {
                  const info = info[i].info;
                  const values = info[i].values;
                  data = {
                      info: typeof info === 'string' ? info.split('\r\n') : [],
                      values: values ? values : [],
                  };
                  break;
              }
          }
          this.setState({data: this.filter_data(data, this.state.query)});
        };
        render = () =&gt; {
            /* i want to call set_data here but should not sure of when to be 
           called meaning condition like in componentdidupdate method*/
           this.set_data();};}
  </code></pre>
  
  <p>Could someone help me solve this? Thanks.</p>