mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This PR removes the deprecated sync access to Dynamic APIs. - Removed UnsafeUnwrapped* types. - Replaced `as unknown as UnsafeUnwrapped ` type casts to `as any` for dev warning. - Removed tests that expected sync access to not error. - Removed `UntrackedExotic` functions. - Modified tests that were accidentally doing sync access. - Updated warnings to emphasize that it is a Promise and must be awaited. - Removed paragraph that states access is allowed from `errors/sync-dynamic-apis.mdx`. --------- Co-authored-by: Josh Story <[email protected]>
24 lines
604 B
TypeScript
24 lines
604 B
TypeScript
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 />
|
|
</>
|
|
)
|
|
}
|