I discovered a pretty useful lifecycle event in React. I’ve typically only stuck to getInitialState, componentWillMount, and Render, but I jsut discovered componentWillReceiveProps.

This essentially gets called every time the component will receive a new or updated prop. This is really useful when you want to set a state equal to prop more than once in its lifecycle. The syntax is:

componentWillReceiveProps(props) {

Try this out when you can! It’s really useful.

Posted in Web Development with ReactJS