mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
864f065392
This adds the discussed updated cache handling for app dir for more fine grained control over the cached values. Also adds initial `revalidateTag` and `revalidatePath` exports from `next/server` although export location may change. Continuation of https://github.com/vercel/next.js/pull/47720 x-ref: [slack thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1681404363048459)
19 lines
447 B
JavaScript
19 lines
447 B
JavaScript
import { cache, use } from 'react'
|
|
|
|
export default function Layout({ children }) {
|
|
const getData = cache(() =>
|
|
fetch('https://next-data-api-endpoint.vercel.app/api/random?layout', {
|
|
next: { revalidate: 10, tags: ['thankyounext'] },
|
|
}).then((res) => res.text())
|
|
)
|
|
const dataPromise = getData()
|
|
const data = use(dataPromise)
|
|
|
|
return (
|
|
<>
|
|
<p id="layout-data">revalidate 10: {data}</p>
|
|
{children}
|
|
</>
|
|
)
|
|
}
|