MCPcopy
hub / github.com/kuma-ui/kuma-ui / getInitialProps

Method getInitialProps

example/next/src/pages/_document.tsx:7–30  ·  view source on GitHub ↗
(ctx: DocumentContext)

Source from the content-addressed store, hash-verified

5
6export default class MyDocument extends Document {
7 static async getInitialProps(ctx: DocumentContext) {
8 const registry = createStyleRegistry();
9 const originalRenderPage = ctx.renderPage;
10
11 try {
12 ctx.renderPage = () =>
13 originalRenderPage({
14 enhanceApp: (App) => (props) =>
15 (
16 <StyleRegistry registry={registry}>
17 <App {...props} />
18 </StyleRegistry>
19 ),
20 });
21
22 const initialProps = await Document.getInitialProps(ctx);
23 return {
24 ...initialProps,
25 styles: [initialProps.styles, registry.styles()],
26 };
27 } finally {
28 registry.flush();
29 }
30 }
31
32 render() {
33 return (

Callers

nothing calls this directly

Calls 3

createStyleRegistryFunction · 0.90
stylesMethod · 0.80
flushMethod · 0.65

Tested by

no test coverage detected