What is the role of getDerivedStateFromError() in an error boundary?
function App() {
return (
<ErrorBoundary>
<div>{undefinedVar}</div>
</ErrorBoundary>
);
}
Trigger re-render
Log the error
Update state on error
Display fallback UI
This question is part of this quiz :
Error Boundary and Debugging in React