Skip to content

Commit

Permalink
fix: remove magic numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
audipasuatmadi committed Nov 26, 2024
1 parent 8942245 commit 43e1b3d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/Virtualization/VirtualizedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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<HTMLDivElement>(null);
Expand All @@ -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();
Expand Down

0 comments on commit 43e1b3d

Please sign in to comment.