File size: 685 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
import { unstable_expireTag, unstable_cache } from 'next/cache'
import { RevalidateButton } from '../revalidate-button'

export const dynamic = 'force-dynamic'

export default async function Page() {
  async function revalidate() {
    'use server'
    await unstable_expireTag('undefined-value-data')
  }

  const cachedData = await unstable_cache(
    async () => {
      return undefined as undefined
    },
    ['undefined-value'],
    {
      tags: ['undefined-value-data'],
    }
  )()

  return (
    <div>
      <p>random: {Math.random()}</p>
      <p id="cached-data">typeof cachedData: {typeof cachedData}</p>
      <RevalidateButton onClick={revalidate} />
    </div>
  )
}