Skip to content

Commit 106842e

Browse files
committed
is flushSync needed
1 parent 20dd703 commit 106842e

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/hooks/useGridDimensions.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useLayoutEffect, useRef, useState } from 'react';
2-
import { flushSync } from 'react-dom';
32

43
export function useGridDimensions() {
54
const gridRef = useRef<HTMLDivElement>(null);
@@ -28,12 +27,9 @@ export function useGridDimensions() {
2827
const size = entries[0].contentBoxSize[0];
2928
const { clientHeight, offsetHeight } = gridRef.current!;
3029

31-
// we use flushSync here to avoid flashing scrollbars
32-
flushSync(() => {
33-
setInlineSize(size.inlineSize);
34-
setBlockSize(size.blockSize);
35-
setHorizontalScrollbarHeight(offsetHeight - clientHeight);
36-
});
30+
setInlineSize(size.inlineSize);
31+
setBlockSize(size.blockSize);
32+
setHorizontalScrollbarHeight(offsetHeight - clientHeight);
3733
});
3834
resizeObserver.observe(gridRef.current!);
3935

0 commit comments

Comments
 (0)