I implementing a custom component that he receive how prop one children, the problem is that I need to passing a props to this children prop. How can I do that ?
this is my custom component:
import React from 'react'
import AutoSizer from 'react-virtualized-auto-sizer'
import { FixedSizeList } from 'react-window'
function VirtualizedCarousel({
height,
itemSize,
length,
children,
className,
}) {
return (
<AutoSizer>
{({ _, width }) => (
<FixedSizeList
height={height}
itemCount={length}
itemSize={itemSize}
width={width}
layout="horizontal"
>
{({ index, style }) => (
<div className={className} style={style}>
{children}
</div>
)}
</FixedSizeList>
)}
</AutoSizer>
)
}
export default VirtualizedCarousel
I need to passing 'index' to children prop and using index in my children component.
should be like this :
<VirtualizedCarousel>
<CourseCard
data={data}
index={index}
/>
</VirtualizedCarousel >