mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Moved app-dir path params parsing logic from `useParams` to `AppRouter`. This allows for the use of `PathParamsContext` in the `useParams` hook for both pages and app routers. In addition, this allows for memoization of the layout tree which fixes undesired re-renders of the `useParams` hook. Fixes [#58788](https://github.com/vercel/next.js/issues/58788) Closes NEXT-2434 --------- Co-authored-by: Zack Tanner <[email protected]>
15 lines
331 B
TypeScript
15 lines
331 B
TypeScript
'use client'
|
|
import Link from 'next/link'
|
|
import { useParams } from 'next/navigation'
|
|
export default function Page() {
|
|
const params = useParams()
|
|
|
|
return (
|
|
<div>
|
|
<Link href="/foo">Link</Link>
|
|
<div id="random">{Math.random()}</div>
|
|
<div id="params">{JSON.stringify(params?.dynamic)}</div>
|
|
</div>
|
|
)
|
|
}
|