mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This ensures we properly honor the `export const fetchCache` config and also ensures we properly bypass fetch-cache when an On-Demand Revalidation is occurring. The `export const dynamic` handling is not changed here as that was behaving correctly and should not influence fetch cache handling only whether a page is prerendered fully or treated as SSR. Fixes: https://github.com/vercel/next.js/issues/47273 x-ref: [slack thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1679078572123979)
22 lines
466 B
JavaScript
22 lines
466 B
JavaScript
import { cache, use } from 'react'
|
|
|
|
export const fetchCache = 'force-no-store'
|
|
|
|
export default function Page() {
|
|
const getData = cache(() =>
|
|
fetch('https://next-data-api-endpoint.vercel.app/api/random?page', {}).then(
|
|
(res) => res.text()
|
|
)
|
|
)
|
|
const dataPromise = getData()
|
|
const data = use(dataPromise)
|
|
|
|
return (
|
|
<>
|
|
<p id="page">/force-no-store</p>
|
|
<p id="page-data">{data}</p>
|
|
<p id="now">{Date.now()}</p>
|
|
</>
|
|
)
|
|
}
|