Closed skelawsky closed 1 year ago
This fixes the problem.
itemData: any
Contextual data to be passed to the item renderer as a data prop. This is a light-weight alternative to React's built-in context API.
Item data is useful for item renderers that are class components.
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>
);
}
}
When data rerender due to data fetch from server inputs inside lose focus. I think this is not desired activity. How to work around it?