We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
flushSync
1 parent 20dd703 commit 106842eCopy full SHA for 106842e
1 file changed
src/hooks/useGridDimensions.ts
@@ -1,5 +1,4 @@
1
import { useLayoutEffect, useRef, useState } from 'react';
2
-import { flushSync } from 'react-dom';
3
4
export function useGridDimensions() {
5
const gridRef = useRef<HTMLDivElement>(null);
@@ -28,12 +27,9 @@ export function useGridDimensions() {
28
27
const size = entries[0].contentBoxSize[0];
29
const { clientHeight, offsetHeight } = gridRef.current!;
30
31
- // we use flushSync here to avoid flashing scrollbars
32
- flushSync(() => {
33
- setInlineSize(size.inlineSize);
34
- setBlockSize(size.blockSize);
35
- setHorizontalScrollbarHeight(offsetHeight - clientHeight);
36
- });
+ setInlineSize(size.inlineSize);
+ setBlockSize(size.blockSize);
+ setHorizontalScrollbarHeight(offsetHeight - clientHeight);
37
});
38
resizeObserver.observe(gridRef.current!);
39
0 commit comments