I have an array as such:
export const options = [
{id: 1, name='ComponentOne'},
{id: 2, name='ComponentTwo'},
]
Then I have my components:
export const ComponentOne = props => (<div>{this.props.content}</div>)
export const ComponentTwo = props => (<div>{this.props.content}</div>)
Then I have my view:
export class MyView extends React.Component{
constructor(props){
super(props);
this.state = {};
}
render(){
return(
<div>
{options.map( obj => <obj.name/> )
</div>
)
}
}
I would like to dynamically render these components but have no idea how to.
options?{id: 1, name=ComponentOne}. Should it work?