Files
adopt-a-street/frontend/src/components/ErrorBoundary.js
William Valentin 2df5a303ed refactor: convert frontend from submodule to true monorepo
Convert frontend from Git submodule to a regular monorepo directory for simplified development workflow.

Changes:
- Remove frontend submodule tracking (mode 160000 gitlink)
- Add all frontend source files directly to main repository
- Remove frontend/.git directory
- Update CLAUDE.md to clarify true monorepo structure
- Update Frontend Architecture documentation (React Router v6, Socket.IO, Leaflet, ErrorBoundary)

Benefits of Monorepo:
- Single git clone for entire project
- Unified commit history
- Simpler CI/CD pipeline
- Easier for new developers
- No submodule sync issues
- Atomic commits across frontend and backend

Frontend Files Added:
- All React components (MapView, ErrorBoundary, TaskList, SocialFeed, etc.)
- Context providers (AuthContext, SocketContext)
- Complete test suite with MSW
- Dependencies and configuration files

Branch Cleanup:
- Using 'main' as default branch (develop deleted)
- Frontend no longer has separate Git history

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 11:01:06 -07:00

63 lines
1.7 KiB
JavaScript

import React from "react";
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false, error: null, errorInfo: null };
}
static getDerivedStateFromError(error) {
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
console.error("ErrorBoundary caught an error:", error, errorInfo);
this.setState({
error: error,
errorInfo: errorInfo,
});
}
render() {
if (this.state.hasError) {
return (
<div className="container mt-5">
<div className="alert alert-danger" role="alert">
<h2 className="alert-heading">Something went wrong</h2>
<p>
We're sorry, but something unexpected happened. Please try
refreshing the page.
</p>
{process.env.NODE_ENV === "development" && this.state.error && (
<details className="mt-3" style={{ whiteSpace: "pre-wrap" }}>
<summary>Error details (development only)</summary>
<p className="mt-2">
<strong>Error:</strong> {this.state.error.toString()}
</p>
{this.state.errorInfo && (
<p>
<strong>Stack trace:</strong>
<br />
{this.state.errorInfo.componentStack}
</p>
)}
</details>
)}
<hr />
<button
className="btn btn-primary"
onClick={() => window.location.reload()}
>
Refresh Page
</button>
</div>
</div>
);
}
return this.props.children;
}
}
export default ErrorBoundary;