Download next.js/test/e2e/basepath/pages/hello.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/hello.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/basepath/pages/hello.js
-
curl -L -o hello.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/hello.js
1.96 kB
| import Link from 'next/link' | |
| import { useRouter } from 'next/router' | |
| function Page() { | |
| const router = useRouter() | |
| const routerObj = router.isReady ? router : { pathname: '', asPath: '' } | |
| return ( | |
| <> | |
| <Link href="/other-page" id="other-page-link"> | |
| <h1>Hello World</h1> | |
| </Link> | |
| <br /> | |
| <Link href="/gsp" id="gsp-link"> | |
| <h1>getStaticProps</h1> | |
| </Link> | |
| <br /> | |
| <Link href="/gssp" id="gssp-link"> | |
| <h1>getServerSideProps</h1> | |
| </Link> | |
| <br /> | |
| <Link href="/[slug]" as="/first" id="dynamic-link"> | |
| <h1>dynamic page</h1> | |
| </Link> | |
| <br /> | |
| <Link | |
| href="/catchall/[...parts]" | |
| as="/catchall/hello/world" | |
| id="catchall-link" | |
| > | |
| <h1>catchall page</h1> | |
| </Link> | |
| <br /> | |
| <Link href="/" id="index-gsp"> | |
| <h1>index getStaticProps</h1> | |
| </Link> | |
| <br /> | |
| <Link href="/index" id="nested-index-gsp"> | |
| <h1>nested index getStaticProps</h1> | |
| </Link> | |
| <Link href="#hashlink" id="hashlink"> | |
| Hash Link | |
| </Link> | |
| <br /> | |
| <div id="base-path">{router.basePath}</div> | |
| <div id="pathname" suppressHydrationWarning> | |
| {routerObj.pathname} | |
| </div> | |
| <div | |
| id="trigger-error" | |
| onClick={() => { | |
| throw new Error('oops heres an error') | |
| }} | |
| > | |
| click me for error | |
| </div> | |
| <br /> | |
| <div id="as-path" suppressHydrationWarning> | |
| {routerObj.asPath} | |
| </div> | |
| <Link href="/slow-route" id="slow-route"> | |
| <h1>Slow route</h1> | |
| </Link> | |
| <Link href="/error-route" id="error-route"> | |
| <h1>Error route</h1> | |
| </Link> | |
| <Link href="/hello#some-hash" id="hash-change"> | |
| <h1>Hash change</h1> | |
| </Link> | |
| <Link href="/something-else" as="/hello" id="something-else-link"> | |
| to something else | |
| </Link> | |
| </> | |
| ) | |
| } | |
| export default Page | |