React | Error Boundaries and Debugging | Question 7

Last Updated :
Discuss
Comments

What will be the output of the following code?

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


Error caught, fallback UI shown

App crashes

Button works fine

No UI rendered

Share your thoughts in the comments