Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/VirtualizedPropertyGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { memo, useMemo, useRef, useEffect, useState } from 'react';
import { useVirtualizer } from '@tanstack/react-virtual';
import { PropertyCard } from './PropertyCard';
import { ErrorBoundary } from './ui/SimpleErrorBoundary';
import { PropertyEmptyState } from './ui/EmptyState';
import type { Property } from '@/types/property';

interface VirtualizedPropertyGridProps {
Expand Down Expand Up @@ -49,16 +50,20 @@ const VirtualizedPropertyGridInner: React.FC<VirtualizedPropertyGridProps> = ({
// its inputs change instead of on every render of the grid.
const virtualizerOptions = useMemo(
() => ({
count: rowCount,
count: rows.length,
getScrollElement: () => parentRef.current,
estimateSize: () => (viewMode === 'grid' ? 450 : 200),
overscan: 5,
}),
[rowCount, viewMode]
[rows.length, viewMode]
);

const rowVirtualizer = useVirtualizer(virtualizerOptions);

if (properties.length === 0) {
return <PropertyEmptyState className={className} />;
}

return (
<div
ref={parentRef}
Expand Down
Loading