Idea is to create an Component with a child which could be any component, so i need to assign the props to this Component.
I try to do it in a loop, because i don't know how many props there should be
//Array of objects which i wanna render
{array?.[i] && (
<Component
{...Object.keys(component.props)?.map(prop => ({
[prop]: array?.[i]?.[prop]
}))}
/>
)}
but as result in inspector i got something like..
props
0:{prop1: "prop1"}
1:{prop2: "prop2"}
2:{prop3: "prop3"}
But i wan't to look it like this
prop1: "prop1",
prop2: "prop2"
prop3: "prop3"
burned out a bit
all i tried to do is like
<Component
{...Object.keys(component.props)?.reduce((acc: { [key: string]: any }, curr) => {
acc[curr] = array?.[i]?.[curr]
return acc
}, {})}
/>