[examples] Updating the Link component example for the Next.js App Router
@sai6855 is already working on this.
Since Sep 1, 2023.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Related page
Kind of issue
Missing information
Issue description
I thought that if I change the lines of code related to usePathname (due to the update in Next version 13) it will work,
...
import { usePathname } from 'next/navigation'
...
...
const nextPathname = usePathname()
const pathname = typeof href === 'string' ? href : href.pathname
const className = clsx(classNameProps, {
[activeClassName]: nextPathname === pathname && activeClassName,
})
...
but I get 3 errors in the browser:
First 2 error messages:
Unhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.Warning: Expected server HTML to contain a matching
<a>in<a>.See more info here: https://nextjs.org/docs/messages/react-hydration-error
Third error message:
Unhandled Runtime Error
Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.
Context 🔦
It would be great if someone could update the example to work in the latest version.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.