Method 1: static getDerivedStateFromError
Updating the State
Whenever an error is thrown in a descendant component, this method is called first, and the error thrown is passed as an argument.
Whatever value is returned from this method is used to update the state of the component.
Let’s update the
ErrorBoundary component to use this lifecycle method.