What is the difference between componentWillMount and componentDidMount in ReactJS?

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.

Leave a Comment