MCPcopy Index your code
hub / github.com/TanStack/virtual / RowVirtualizerFixed

Function RowVirtualizerFixed

examples/react/fixed/src/main.tsx:42–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42function RowVirtualizerFixed() {
43 const parentRef = React.useRef(null)
44
45 const rowVirtualizer = useVirtualizer({
46 count: 10000,
47 getScrollElement: () => parentRef.current,
48 estimateSize: () => 35,
49 overscan: 5,
50 })
51
52 return (
53 <>
54 <div
55 ref={parentRef}
56 className="List"
57 style={{
58 height: `200px`,
59 width: `400px`,
60 overflow: 'auto',
61 }}
62 >
63 <div
64 style={{
65 height: `${rowVirtualizer.getTotalSize()}px`,
66 width: '100%',
67 position: 'relative',
68 }}
69 >
70 {rowVirtualizer.getVirtualItems().map((virtualRow) => (
71 <div
72 key={virtualRow.index}
73 className={virtualRow.index % 2 ? 'ListItemOdd' : 'ListItemEven'}
74 style={{
75 position: 'absolute',
76 top: 0,
77 left: 0,
78 width: '100%',
79 height: `${virtualRow.size}px`,
80 transform: `translateY(${virtualRow.start}px)`,
81 }}
82 >
83 Row {virtualRow.index}
84 </div>
85 ))}
86 </div>
87 </div>
88 </>
89 )
90}
91
92function ColumnVirtualizerFixed() {
93 const parentRef = React.useRef(null)

Callers

nothing calls this directly

Calls 1

useVirtualizerFunction · 0.90

Tested by

no test coverage detected