I'm trying to chain a React Components to Object by passing my imported Components to them as Props.
const [showComponent, setShowComponent] = useState([
{ cId: 1, componentName: <ContactDialogAddresses />, title: 'Adresse', render: true },
{ cId: 2, componentName: <ContactDialogPhone />, title: 'Rufnummer', render: true },
]);
return(
{showComponent.map((component, index) => {
if (component.render) {
return (
<>
<span>{index}</span>
{component.componentName}
</>
);
}
})}
)
How can I reimplement props like this?
// I need to pass the props during the mapping because I need a unique identifier for each rendert component later on.
<ContactDialogAddresses
key={component.cId}
onShowComponent={handleShowComponent}
cIndex={index}
/>