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);