aherriot
aherriot

Reputation: 4725

React virtualized table custom rowRenderer state

I am trying to create custom rows on a table with their own state. Unfortunately, the rowRenderer property on the Table component must be Proptypes.func and not a full react component where I have access to lifecycle methods and state. Is there a reason for this, or is there an alternative method for me to be able to have a stateful component for each row?

See https://github.com/bvaughn/react-virtualized/blob/master/source/Table/Table.js#L167

I should also mention that I understand that these row components may be unmounted when they scroll off the screen. I am ok with that, as long as I can have state for it when it is in the viewport.

Upvotes: 1

Views: 3623

Answers (1)

bvaughn
bvaughn

Reputation: 13487

You can return a class component (with lifecycle hooks) from a function prop like rowRenderer. eg

function rowRenderer(props) {
  return <RowComponent {...props} />
}

Upvotes: 3

Related Questions