From 62b0ea66162eb23b53251e84bb407ab1abdef972 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Thu, 23 Oct 2025 18:15:45 -0700 Subject: [PATCH] memoize and reset scrollEnd handler on grid list --- .../item-list/item-grid-list/item-grid-list.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/item-list/item-grid-list/item-grid-list.tsx b/src/renderer/components/item-list/item-grid-list/item-grid-list.tsx index 3a7d39397..b4f78547a 100644 --- a/src/renderer/components/item-list/item-grid-list/item-grid-list.tsx +++ b/src/renderer/components/item-list/item-grid-list/item-grid-list.tsx @@ -265,7 +265,16 @@ export const ItemGridList = ({ [onScrollEnd], ); - const debouncedOnScrollEnd = debounce(handleOnScrollEnd, 150); + const debouncedOnScrollEnd = useMemo( + () => debounce(handleOnScrollEnd, 150), + [handleOnScrollEnd], + ); + + useEffect(() => { + return () => { + debouncedOnScrollEnd.cancel(); + }; + }, [debouncedOnScrollEnd]); const handleScroll = useCallback( (e: UIEvent) => {