When I log the children component props,
const Row = (props) => {
console.log('-----', props)
return (
<div>#{props.index}</div>
)
}

the data prop in props is undefined, why an undefined value is passed to the children component?
Here is the source code
// ...
createElement(children, {
data: itemData,
key: itemKey(index),
index,
isScrolling: useIsScrolling ? isScrolling : undefined,
style: this._getItemStyle(index),
})
// ...
The itemData is from the props.
props.data will be whatever you pass as itemData to the list (as mentioned in the docs) 馃槃
class ComponentThatRendersAListOfItems extends PureComponent {
render() {
// Pass items array to the item renderer component as itemData:
return (
<FixedSizeList
itemData={this.props.itemsArray}
{...otherListProps}
>
{ItemRenderer}
</FixedSizeList>
);
}
}
// The item renderer is declared outside of the list-rendering component.
// So it has no way to directly access the items array.
class ItemRenderer extends PureComponent {
render() {
// Access the items array using the "data" prop:
const item = this.props.data[this.props.index];
return (
<div style={this.props.style}>
{item.name}
</div>
);
}
}
Thanks
Most helpful comment
props.datawill be whatever you pass asitemDatato the list (as mentioned in the docs) 馃槃