React | Error Boundaries and Debugging | Question 8

Last Updated :
Discuss
Comments

What happens when componentDidCatch() is removed in the following code?

JavaScript
function App() {
    return (
        <ErrorBoundary>
            <button
                onClick={() => {
                    throw new Error();
                }}
            >
                Click me
            </button>
        </ErrorBoundary>
    );
}


Error still caught, not logged

App crashes

Error not caught

App re-renders

Share your thoughts in the comments