Files
3e5b0253e4 Fix document head with react 18 (#37443)
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]>
2022-06-04 10:30:42 +00:00

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" />,
],
}
}