Files
Hendrik LiebauandGitHub 5442d09221 Disable dynamicIO in global default cache handler test (#79300)
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.
2025-05-17 16:32:32 +02:00

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>
</>
)
}