Method 2: getSnapshotBeforeUpdate Extension in Detail
This lesson is an extension of the previous lesson. We'll discuss getSnapshotBeforeUpdate components and the chat panel in more detail.
We'll cover the following...
The componentDidUpdate
Lifecycle Method
The getSnapshotBeforeUpdate
lifecycle method doesn’t work on its own. It is meant to be used in conjunction with the componentDidUpdate
lifecycle method.
Whatever value is returned from the getSnapshotBeforeUpdate
lifecycle method is passed as the third argument to the componentDidUpdate
method.
Let’s call the returned value from getSnapshotBeforeUpdate
, snapshot. Here’s what we get:
componentDidUpdate(prevProps, prevState, snapshot) {}
The componentDidUpdate
lifecycle method is invoked after the getSnapshotBeforeUpdate
. As with the getSnapshotBeforeUpdate
method, it receives the previous props and state as arguments. It also receives the returned value from ...