Skip to content

Commit 500c8ae

Browse files
committed
[dev-overlay] Fix unactionable useLayoutEffect warning if React 18 is used
1 parent b6b9c22 commit 500c8ae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/next/src/client/components/react-dev-overlay/ui/components/shadow-portal.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export function ShadowPortal({ children }: { children: React.ReactNode }) {
77
let shadowNode = React.useRef<ShadowRoot | null>(null)
88
let [, forceUpdate] = React.useState<{} | undefined>()
99

10-
React.useLayoutEffect(() => {
10+
// Don't use useLayoutEffect here, as it will cause warnings during SSR in React 18.
11+
// Don't use useSyncExternalStore as an SSR gate unless you verified it doesn't
12+
// downgrade a Transition of the initial root render to a sync render or
13+
// we can assure the root render is not a Transition.
14+
React.useEffect(() => {
1115
const ownerDocument = document
1216
portalNode.current = ownerDocument.createElement('nextjs-portal')
1317
// load default color preference from localstorage

0 commit comments

Comments
 (0)