petyosi / react-virtuoso

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

List only Render the First Item when using List and Item components #702

Closed nassif7 closed 2 years ago

nassif7 commented 2 years ago

Hello There, I just started using this very nice library. thank you!

I have a problem when using the components prop, when I am adding my List and Item, the list only render the first Item.

here is my components

import React from 'react'
import { Components } from 'react-virtuoso'

export const List: Components['List'] = React.forwardRef((props, ref) => {
  return <div className='list-group' {...props} ref={ref} />
})
export const Item: Components['Item'] = ({ children }) => {
  return <div className='list-group-item list-group-item-action'>{children}</div>
}

and here how i am using the Virtuoso component

 <>
      <Virtuoso
        style={{ height: '100%' }}
        data={items}
        itemContent={(index, item) => {
          return <>{item.label}</>
        }}
        components={{ List, Item }}
      />
 </>

any help would be greatly appreciated

nassif7 commented 2 years ago

ok it seems I was missing the props on the Item component.

closed