Method 1: static getDerivedStateFromError
Let's define the getDerivedStateFromError method for the ErrorBoundary component in this lesson.
We'll cover the following
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.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy