What is the purpose of the getSnapshotBeforeUpdate() lifecycle method?
The getSnapshotBeforeUpdate() method is used to capture information from the DOM just before it potentially changes. This method is called right before the changes from the virtual DOM are reflected in the actual DOM. The return value from this method is passed as the third parameter to componentDidUpdate(). This is useful for cases like preserving scroll position during updates.