Question · JavaScript and React course · Module 16: Error Handling and Suspense
getDerivedStateFromError
What does the static getDerivedStateFromError(error) method do in an Error Boundary?
Answer options
- Removes the component from the DOM tree and inserts an empty div
- Sends the error to a monitoring server
- Returns an object that updates state so the next render shows a fallback UI
- Fixes the error automatically and continues rendering
You can check the correct answer by solving this task in the CodeWorlds game.