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

Function Grid

lib/components/grid/Grid.tsx:26–321  ·  view source on GitHub ↗
({
  cellComponent: CellComponentProp,
  cellProps: cellPropsUnstable,
  children,
  className,
  columnCount,
  columnWidth,
  defaultHeight = 0,
  defaultWidth = 0,
  dir,
  gridRef,
  onCellsRendered,
  onResize,
  overscanCount = 3,
  rowCount,
  rowHeight,
  style,
  tagName = "div" as TagName,
  ...rest
}: GridProps<CellProps, TagName>)

Source from the content-addressed store, hash-verified

24 * Either static sizes or something that can be derived (from the data in `CellProps`) without rendering.
25 */
26export function Grid<
27 CellProps extends object,
28 TagName extends TagNames = "div"
29>({
30 cellComponent: CellComponentProp,
31 cellProps: cellPropsUnstable,
32 children,
33 className,
34 columnCount,
35 columnWidth,
36 defaultHeight = 0,
37 defaultWidth = 0,
38 dir,
39 gridRef,
40 onCellsRendered,
41 onResize,
42 overscanCount = 3,
43 rowCount,
44 rowHeight,
45 style,
46 tagName = "div" as TagName,
47 ...rest
48}: GridProps<CellProps, TagName>): ReactElement {
49 const cellProps = useMemoizedObject(cellPropsUnstable);
50 const CellComponent = useMemo(
51 () => memo(CellComponentProp, arePropsEqual),
52 [CellComponentProp]
53 );
54
55 const [element, setElement] = useState<HTMLDivElement | null>(null);
56
57 const isRtl = useIsRtl(element, dir);
58
59 const {
60 getCellBounds: getColumnBounds,
61 getEstimatedSize: getEstimatedWidth,
62 startIndexOverscan: columnStartIndexOverscan,
63 startIndexVisible: columnStartIndexVisible,
64 scrollToIndex: scrollToColumnIndex,
65 stopIndexOverscan: columnStopIndexOverscan,
66 stopIndexVisible: columnStopIndexVisible
67 } = useVirtualizer({
68 containerElement: element,
69 containerStyle: style,
70 defaultContainerSize: defaultWidth,
71 direction: "horizontal",
72 isRtl,
73 itemCount: columnCount,
74 itemProps: cellProps,
75 itemSize: columnWidth,
76 onResize,
77 overscanCount
78 });
79
80 const {
81 getCellBounds: getRowBounds,
82 getEstimatedSize: getEstimatedHeight,
83 startIndexOverscan: rowStartIndexOverscan,

Callers

nothing calls this directly

Calls 3

useMemoizedObjectFunction · 0.90
useIsRtlFunction · 0.90
useVirtualizerFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…