|
1 |
| -import React, { Component, ReactElement, ReactNode, useContext } from 'react' |
| 1 | +import React, { ReactElement, ReactNode, useContext } from 'react' |
2 | 2 | import {
|
3 | 3 | OPTIMIZED_FONT_PROVIDERS,
|
4 | 4 | NEXT_BUILTIN_DOCUMENT,
|
@@ -353,7 +353,13 @@ function getAmpPath(ampPath: string, asPath: string): string {
|
353 | 353 | return ampPath || `${asPath}${asPath.includes('?') ? '&' : '?'}amp=1`
|
354 | 354 | }
|
355 | 355 |
|
356 |
| -export class Head extends Component<HeadProps> { |
| 356 | +// Use `React.Component` to avoid errors from the RSC checks because |
| 357 | +// it can't be imported directly in Server Components: |
| 358 | +// |
| 359 | +// import { Component } from 'react' |
| 360 | +// |
| 361 | +// More info: https://github.com/vercel/next.js/pull/40686 |
| 362 | +export class Head extends React.Component<HeadProps> { |
357 | 363 | static contextType = HtmlContext
|
358 | 364 |
|
359 | 365 | context!: React.ContextType<typeof HtmlContext>
|
@@ -899,7 +905,7 @@ function handleDocumentScriptLoaderItems(
|
899 | 905 | __NEXT_DATA__.scriptLoader = scriptLoaderItems
|
900 | 906 | }
|
901 | 907 |
|
902 |
| -export class NextScript extends Component<OriginProps> { |
| 908 | +export class NextScript extends React.Component<OriginProps> { |
903 | 909 | static contextType = HtmlContext
|
904 | 910 |
|
905 | 911 | context!: React.ContextType<typeof HtmlContext>
|
@@ -1104,7 +1110,9 @@ export function Main() {
|
1104 | 1110 | * `Document` component handles the initial `document` markup and renders only on the server side.
|
1105 | 1111 | * Commonly used for implementing server side rendering for `css-in-js` libraries.
|
1106 | 1112 | */
|
1107 |
| -export default class Document<P = {}> extends Component<DocumentProps & P> { |
| 1113 | +export default class Document<P = {}> extends React.Component< |
| 1114 | + DocumentProps & P |
| 1115 | +> { |
1108 | 1116 | /**
|
1109 | 1117 | * `getInitialProps` hook returns the context object with the addition of `renderPage`.
|
1110 | 1118 | * `renderPage` callback executes `React` rendering logic synchronously to support server-rendering wrappers
|
|
0 commit comments