Capture values using the lifecycle hook getSnapshotBeforeUpdate in React 16.3

Share this video with your friends

Send Tweet

getSnapshotBeforeUpdate is a lifecycle hook that was introduced with React 16.3. It is invoked right before the most recently rendered output is committed and the value returned by it will be passed as a third parameter to componentDidUpdate. It enables your component to capture current values for example a scroll position before they are potentially changed.

rishi
rishi
~ 6 years ago

code sandbox is not loading

Nik Graf
Nik Graf(instructor)
~ 6 years ago

code sandbox is not loading

Hey rishi, might have been a temporary issue. It's working for me now. Can you check again?

Ozkan Abdullahoglu
Ozkan Abdullahoglu
~ 4 years ago

Hi :) Is there any way to implement the same logic with Hooks?