What is the purpose of getSnapshotBeforeUpdate() lifecycle method?

Posted by Prem Tiwari | Updated on

What is the purpose of getSnapshotBeforeUpdate() lifecycle method?

The new getSnapshotBeforeUpdate() lifecycle method is called right before DOM updates. The return value from this method will be passed as the third parameter to componentDidUpdate().

class MyComponent extends React.Component {

This lifecycle method along with componentDidUpdate() covers all the use cases of componentWillUpdate().


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers