Skip to content

Commit

Permalink
Fix terrible initial performance of table virtualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Mar 28, 2024
1 parent d4a10c6 commit bb359ea
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/components/tables/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,10 @@ function useSelectHandler<TData>(

function useTableVirtualizer(count: number): [React.MutableRefObject<HTMLElement | null>, number, Virtualizer<HTMLElement, Element>] {
const parentRef = useRef<HTMLElement | null>(null);
const [rowHeight, setRowHeight] = useState(0);

const { value: fontSize } = useFontSize();

useEffect(() => {
const lineHeight = getComputedStyle(document.body).lineHeight.match(/[\d.]+/)?.[0];
setRowHeight(Math.ceil(Number(lineHeight) * 1.05));
}, [fontSize]);
const rowHeight = Math.ceil(16 * fontSize * 1.6);

const rowVirtualizer = useVirtualizer({
count,
Expand Down

0 comments on commit bb359ea

Please sign in to comment.