Use componentWillMount or componentDidMount lifecycle functions for async request in React
I am reading up on react lifecycle and am getting a little confused. Some recommend using componentWillMount to make ajax calls:
Calling setState in componentDidMount will trigger another render() call and it can lead to layout thrashing.
and in other places it says not to put ajax calls in the componentWillMount:
...this function might end up being called multiple times before the initial render is called so might result in triggering multiple side-effects. Due to this fact it is not recommended to use this function for any side-effect causing operations.
Which is correct?