From b56385fe833078dc918b4f19edc66ee068140f6f Mon Sep 17 00:00:00 2001 From: axeldesutter Date: Sun, 2 Jun 2024 16:17:00 +0200 Subject: [PATCH] fix(src): Replace `React.useLayoutEffect` with `useIsomorphicLayoutEffect` for SSR --- src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 1667a260..cdff9f9f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,7 +4,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog'; import React, { useRef, useState } from 'react'; import { DrawerContext, useDrawerContext } from './context'; import './style.css'; -import { usePreventScroll, isInput, isIOS } from './use-prevent-scroll'; +import { usePreventScroll, isInput, isIOS, useIsomorphicLayoutEffect } from './use-prevent-scroll'; import { useComposedRefs } from './use-composed-refs'; import { usePositionFixed } from './use-position-fixed'; import { useSnapPoints } from './use-snap-points'; @@ -139,7 +139,7 @@ function Root({ nested, hasBeenOpened, preventScrollRestoration, - noBodyStyles + noBodyStyles, }); function getScale() { @@ -453,7 +453,7 @@ function Root({ }, [isOpen, shouldScaleBackground]); // LayoutEffect to prevent extra render where openProp and isOpen are not synced yet - React.useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { if (openProp) { setIsOpen(true); setHasBeenOpened(true);