From c91647198dc9c0df27e4cadd1b52b9a5ce5eed99 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 23 Jan 2025 12:57:37 -0700 Subject: [PATCH] memoize impertative function --- .../components/layout/AppSplitter/AppSplitter.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/src/components/layout/AppSplitter/AppSplitter.tsx b/web/src/components/layout/AppSplitter/AppSplitter.tsx index 208f79359..6cd856e09 100644 --- a/web/src/components/layout/AppSplitter/AppSplitter.tsx +++ b/web/src/components/layout/AppSplitter/AppSplitter.tsx @@ -178,11 +178,15 @@ export const AppSplitter = forwardRef< } ); + const imperativeHandleMethods = useMemo(() => { + return () => ({ + setSplitSizes, + animateWidth + }); + }, [setSplitSizes, animateWidth]); + // Add useImperativeHandle to expose the function - useImperativeHandle(ref, () => ({ - setSplitSizes, - animateWidth - })); + useImperativeHandle(ref, imperativeHandleMethods); return (