Skip to content

Commit

Permalink
Fix useResize causing excessive re-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Jan 8, 2024
1 parent 110ded4 commit 6f49720
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/app/hooks/use-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export const useResize = ({ initialWidth, minWidth, maxWidth, onResizeStart, onR
);

useEffect(() => {
// Prioritize minWidth even if it's larger than maxWidth
if (minWidth !== 0 && width < minWidth) {
setWidth(minWidth);
} else if (maxWidth !== 0 && width > maxWidth) {
} else if (maxWidth !== 0 && width > Math.max(minWidth, maxWidth)) {
setWidth(maxWidth);
}
}, [maxWidth, minWidth, width]);
Expand Down

0 comments on commit 6f49720

Please sign in to comment.