From 43e1b3df0c38143057a7680170874a5d94dd7fd8 Mon Sep 17 00:00:00 2001 From: Putu Audi Pasuatmadi Date: Tue, 26 Nov 2024 14:41:56 +0800 Subject: [PATCH] fix: remove magic numbers --- src/components/Virtualization/VirtualizedContent.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Virtualization/VirtualizedContent.tsx b/src/components/Virtualization/VirtualizedContent.tsx index bdf8f86f0..ed9a2a965 100644 --- a/src/components/Virtualization/VirtualizedContent.tsx +++ b/src/components/Virtualization/VirtualizedContent.tsx @@ -9,6 +9,8 @@ type VirtualizedContentProps = { menu: MenuStore; }; +const ESTIMATED_EACH_API_HEIGHT_PX = 1000; + /** * VirtualizedContent optimizes the rendering of API documentation in Redoc by virtualizing the content. * @@ -21,7 +23,6 @@ type VirtualizedContentProps = { * by reducing the amount of content loaded into memory at any one time, thereby enhancing * performance and preventing potential crashes due to excessive memory usage. * - * @author Audi */ const VirtualizedContent = ({ store, menu }: VirtualizedContentProps) => { const scrollableRef = React.useRef(null); @@ -34,7 +35,7 @@ const VirtualizedContent = ({ store, menu }: VirtualizedContentProps) => { const virtualizer = useVirtualizer({ count: renderables.length, getScrollElement: () => scrollableRef.current!, - estimateSize: () => 1000, + estimateSize: () => ESTIMATED_EACH_API_HEIGHT_PX, }); const selectedTag = useSelectedTag();