mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
To prepare for an upcoming change where `ppr` will be enabled automatically when `dynamicIO` is enabled, we're disabling `dynamicIO` in the global default cache handler test, and using the `useCache` config instead, because `output: 'standalone'` is currently not compatible with PPR.
46 lines
937 B
TypeScript
46 lines
937 B
TypeScript
import React, { Suspense } from 'react'
|
|
import { revalidate } from './actions'
|
|
import { connection } from 'next/server'
|
|
|
|
async function Random({ cached }: { cached?: boolean }) {
|
|
const data = await fetch(
|
|
'https://next-data-api-endpoint.vercel.app/api/random'
|
|
).then((res) => res.text())
|
|
|
|
return (
|
|
<>
|
|
<p>now: {Date.now()}</p>
|
|
<p>
|
|
{cached ? 'cached ' : ''}random: {data}
|
|
</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
async function CachedRandom() {
|
|
'use cache'
|
|
|
|
return <Random cached />
|
|
}
|
|
|
|
export default async function Page() {
|
|
await connection()
|
|
|
|
return (
|
|
<>
|
|
<p>index page</p>
|
|
<Suspense fallback={<p>Loading...</p>}>
|
|
<Random />
|
|
</Suspense>
|
|
<Suspense fallback={<p>Loading...</p>}>
|
|
<CachedRandom />
|
|
</Suspense>
|
|
<form action={revalidate}>
|
|
<button id="revalidate-tag" type="submit">
|
|
Revalidate tag
|
|
</button>
|
|
</form>
|
|
</>
|
|
)
|
|
}
|