mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Fix custom head on getInitialProps works with React 18 ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Co-authored-by: Jiachi Liu <[email protected]>
26 lines
505 B
JavaScript
26 lines
505 B
JavaScript
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
|
|
|
export default function MyDocument() {
|
|
return (
|
|
<Html>
|
|
<Head />
|
|
<body>
|
|
<Main />
|
|
<NextScript />
|
|
</body>
|
|
</Html>
|
|
)
|
|
}
|
|
|
|
MyDocument.getInitialProps = async (context) => {
|
|
const initialProps = await Document.getInitialProps(context)
|
|
|
|
return {
|
|
...initialProps,
|
|
head: [
|
|
...(initialProps?.head ?? []),
|
|
<meta name="test-head-initial-props" content="hello" />,
|
|
],
|
|
}
|
|
}
|