Files
Hendrik LiebauandGitHub af74b4a36f Include use-cache test suite in the Cache Components tests (#81610)
We're splitting the test app routes between two root layouts, one for (partially) static pages that does not wrap its children in a Suspense boundary, and one for dynamic pages that adds a Suspense boundary above `body`, which opts those pages into fully dynamic rendering.

Two tests are expected to fail for now, because they revealed bugs related to revalidation, which will be fixed in follow-up PRs:
- https://github.com/vercel/next.js/pull/81611
- https://github.com/vercel/next.js/pull/81621

closes NAR-171
2025-07-16 13:05:25 +02:00

48 lines
1.1 KiB
TypeScript

'use client'
import { useActionState } from 'react'
export function Form({
revalidateAction,
initialValues,
}: {
revalidateAction: (type: 'tag' | 'path') => Promise<[number, number, string]>
initialValues: [number, number, string]
}) {
const [
[useCacheValue1, useCacheValue2, fetchedValue],
revalidate,
isPending,
] = useActionState(
async (_state: [number, number, string], type: 'tag' | 'path') =>
revalidateAction(type),
initialValues
)
return (
<form>
<p>
before revalidate: <span id="use-cache-value-1">{useCacheValue1}</span>
</p>
<p>
after revalidate: <span id="use-cache-value-2">{useCacheValue2}</span>
</p>
<p id="fetched-value">{fetchedValue}</p>
<button
id="revalidate-tag"
formAction={() => revalidate('tag')}
disabled={isPending}
>
Revalidate Tag
</button>
<button
id="revalidate-path"
formAction={() => revalidate('path')}
disabled={isPending}
>
Revalidate Path
</button>
</form>
)
}