Where to make an Initial AJAX request from in ReactJS
frontend, javascript, reactjs
Solution
Since react is meant to be used as a view, your ajax requests are supposed to be placed in your model.
Else, if for some reason you need to make it in a view, the difference between `componentDidMount` and `componentWillMount` is that the first one is being invoked once the element is re-rendered and you have access to it via `this.getDOMNode()`, and the second one is invoked once right before `render()` starts.
Problem
I have a page where I need to load some initial Ajax data. I read on this `Reactjs` page that I should make the call in `componentDidMount`. What is the advantage of making the request from `componentDidMount` rather than `componentWillMount` ?