petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.16k stars 299 forks source link

[BUG] TableVirtuoso: Only 1 row is rendered when the `components` prop has `TableRow: props => props.children` #1012

Closed akhilpanchal closed 9 months ago

akhilpanchal commented 9 months ago

Thank you so much for your efforts on this really amazing library.

Describe the bug When attempting to use the TableVirtuoso component along with components prop for customizing the markup, I am noticing only a single row being rendered. I am passing { TableRow: props => props.children } as part of the components prop, since I am rendering the <tr /> as part of the itemContent prop so that my markup is semantically correct. (More details in the Additional Context section).

Reproduction Reproduction CSB Link: https://codesandbox.io/p/sandbox/charming-leftpad-yvwzmj?file=%2FApp.js%3A43%2C23 I took the material UI example on the website and just updated the value for the components prop, and wrapped the itemContentprop with instead of a React Fragment.

To Reproduce Steps to reproduce the behavior:

  1. Open the CSB Link
  2. Notice that only a single row is rendered when the data contains more row data objects.

Expected behavior Should render all the rows passed as data prop.

Screenshots image

Desktop (please complete the following information):

Additional context I am attempting to bring virtualization capabilities to my Table component. I am using the context prop to do some state management. The reason I need the components.TableRow to just be a passthrough, is because I want the users of the Table component to pass props to Table.Row - via the itemContent prop - as seen on the Sandbox.

I'll be more than happy to contribute a fix for this, with your help, once you confirm if this is actually a bug.

Thank you once again for your time 😊.

petyosi commented 9 months ago

No, that's not a bug. The table row component and the props passed are necessary for the correct component operation, you can't skip it.