1- import React , { useMemo } from "react" ;
1+ import React , { useMemo , Suspense } from "react" ;
22import { objectKeys } from "tsafe/objectKeys" ;
33import { getAssetUrl } from "../tools/getAssetUrl" ;
44import AppleTouchIcon from "../dsfr/favicon/apple-touch-icon.png" ;
@@ -14,7 +14,7 @@ import { assert } from "tsafe/assert";
1414// @import url(...) doesn't work. Using Sass and @use is our last resort.
1515import "../assets/dsfr_plus_icons.scss" ;
1616// eslint-disable-next-line @typescript-eslint/no-unused-vars -- used in doc
17- import { type startReactDsfr } from "./zz_internal/start" ;
17+ import type { startReactDsfr } from "./zz_internal/start" ;
1818
1919export type DsfrHeadProps = {
2020 /** If not provided no fonts are preloaded.
@@ -94,27 +94,34 @@ export function DsfrHead(props: DsfrHeadProps) {
9494 < link rel = "shortcut icon" href = { getAssetUrl ( FaviconIco ) } type = "image/x-icon" />
9595 </ >
9696 ) }
97- < script
98- suppressHydrationWarning
99- nonce = { nonce }
100- dangerouslySetInnerHTML = { {
101- "__html" : getScriptToRunAsap ( {
102- defaultColorScheme,
103- nonce,
104- trustedTypesPolicyName
105- } )
106- } }
107- />
108- { nonce !== undefined && (
97+ { /*
98+ This suspense is only a workaround for an incompatibility between RSC and Cypress.
99+ See: https://github.com/cypress-io/cypress/issues/27204#issuecomment-1625490068
100+ It is in practice a no-op.
101+ */ }
102+ < Suspense >
109103 < script
110104 suppressHydrationWarning
111- key = "nonce-setter"
112105 nonce = { nonce }
113106 dangerouslySetInnerHTML = { {
114- __html : `window.ssrNonce = "${ nonce } ";`
107+ "__html" : getScriptToRunAsap ( {
108+ defaultColorScheme,
109+ nonce,
110+ trustedTypesPolicyName
111+ } )
115112 } }
116113 />
117- ) }
114+ { nonce !== undefined && (
115+ < script
116+ suppressHydrationWarning
117+ key = "nonce-setter"
118+ nonce = { nonce }
119+ dangerouslySetInnerHTML = { {
120+ __html : `window.ssrNonce = "${ nonce } ";`
121+ } }
122+ />
123+ ) }
124+ </ Suspense >
118125 </ >
119126 ) ;
120127}
0 commit comments