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]>
40 lines
976 B
React
40 lines
976 B
React
import React from 'react'
|
|
import * as next from 'next/headers'
|
|
|
|
export const Dynamic = async ({ pathname, fallback = null, params = null }) => {
|
|
if (fallback) {
|
|
return <div data-fallback>Dynamic Loading...</div>
|
|
}
|
|
|
|
const headers = await next.headers()
|
|
const messages = []
|
|
for (const name of ['x-test-input', 'user-agent']) {
|
|
messages.push({ name, value: headers.get(name) })
|
|
}
|
|
|
|
return (
|
|
<dl>
|
|
{pathname && (
|
|
<>
|
|
<dt>Pathname</dt>
|
|
<dd data-pathname={pathname}>{pathname}</dd>
|
|
</>
|
|
)}
|
|
{messages.map(({ name, value }) => (
|
|
<React.Fragment key={name}>
|
|
<dt>
|
|
Header: <code>{name}</code>
|
|
</dt>
|
|
<dd>{value ?? `MISSING:${name.toUpperCase()}`}</dd>
|
|
</React.Fragment>
|
|
))}
|
|
{params && (
|
|
<>
|
|
<dt>Params</dt>
|
|
<dd data-params={JSON.stringify(params)}>{JSON.stringify(params)}</dd>
|
|
</>
|
|
)}
|
|
</dl>
|
|
)
|
|
}
|