I'm building a new project with React. I have a component that defines several child components like this:
class TimeStepDisplayGraph extends React.Component {
render () {
return <div id={ this.props.id }>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
<TimeStepDisplayGraphNode class="graphNodeStyles"/>
</div>;
}
}
Now ideally what I would like to do is not have the number of nodes created defined explicitly, but rather through a call like:
function createGraphNode() {
return React.createElement( <TimeStepDisplayGraphNode class="graphNodeStyles"/>);
}
That I call x number of times. It seems like something really simple to do, and I'm sure I'll be kicking myself later for being so stupid, but at the moment I'm really at a loss for how to do this. Any help would be appreciated.