Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

fix(src): Replace `React.useLayoutEffect` with `useIsomorphicLayoutEffect` (#368)

Axel D.d561b94e1c3b
diff --git a/src/index.tsx b/src/index.tsx
index 1667a26..cdff9f9 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);