How do I loop this props?
Tried looping something like this:
for (var key in this.props.data.data) {
this.state.newData.push(
<NewData key={key} />
);
}
doesn't work.
Something like this ought to work:
const newData = this.props.data.data.map(key => (<NewData key={key} />));
this.setState({ newData });
Two notable changes:
Array.prototype.map to iterate over the array rather than a for-in loop.setState to set the state rather than doing so directly. Outside of the constructor, you should always use setState. See https://facebook.github.io/react/docs/state-and-lifecycle.html for more details.