react-code-dataset / next.js /test /development /app-dir /owner-stack /app /browser /caught /page.js
Download next.js/test/development/app-dir/owner-stack/app/browser/caught/page.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 646 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-dir/owner-stack/app/browser/caught/page.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/development/app-dir/owner-stack/app/browser/caught/page.js
-
curl -L -o page.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-dir/owner-stack/app/browser/caught/page.js
646 Bytes
| 'use client' | |
| import { Component } from 'react' | |
| class MyErrorBoundary extends Component { | |
| static getDerivedStateFromError(error) { | |
| return { error } | |
| } | |
| state = { error: null } | |
| render() { | |
| if (this.state.error) { | |
| return 'failed' | |
| } | |
| return this.props.children | |
| } | |
| } | |
| function Inner() { | |
| return ( | |
| <MyErrorBoundary> | |
| <Thrower /> | |
| </MyErrorBoundary> | |
| ) | |
| } | |
| function Thrower() { | |
| useErrorHook() | |
| } | |
| function useThrowError() { | |
| if (typeof window !== 'undefined') { | |
| throw new Error('browser error') | |
| } | |
| } | |
| function useErrorHook() { | |
| useThrowError() | |
| } | |
| export default function Page() { | |
| return <Inner /> | |
| } | |