Interface: VirtuosoGridProps<D, C>
Extends
Type Parameters
D
D
C
C = unknown
Properties
atBottomStateChange()?
optionalatBottomStateChange: (atBottom) =>void
Called with true / false when the list has reached the bottom / gets scrolled up.
Can be used to load newer items, like tail -f.
Parameters
atBottom
boolean
Returns
void
atTopStateChange()?
optionalatTopStateChange: (atTop) =>void
Called with true / false when the list has reached the top / gets scrolled down.
Parameters
atTop
boolean
Returns
void
components?
optionalcomponents:GridComponents<C>
Use the components property for advanced customization of the elements rendered by the list.
computeItemKey?
optionalcomputeItemKey:GridComputeItemKey<D,C>
If specified, the component will use the function to generate the key property for each list item.
context?
optionalcontext:C
Additional context available in the custom components and content callbacks
customScrollParent?
optionalcustomScrollParent:HTMLElement
Pass a reference to a scrollable parent element, so that the grid won't wrap in its own.
data?
optionaldata: readonlyD[]
The data items to be rendered. If data is set, the total count will be inferred from the length of the array.
endReached()?
optionalendReached: (index) =>void
Gets called when the user scrolls to the end of the list. Receives the last item index as an argument. Can be used to implement endless scrolling.
Parameters
index
number
Returns
void
increaseViewportBy?
optionalincreaseViewportBy:number| {bottom:number;top:number; }
The property accepts pixel values.
Set the increaseViewportBy property to artificially increase the viewport size, causing items to be rendered before outside of the viewport.
The property causes the component to render more items than the necessary, but can help with slow loading content.
Using { top?: number, bottom?: number } lets you set the increase for each end separately.
initialItemCount?
optionalinitialItemCount:number
Use for server-side rendering - if set, the list will render the specified amount of items regardless of the container / item size.
initialTopMostItemIndex?
optionalinitialTopMostItemIndex:GridIndexLocation
isScrolling()?
optionalisScrolling: (isScrolling) =>void
Called when the list starts/stops scrolling.
Parameters
isScrolling
boolean
Returns
void
itemClassName?
optionalitemClassName:string
Sets the grid items' className
itemContent?
optionalitemContent:GridItemContent<D,C>
Set the callback to specify the contents of the item.
listClassName?
optionallistClassName:string
Sets the className for the list DOM element
logLevel?
optionallogLevel:LogLevel
set to LogLevel.DEBUG to enable various diagnostics in the console, the most useful being the item measurement reports.
Ensure that you have "all levels" enabled in the browser console too see the messages.
overscan?
optionaloverscan:number| {main:number;reverse:number; }
Set the overscan property to make the component "chunk" the rendering of new items on scroll.
The property causes the component to render more items than the necessary, but reduces the re-renders on scroll.
Setting { main: number, reverse: number } lets you extend the grid in both the main and the reverse scrollable directions.
See the increaseViewportBy property for a similar behavior (equivalent to the overscan in react-window).
rangeChanged()?
optionalrangeChanged: (range) =>void
Called with the new set of items each time the list items are rendered due to scrolling.
Parameters
range
Returns
void
readyStateChanged()?
optionalreadyStateChanged: (ready) =>void
invoked with true after the grid has done the initial render and the items have been measured.
Parameters
ready
boolean
Returns
void
restoreStateFrom?
optionalrestoreStateFrom:null|GridStateSnapshot
scrollerRef()?
optionalscrollerRef: (ref) =>any
Provides access to the root DOM element
Parameters
ref
null | HTMLElement
Returns
any
scrollSeekConfiguration?
optionalscrollSeekConfiguration:false|ScrollSeekConfiguration
Use to display placeholders if the user scrolls fast through the list.
Set components.ScrollSeekPlaceholder to change the placeholder content.
startReached()?
optionalstartReached: (index) =>void
Called when the user scrolls to the start of the list.
Parameters
index
number
Returns
void
stateChanged()?
optionalstateChanged: (state) =>void
reports when the grid state changes. The reported value can be stored and passed back to restoreStateFrom to restore the grid to the same state.
Parameters
state
Returns
void
totalCount?
optionaltotalCount:number
The total amount of items to be rendered.
useWindowScroll?
optionaluseWindowScroll:boolean
Uses the document scroller rather than wrapping the grid in its own.
start?
optionalstart:number