mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
28 lines
567 B
TypeScript
28 lines
567 B
TypeScript
async function getCachedRandom(x: number, children: React.ReactNode) {
|
|
'use cache: custom'
|
|
return {
|
|
x,
|
|
y: Math.random(),
|
|
r: children,
|
|
}
|
|
}
|
|
|
|
export default async function Page({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
}) {
|
|
const n = +(await searchParams).n!
|
|
const values = await getCachedRandom(
|
|
n,
|
|
<p id="r">rnd{Math.random()}</p> // This should not invalidate the cache
|
|
)
|
|
return (
|
|
<>
|
|
<p id="x">{values.x}</p>
|
|
<p id="y">{values.y}</p>
|
|
{values.r}
|
|
</>
|
|
)
|
|
}
|