i have an array of objects and i want to print the content of each element inside this each object, i have tried the method provided in this(Render Object properties in React) and what i got is just a list of the elements without its values
state={
machines: [{
MachineName: 'A1',
region: 'west',
zones:'west-01',
ipAddr:'1.1.1.1',
subnet:'test'},
{
MachineName: 'A2',
region: 'west',
zones:'west-01',
ipAddr:'1.1.1.2',
subnet:'test2'
}]
}
render() {
const machinespc=this.state.machines.map((value,key)=>{
return (
<div>
<div className="col-md-4" key={key}>
<div className="dashboard-info">
{Object.keys(value).map((val, k) => {
return (<h4 k={k}>{val}</h4>)
})
}
</div>
</div>
</div>
)
})
return (
{machinespc}
)
and the out put was like below,
MachineName
region
zones
ipAddr
subnet
so what i want is to print the values of each element inside the object like below:
A1
west
west-01
1.1.1.1
test'}
return (<h4 k={val}>{value[val]}</h4>). Maybe naming your variables with meaningful names would have helped.