Spaces:
Sleeping
Sleeping
Download client/src/components/error-boundary.tsx from recursiverall/api-gateway: direct link, hf CLI and curl.
- Browser
- Download file 842 Bytes
-
https://huggingface.co/spaces/recursiverall/api-gateway/resolve/main/client/src/components/error-boundary.tsx
- Command line
-
hf download hf://spaces/recursiverall/api-gateway/client/src/components/error-boundary.tsx
-
curl -L -o error-boundary.tsx https://huggingface.co/spaces/recursiverall/api-gateway/resolve/main/client/src/components/error-boundary.tsx
842 Bytes
| import { Component, type ReactNode } from 'react' | |
| import { Button } from '@/components/ui/button' | |
| interface Props { | |
| children: ReactNode | |
| } | |
| interface State { | |
| hasError: boolean | |
| } | |
| export class ErrorBoundary extends Component<Props, State> { | |
| state: State = { hasError: false } | |
| static getDerivedStateFromError(): State { | |
| return { hasError: true } | |
| } | |
| handleReload = () => { | |
| this.setState({ hasError: false }) | |
| window.location.reload() | |
| } | |
| render() { | |
| if (this.state.hasError) { | |
| return ( | |
| <div className="flex flex-col items-center justify-center gap-4 py-20"> | |
| <p className="text-lg text-muted-foreground">Something went wrong</p> | |
| <Button onClick={this.handleReload}>Reload</Button> | |
| </div> | |
| ) | |
| } | |
| return this.props.children | |
| } | |
| } | |