I created such a code (and it works locally in Google Chrome but doesn't work on AWS) :
parameters: {
'forces': 100,
'hit': 5,
'defense': 5
}
<Parameters params={this.props.parameters}/>
//In render method:
//console.log(this.props.params); "produces: Object{forces:100, hit:5, defence:5}"
const bars = Object.entries(this.props.params).map(([key,value]) => {
return (
<ProgressBar
key={key}
property={key}
value={Number(value)} />
)
});
return (
<div className="Parameters">
{bars}
</div>
);
Based on this information: How do I loop through or enumerate a JavaScript object how to create the equal code using old-fashion code:
const bars = [];
const obj = this.props.params;
for (const key of Object.keys(obj)) {
//console.log(key, obj[key]);
bars.push()
}
The "bars" array should have 3 Progress Bar Components... I created this project just for my own educational purposes and would like to learn different approaches.
Link to this app: Alex Pilugin: React-Game (it works in Chrome, not in Safari)