mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
26 lines
552 B
TypeScript
26 lines
552 B
TypeScript
import React from 'react'
|
|
import { cookies, draftMode } from 'next/headers'
|
|
|
|
export default function Page() {
|
|
const { isEnabled } = draftMode()
|
|
let data: string | undefined
|
|
if (isEnabled) {
|
|
data = cookies().get('data')?.value
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<h1>Draft Mode with dynamic cookie</h1>
|
|
<p>
|
|
Random: <em id="rand">{Math.random()}</em>
|
|
</p>
|
|
<p>
|
|
State: <strong id="mode">{isEnabled ? 'ENABLED' : 'DISABLED'}</strong>
|
|
</p>
|
|
<p>
|
|
Data: <em id="data">{data}</em>
|
|
</p>
|
|
</>
|
|
)
|
|
}
|