Skip to content

Commit 685bbec

Browse files
authored
Improve readability of the extractCriticalToChunks example in the docs (#2460)
1 parent 218e4f7 commit 685bbec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/ssr.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ const key = 'custom'
4747
const cache = createCache({ key })
4848
const { extractCriticalToChunks, constructStyleTagsFromChunks } = createEmotionServer(cache)
4949

50-
let element = (
50+
const html = renderToString(
5151
<CacheProvider value={cache}>
5252
<App />
5353
</CacheProvider>
5454
)
5555

56-
let { html, styles } = extractCriticalToChunks(renderToString(element))
56+
const chunks = extractCriticalToChunks(html)
57+
const styles = constructStyleTagsFromChunks(chunks)
5758

5859
res
5960
.status(200)
@@ -65,7 +66,7 @@ res
6566
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6667
<meta http-equiv="X-UA-Compatible" content="ie=edge">
6768
<title>My site</title>
68-
${constructStyleTagsFromChunks({ html, styles })}
69+
${styles}
6970
</head>
7071
<body>
7172
<div id="root">${html}</div>

0 commit comments

Comments
 (0)