componentDidMount. By the time componentDidMount is called, the component has been rendered once. In practice, componentDidMount is the best place to put calls to fetch data, for two reasons: Using didMount makes it clear that data won’t be loaded until after the initial render. How To Use Async Await in React: frequently asked questions. componentDidMount is the natural place for using async/await in React. After all you want to fetch data from APIs as soon as the component mounts.

Mar 10, 2018 · setState and re-rendering. setState() will always lead to a re-render unless shouldComponentUpdate() returns false. To avoid unnecessary renders, calling setState() only when the new state differs from the previous state makes sense and can avoid calling setState() in an infinite loop within certain lifecycle methods like componentDidUpdate.