MCPcopy
hub / github.com/bvaughn/react-window / List

Function List

lib/components/list/List.tsx:26–244  ·  view source on GitHub ↗
({
  children,
  className,
  defaultHeight = 0,
  listRef,
  onResize,
  onRowsRendered,
  overscanCount = 3,
  rowComponent: RowComponentProp,
  rowCount,
  rowHeight: rowHeightProp,
  rowProps: rowPropsUnstable,
  tagName = "div" as TagName,
  style,
  ...rest
}: ListProps<RowProps, TagName>)

Source from the content-addressed store, hash-verified

24 * Renders data with many rows.
25 */
26export function List<
27 RowProps extends object,
28 TagName extends TagNames = "div"
29>({
30 children,
31 className,
32 defaultHeight = 0,
33 listRef,
34 onResize,
35 onRowsRendered,
36 overscanCount = 3,
37 rowComponent: RowComponentProp,
38 rowCount,
39 rowHeight: rowHeightProp,
40 rowProps: rowPropsUnstable,
41 tagName = "div" as TagName,
42 style,
43 ...rest
44}: ListProps<RowProps, TagName>): ReactElement {
45 const rowProps = useMemoizedObject(rowPropsUnstable);
46 const RowComponent = useMemo(
47 () => memo(RowComponentProp, arePropsEqual),
48 [RowComponentProp]
49 );
50
51 const [element, setElement] = useState<HTMLDivElement | null>(null);
52
53 const isDynamicRowHeight = isDynamicRowHeightUtil(rowHeightProp);
54
55 const rowHeight = useMemo(() => {
56 if (isDynamicRowHeight) {
57 return (index: number) => {
58 return (
59 rowHeightProp.getRowHeight(index) ??
60 rowHeightProp.getAverageRowHeight()
61 );
62 };
63 }
64
65 return rowHeightProp;
66 }, [isDynamicRowHeight, rowHeightProp]);
67
68 const {
69 getCellBounds,
70 getEstimatedSize,
71 scrollToIndex,
72 startIndexOverscan,
73 startIndexVisible,
74 stopIndexOverscan,
75 stopIndexVisible
76 } = useVirtualizer({
77 containerElement: element,
78 containerStyle: style,
79 defaultContainerSize: defaultHeight,
80 direction: "vertical",
81 itemCount: rowCount,
82 itemProps: rowProps,
83 itemSize: rowHeight,

Callers

nothing calls this directly

Calls 3

useMemoizedObjectFunction · 0.90
useVirtualizerFunction · 0.90
getEstimatedSizeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…