next.js/test/development/app-dir/async-request-warnings/app/request/draftMode/page.tsx
page.tsx24 lines604 B
import { draftMode } from 'next/headers'

function Component() {
  // Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access
  const isEnabled = (draftMode() as any).isEnabled
  ;(draftMode() as any).enable()

  const clonedDraftMode = {
    ...(draftMode() as any),
  }
  return <pre>{JSON.stringify({ clonedDraftMode, isEnabled }, null, 2)}</pre>
}

export default function Page() {
  const isEnabled = (draftMode() as any).isEnabled
  return (
    <>
      <pre>{JSON.stringify({ isEnabled }, null, 2)}</pre>
      <Component />
      <Component />
    </>
  )
}
Quest for Codev2.0.0
/
SIGN IN