useLayoutEffect instead

This commit is contained in:
Lim Chee Aun 2023-06-14 16:15:25 +08:00
parent ddbca53a72
commit d2826085e1

View file

@ -1,4 +1,4 @@
import { useEffect, useState } from 'preact/hooks';
import { useLayoutEffect, useState } from 'preact/hooks';
export default function useScroll({
scrollableRef,
@ -17,7 +17,7 @@ export default function useScroll({
const [nearReachEnd, setNearReachEnd] = useState(false);
const isVertical = direction === 'vertical';
useEffect(() => {
useLayoutEffect(() => {
const scrollableElement = scrollableRef.current;
if (!scrollableElement) return {};
let previousScrollStart = isVertical