Skip to content

Commit 6176083

Browse files
committed
fix(useLayoutSnapshot): use layout effect for initial value
1 parent 219dd52 commit 6176083

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useContext, useEffect, useState } from 'react';
1+
import { useContext, useEffect, useLayoutEffect, useState } from 'react';
22

33
import { ViewportContext } from './ViewportProvider';
44
import { IViewport, IScroll, IDimensions, PriorityType } from './types';
@@ -90,7 +90,7 @@ export const useLayoutSnapshot = <T = any>(
9090
},
9191
);
9292

93-
useEffect(() => {
93+
useLayoutEffect(() => {
9494
setSnapshot(recalculateLayoutBeforeUpdate(getCurrentViewport()));
9595
}, []);
9696

0 commit comments

Comments
 (0)