MCPcopy Index your code
hub / github.com/dabbott/react-native-express / getInitialProps

Method getInitialProps

pages/_document.tsx:8–32  ·  view source on GitHub ↗
(ctx: DocumentContext)

Source from the content-addressed store, hash-verified

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

Callers 1

_app.tsxFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected