diff --git a/packages/@react-aria/overlays/src/usePreventScroll.ts b/packages/@react-aria/overlays/src/usePreventScroll.ts index ff91b247de9..e1c15ac60b5 100644 --- a/packages/@react-aria/overlays/src/usePreventScroll.ts +++ b/packages/@react-aria/overlays/src/usePreventScroll.ts @@ -11,7 +11,7 @@ */ import {chain, getScrollParent} from '@react-aria/utils'; -import {useEffect} from 'react'; +import {useLayoutEffect} from 'react'; interface PreventScrollOptions { /** Whether the scroll lock is disabled. */ @@ -38,7 +38,7 @@ const visualViewport = typeof window !== 'undefined' && window.visualViewport; export function usePreventScroll(options: PreventScrollOptions = {}) { let {isDisabled} = options; - useEffect(() => { + useLayoutEffect(() => { if (isDisabled) { return; }