Skip to content

Commit

Permalink
fix: optimize row height calculation in Row component
Browse files Browse the repository at this point in the history
  • Loading branch information
schummar committed Jul 19, 2024
1 parent 119e9bd commit e910dd8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ export const Row = memo(function Row<T>({
};
});

useEffect(() => {
useLayoutEffect(() => {
function update() {
table.update((state) => {
const h1 = document.contains(divRef.current) ? divRef.current?.offsetHeight ?? 0 : 0;
const h2 = document.contains(detailsDivRef.current)
? detailsDivRef.current?.offsetHeight ?? 0
: 0;
if (!divRef.current) {
return;
}

const h1 = divRef.current.offsetHeight;
const h2 =
detailsDivRef.current && document.contains(detailsDivRef.current)
? detailsDivRef.current.offsetHeight
: 0;

state.rowHeights.set(itemId, h1 + h2);
});
Expand Down

0 comments on commit e910dd8

Please sign in to comment.