Without a boundary the throw unmounts the whole tree.
Acceptance criteria
- 1.#value should show Something went wrong.
Without a boundary the throw unmounts the whole tree.
class Boundary extends React.Component { constructor(props) { super(props) this.state = { failed: false } } static getDerivedStateFromError() { return { failed: true } } render() { if (this.state.failed) return <p id="value">Something went wrong</p> return this.props.children } } function Risky() { throw new Error("boom") } function App() { return <Risky /> } const root = ReactDOM.createRoot(document.getElementById("root")) root.render(<App />)
Output ready when you are
Press Run to render your code, or Submit to validate your solution.