Download next.js/test/development/app-dir/dev-fetch-hmr/app/layout.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 836 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-dir/dev-fetch-hmr/app/layout.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/development/app-dir/dev-fetch-hmr/app/layout.tsx
-
curl -L -o layout.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-dir/dev-fetch-hmr/app/layout.tsx
836 Bytes
| import React from 'react' | |
| import { ReactNode } from 'react' | |
| const magicNumber = Math.random() | |
| const originalFetch = globalThis.fetch | |
| if (originalFetch.name === 'monkeyPatchedFetch') { | |
| throw new Error( | |
| 'Patching over already patched fetch. This creates a memory leak.' | |
| ) | |
| } | |
| globalThis.fetch = async function monkeyPatchedFetch( | |
| resource: URL | RequestInfo, | |
| options?: RequestInit | |
| ) { | |
| const request = new Request(resource) | |
| if (request.url === 'http://fake.url/secret') { | |
| return new Response('monkey patching is fun') | |
| } | |
| if (request.url === 'http://fake.url/magic-number') { | |
| return new Response(magicNumber.toString()) | |
| } | |
| return originalFetch(resource, options) | |
| } | |
| export default function Root({ children }: { children: ReactNode }) { | |
| return ( | |
| <html> | |
| <body>{children}</body> | |
| </html> | |
| ) | |
| } | |