Spaces:
Running
Running
Download src/components/Shared/ErrorBoundary.jsx from STAR-GROUP/model-test-react: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Shared/ErrorBoundary.jsx
- Command line
-
hf download hf://spaces/STAR-GROUP/model-test-react/src/components/Shared/ErrorBoundary.jsx
-
curl -L -o ErrorBoundary.jsx https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Shared/ErrorBoundary.jsx
577 Bytes
| import React, { Component } from "react"; | |
| class ErrorBoundary extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { hasError: false }; | |
| } | |
| static getDerivedStateFromError(error) { | |
| return { hasError: true }; | |
| } | |
| componentDidCatch(error, errorInfo) { | |
| console.error("Error caught by ErrorBoundary:", error, errorInfo); | |
| } | |
| render() { | |
| if (this.state.hasError) { | |
| return <h1>Something went wrong. Please try again later.</h1>; | |
| } | |
| return this.props.children; | |
| } | |
| } | |
| export default ErrorBoundary; | |