Files
f260328900 BREAKING CHANGE: Enable newNextLinkBehavior (#41459)
- Enable newNextLinkBehavior. See #36436 
- Run next/link codemod on test suite

Note that from when this lands on apps trying canary will need to run
the new-link codemod in order to upgrade.
Ideally we have to detect `<a>` while rendering the new link and warn
for it.

Co-authored-by: Steven <[email protected]>
2022-10-17 21:20:28 -04:00

51 lines
1004 B
JavaScript

import Link from 'next/link'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
export default function Page(props) {
const router = useRouter()
const [mounted, setMounted] = useState(false)
useEffect(() => {
setMounted(true)
}, [])
return (
<>
<p id="page">another page</p>
<p id="props">{JSON.stringify(props)}</p>
<p id="router">
{JSON.stringify(
mounted
? {
basePath: router.basePath,
pathname: router.pathname,
asPath: router.asPath,
query: router.query,
}
: {}
)}
</p>
<Link href="/" id="to-index">
to /index
</Link>
<br />
<Link href="/dynamic/first" id="to-dynamic">
to /dynamic/first
</Link>
<br />
</>
)
}
export function getServerSideProps() {
return {
props: {
hello: 'world',
now: Date.now(),
},
}
}