I have an array of components
[
{
componentName: 'FieldHeader',
props: {title:'bla bla},
showOnDate: '01/01/2019'
},
{
componentName: 'RadioButton',
props: {},
showOnDate: '01/01/2018'
}
]
And I am trying to dynamically create elements from this array.
I have an array that has all the components in it.
I am figuring something like:
for (var i=0; i < objects.length; i++) {
<components[objects[i].componentName] {...props}>
}
but doing something like:
<components['FieldHeader'] {...props}>
throws a compile error.
Is there a way to dynamically render react elements like this?