Download spectrum/src/components/error/ErrorBoundary.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 911 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/error/ErrorBoundary.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/error/ErrorBoundary.js
-
curl -L -o ErrorBoundary.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/src/components/error/ErrorBoundary.js
911 Bytes
| // @flow | |
| import * as React from 'react'; | |
| import BlueScreen from './BlueScreen'; | |
| type State = { | |
| error: ?any, | |
| }; | |
| type Props = { | |
| children: any, | |
| fallbackComponent?: ?any, | |
| }; | |
| class ErrorBoundary extends React.Component<Props, State> { | |
| state = { error: null }; | |
| componentDidCatch = (error: any, errorInfo: any) => { | |
| this.setState({ error }); | |
| console.error({ error }); | |
| window.Raven && window.Raven.captureException(error, { extra: errorInfo }); | |
| }; | |
| render() { | |
| const { error } = this.state; | |
| const { | |
| fallbackComponent: FallbackComponent = null, | |
| children, | |
| } = this.props; | |
| if (error) { | |
| if (this.props.fallbackComponent) { | |
| // $FlowFixMe | |
| return <FallbackComponent />; | |
| } | |
| if (!this.props.fallbackComponent) { | |
| return null; | |
| } | |
| return <BlueScreen />; | |
| } | |
| return children; | |
| } | |
| } | |
| export default ErrorBoundary; | |