Reference home > @af-utils/virtual-react > createGridItemRef

createGridItemRef() function

Creates callback ref for grid item at specified index.

Signature:

createGridItemRef: (rowsModel: VirtualScroller, rowItemIndex: number, colsModel: VirtualScroller, colItemIndex: number) => (el: HTMLElement | null) => void

Parameters

Parameter

Type

Description

rowsModel

VirtualScroller

rowItemIndex

number

row item index

colsModel

VirtualScroller

colItemIndex

number

column item index

Returns

(el: HTMLElement | null) => void

callback ref

Remarks

Calls VirtualScroller.attachItem() when item is mounted and VirtualScroller.detachItem() when item is about to unmount.

createListItemRef() differences:

  • works with two models at the same time;

  • column widths are taken only from first mounted row;

  • row heights are taken only from first mounted column.