DjangoBoys DjangoBoys - 1 year ago 303
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download