Skip to content

Commit 909bdd7

Browse files
committed
Document fonctional style
1 parent 36ceaf2 commit 909bdd7

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/test/frameworks/next/pages/_document.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@ import { getColorSchemeSsrUtils } from "dsfr-react/lib/nextJs";
44

55
const { readColorSchemeFromCookie, getColorSchemeHtmlAttributes } = getColorSchemeSsrUtils();
66

7-
export default class Document extends DefaultDocument {
8-
static async getInitialProps(ctx: DocumentContext) {
9-
10-
const initialProps = await DefaultDocument.getInitialProps(ctx);
7+
export default function Document() {
8+
return (
9+
<Html {...getColorSchemeHtmlAttributes()}>
10+
<Head />
11+
<body>
12+
<Main />
13+
<NextScript />
14+
</body>
15+
</Html>
16+
)
17+
}
1118

12-
readColorSchemeFromCookie(ctx);
19+
Document.getInitialProps = async (ctx: DocumentContext) => {
1320

14-
return { ...initialProps };
21+
const initialProps = await DefaultDocument.getInitialProps(ctx);
1522

16-
}
23+
readColorSchemeFromCookie(ctx);
1724

18-
render() {
19-
return (
20-
<Html {...getColorSchemeHtmlAttributes()}>
21-
<Head />
22-
<body>
23-
<Main />
24-
<NextScript />
25-
</body>
26-
</Html>
27-
);
28-
}
25+
return { ...initialProps };
2926

30-
}
27+
};

0 commit comments

Comments
 (0)