Just to mention something that recently changed: in React 16.3.0, some lifecycle methods have been deprecated:
componentWillMount()
componentWillReceiveProps()
componentWillUpdate()
They still can be used for now, but you would need to prefix it with UNSAFE_, like UNSAFE_componentWillMount, UNSAFE_componentWillReceiveProps, and UNSAFE_componentWillUpdate.
These are expected to be removed on React 17.
We got then some new methods to compensate for that:
getDerivedStateFromProps(props, state) - Called after a component is instantiated as well as before it is re-rendered. It can return an object to update state, or null to indicate that the new props do not require any state updates.
getSnapshotBeforeUpdate(prevProps, prevState) - Called right before mutations are made (e.g. before the DOM is updated). The return value for this lifecycle will be passed as the third parameter to componentDidUpdate. (This lifecycle isn’t often needed, but can be useful in cases like manually preserving scroll position during rerenders.)
Excellent list, great job @migueloop !
Just to mention something that recently changed: in React 16.3.0, some lifecycle methods have been deprecated:
They still can be used for now, but you would need to prefix it with
UNSAFE_
, likeUNSAFE_componentWillMount
,UNSAFE_componentWillReceiveProps
, andUNSAFE_componentWillUpdate
.These are expected to be removed on React 17.
We got then some new methods to compensate for that:
Source (with examples): Update on Async Rendering.
That's true Tiago. When I first did my list we had an older version of React. I will update it asap. Thanks so much
You are welcome, Miguel!
And totally, these things change so fast these days!
Updated Tiago! Thanks a lot