My Component has a Property defined as array but i cant iterate the values by numeric keys. It seems that the keys are of type string. Am I missing something?
class Test extends React.Component {
render () {
let parse = [];
for (let i in Object.keys(this.props.test)) {
parse.push(
<div key={i}>
{i} {typeof i} {this.props.test[i]}
</div>
)
}
return (
<div>
{parse}
</div>
)
}
}
Test.propTypes = {
test: React.PropTypes.array
}
ReactDOM.render(
<Test test={["a", "b", "c"]} />,
document.getElementById('main')
);
Shows that the keys of Property Test are strings.
{1: 'foo'}, the1will become a stringObject.keyshere: developer.mozilla.org/docs/Web/JavaScript/Reference/…