DjangoBoys DjangoBoys - 7 months ago 140
React JSX Question

What is the difference between componentWillMount and componentDidMount in ReactJS?

I looked at Facebook's documentation at and it mentions how componentWillMount is invoked on the client/server whereas componentDidMount is invoked only on the client. What does componentWillMount do to the server?


componentWillMount is essentially the constructor. You can set instance properties that don't affect render, pull data from a store synchronously and setState with it, and other simple side effect free code you need to run when setting up your component.

It's rarely needed, and not at all with ES6 classes.