Not sure the title is totally clear (wasn't sure how to phrase it) so let me explain.
I'd like to try and store a list of component names in an array, then loop through using map (or suitable equivalent) in order to display each array value as a JSX component.
So something along the lines of this (appreciate this code doesn't work, just trying to show what I'm hoping to achieve):
render(){
let links = ['DashboardLink', 'CoursesLink', 'AssignmentsLink'];
return (
<div>{
links.map((Link) => {
return <Link key={Link} />
}
}</div>
)
}
Ideally the result would be:
<div>
<DashboardLink key='DashboardLink' />
<CoursesLink key='CoursesLink' />
<AssignmentLink key='AssignmentLink' />
</div>
and each component would then render within the div.
I'm very new to React and ES6 so apologies for any glaring mistakes.
Thanks!
React.createElement