useLayoutEffect instead

pull/165/head^2
Lim Chee Aun 2023-06-14 16:15:25 +08:00
rodzic ddbca53a72
commit d2826085e1
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -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