rsnext/packages/next/client/components
Mateusz Burzyński 482fccb922
Adding head element checking for root layout (#43597)
### Update

We removed the `<head>` element checking for root layout in #41621. Since we also need `<head>` for preload in the future, and also css-in-js will require that. We're adding back the `head` element checking to make sure user always provide valid root layout including it.

### Issue

An issue was reported [here](https://github.com/mui/material-ui/issues/34905#issuecomment-1331945868) that the Emotion/MUI site was suffering from FOUC.

After an inspection, I noticed that the SSRed HTML didn't contain the inserted styles at all - despite them being inserted through `useServerInsertedHTML`. I managed to debug it down and discovered that their layout was missing `<head></head>` and thus the stream transformer skipped the insertion altogether cause of this check:
fbc98abab3/packages/next/server/node-web-streams-helper.ts (L177-L183)

I've figured that at the very least we could surface this as a console error in development to nudge the user to fix the missing `<head/>`

cc @huozhi 



Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-12-02 16:41:46 +00:00
..
react-dev-overlay Adding head element checking for root layout (#43597) 2022-12-02 16:41:46 +00:00
app-router-headers.ts Avoid bundling appDir rendering into pages edge SSR bundle (#43184) 2022-11-21 14:09:46 -08:00
app-router.tsx types: better type definition for internal utils (#43070) 2022-11-19 16:09:13 -08:00
dynamic.tsx Alias next/dynamic to lazy impl for appDir (#41216) 2022-10-06 17:41:27 +02:00
error-boundary.tsx Colocate styles with special entries (#42506) 2022-11-08 14:49:13 +01:00
error.tsx Add default not found template (#41750) 2022-10-24 15:46:59 -07:00
headers.ts fix: Dynamic Usage Error when using previewData with generateStaticParams and appDir (#43395) 2022-11-30 20:28:05 -08:00
hooks-server-context.ts Upgrade react@experimental (#40885) 2022-09-25 21:35:05 +02:00
infinite-promise.ts Handle redirects in new router (#40396) 2022-09-20 15:28:07 +02:00
layout-router.tsx Handle head.js on client-side navigation (#42904) 2022-11-16 18:28:04 +01:00
match-segments.ts Flush styles effects (#39268) 2022-08-03 16:21:20 +00:00
navigation.ts Add force-static handling for app dir (#43061) 2022-11-18 09:47:44 -08:00
not-found.ts Add never return type for redirect() and notFound() (#42009) 2022-10-27 15:07:59 -07:00
redirect.ts Add never return type for redirect() and notFound() (#42009) 2022-10-27 15:07:59 -07:00
reducer.ts types: better type definition for internal utils (#43070) 2022-11-19 16:09:13 -08:00
render-from-template-context.tsx Client component directive: use client (#41333) 2022-10-11 10:26:45 -07:00
request-async-storage.ts Replace global with globalThis (#42627) 2022-11-08 14:45:30 +01:00
static-generation-async-storage.ts Add force-static handling for app dir (#43061) 2022-11-18 09:47:44 -08:00
static-generation-bailout.ts Add force-static handling for app dir (#43061) 2022-11-18 09:47:44 -08:00
use-reducer-with-devtools.ts misc: make useReducerWithDevtools noop on server (#41019) 2022-09-29 10:08:44 +00:00