From 6f497207c09708b6ccd07d2a302dbe4ef5b59f2f Mon Sep 17 00:00:00 2001 From: R-J Lim Date: Mon, 8 Jan 2024 11:16:54 +0900 Subject: [PATCH] Fix useResize causing excessive re-rendering --- common/app/hooks/use-resize.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/app/hooks/use-resize.ts b/common/app/hooks/use-resize.ts index 52abab74..18b3a923 100644 --- a/common/app/hooks/use-resize.ts +++ b/common/app/hooks/use-resize.ts @@ -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]);