File size: 878 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import {
unstable_expireTag,
unstable_cacheLife as cacheLife,
unstable_cacheTag,
} from 'next/cache'
import { fetchData } from '../api/data'
// import { Suspense } from 'react'
// import { cookies, headers } from 'next/headers'
function InnerComponent({ children }) {
return <span id="value">{children}</span>
}
async function refresh() {
'use server'
unstable_expireTag('hello')
}
async function reload() {
'use server'
}
async function Component() {
'use cache'
cacheLife({ revalidate: 30 })
unstable_cacheTag('hello')
return <InnerComponent>{await fetchData()}</InnerComponent>
}
export default async function Home() {
return (
<>
<form action={refresh}>
<button id="refresh">Refresh</button>
</form>
<form action={reload}>
<button id="reload">Reload</button>
</form>
<Component />
</>
)
}
|