Method 2: getSnapshotBeforeUpdate Extension in Detail
componentDidUpdate Lifecycle Method
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
Let’s call the returned value from
getSnapshotBeforeUpdate, snapshot. Here’s what we get: