title: What's the best practice to call API with react
body: <p>I actually face a small problem in React when calling the API, since <code>ComponentWillMount</code> is deprecated.</p>
  
  <p>I did this: </p>
  
  <pre><code>class MyClass extends Component {
    constructor() {
    super();
  
      this.state = {
        questionsAnswers: [[{ answers: [{ text: '', id: 0 }], title: '', id: 0 }]],
  
      },
    };
  }
  componentDidMount() {
     this.getQuestions();
  }
  
  getQuestions = async () =&gt; {
     let questionsAnswers = await Subscription.getQuestionsAndAnswers();
     questionsAnswers = questionsAnswers.data;
     this.setState({ questionsAnswers });
  };
  </code></pre>
  
  <p>So the page is rendered a first time without <code>questionsAsnwers</code>, when I get the <code>questionAnswers</code> the page is re-rendered</p>
  
  <p>Is there a better solution to avoid a re-render?</p>