Download next.js/test/e2e/basepath/pages/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/basepath/pages/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/index.js
861 Bytes
| import { useRouter } from 'next/router' | |
| import Link from 'next/link' | |
| import { useState } from 'react' | |
| import { useEffect } from 'react' | |
| export const getStaticProps = () => { | |
| return { | |
| props: { | |
| nested: false, | |
| hello: 'hello', | |
| }, | |
| } | |
| } | |
| export default function Index({ hello, nested }) { | |
| const { query, pathname, asPath } = useRouter() | |
| const [mounted, setMounted] = useState(false) | |
| useEffect(() => { | |
| setMounted(true) | |
| return () => setMounted(false) | |
| }, []) | |
| return ( | |
| <> | |
| <h1 id="index-page">index page</h1> | |
| <p id="nested">{nested ? 'yes' : 'no'}</p> | |
| <p id="prop">{hello} world</p> | |
| <p id="query">{JSON.stringify(query)}</p> | |
| <p id="pathname">{pathname}</p> | |
| <p id="as-path">{mounted ? asPath : ''}</p> | |
| <Link href="/hello" id="hello-link"> | |
| to /hello | |
| </Link> | |
| </> | |
| ) | |
| } | |