Skip to content

Commit 61f3cb1

Browse files
authored
fix: prevent infinite re-render loop in row height measurement (#181)
1 parent 5af5d19 commit 61f3cb1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web/src/pages/requests/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function RequestsPage() {
8383
const [scrollTop, setScrollTop] = useState(0);
8484
const [viewportHeight, setViewportHeight] = useState(0);
8585
const [rowHeight, setRowHeight] = useState(DEFAULT_ROW_HEIGHT);
86+
const rowHeightRef = useRef(DEFAULT_ROW_HEIGHT);
8687
const rowMeasureObserver = useRef<ResizeObserver | null>(null);
8788

8889
const handleContainerRef = useCallback((node: HTMLDivElement | null) => {
@@ -248,7 +249,8 @@ export function RequestsPage() {
248249

249250
const updateHeight = () => {
250251
const nextHeight = node.getBoundingClientRect().height;
251-
if (nextHeight > 0 && Math.abs(nextHeight - rowHeight) > 0.5) {
252+
if (nextHeight > 0 && Math.abs(nextHeight - rowHeightRef.current) > 0.5) {
253+
rowHeightRef.current = nextHeight;
252254
setRowHeight(nextHeight);
253255
}
254256
};
@@ -264,7 +266,7 @@ export function RequestsPage() {
264266
observer.observe(node);
265267
rowMeasureObserver.current = observer;
266268
}
267-
}, [rowHeight]);
269+
}, []);
268270

269271
return (
270272
<div className="flex flex-col h-full bg-background">

0 commit comments

Comments
 (0)