mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
The `use-cache-dev` suite only covers dev-mode HMR behavior of `use cache`, so it belongs under `test/development/app-dir` alongside the other `cache-components-dev-*` suites rather than in `test/e2e`. Because `test/development` runs only in dev mode and is never deployed, the production-mode placeholder guard, the `skipDeployment` option, and the `if (skipped)` early return are all dropped. The three test manifests that referenced the old path are updated. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
46 lines
1001 B
TypeScript
46 lines
1001 B
TypeScript
import { revalidatePath } from 'next/cache'
|
|
import Link from 'next/link'
|
|
|
|
async function getRandomValue() {
|
|
'use cache'
|
|
|
|
return Math.random()
|
|
}
|
|
|
|
async function getData() {
|
|
'use cache'
|
|
|
|
return fetch('https://next-data-api-endpoint.vercel.app/api/random').then(
|
|
(res) =>
|
|
res
|
|
.text()
|
|
.then(async (text) => [text, 'foo', await getRandomValue()] as const)
|
|
)
|
|
}
|
|
|
|
export default async function Page() {
|
|
const [fetchedRandom, text, mathRandom] = await getData()
|
|
|
|
return (
|
|
<>
|
|
<div id="container">
|
|
<p id="fetchedRandom">{fetchedRandom}</p>
|
|
<p id="text">{text}</p>
|
|
<p id="mathRandom">{mathRandom}</p>
|
|
</div>
|
|
<p id="uncached">{new Date().toISOString()}</p>
|
|
<form
|
|
action={async () => {
|
|
'use server'
|
|
revalidatePath('/')
|
|
}}
|
|
>
|
|
<button id="revalidate">Revalidate</button>
|
|
</form>
|
|
<p>
|
|
<Link href="/some/path">Go to /some/path</Link>
|
|
</p>
|
|
</>
|
|
)
|
|
}
|