mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
29 lines
642 B
TypeScript
29 lines
642 B
TypeScript
import { updateTag, unstable_cache } from 'next/cache'
|
|
import { getUncachedRandomData } from '../no-store-fn'
|
|
import { RevalidateButton } from '../revalidate-button'
|
|
|
|
export default async function Page() {
|
|
async function revalidate() {
|
|
'use server'
|
|
await updateTag('no-store-fn')
|
|
}
|
|
|
|
const cachedData = await unstable_cache(
|
|
async () => {
|
|
return getUncachedRandomData()
|
|
},
|
|
['random'],
|
|
{
|
|
tags: ['no-store-fn'],
|
|
}
|
|
)()
|
|
|
|
return (
|
|
<div>
|
|
<p>random: {Math.random()}</p>
|
|
<p id="data">cachedData: {cachedData.random}</p>
|
|
<RevalidateButton onClick={revalidate} />
|
|
</div>
|
|
)
|
|
}
|