// Error Boundary — catches render errors in any route so a single broken
// component can't take down the whole app.
//
// Usage:
//
//
//
//
// The `route` prop is used as React's `key` so navigating to a new screen
// auto-resets the error state.
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null, info: null };
}
static getDerivedStateFromError(error) {
return { error };
}
componentDidCatch(error, info) {
// Log to console for now; Phase 5 wires this to a real error tracker.
console.error('[ErrorBoundary]', error, info);
this.setState({ info });
}
reset = () => this.setState({ error: null, info: null });
reload = () => window.location.reload();
render() {
if (!this.state.error) return this.props.children;
return (
Something went wrong
We hit a snag rendering this screen.
Your progress is safe — it's stored in your browser. Try resetting
this screen, or reload the app.