I have data that push to a state named value. and i want to display them based on number of array. i'm trying to make initiate but not work.
constructor(props) {
super(props)
this.state = {
json: [],
search: '',
value: [],
jumlah : "",
nama_barang : "Bolu kuwuk",
harga : 10000
}
}
i push jumlah, nama_barang and harga into value [] like this
handleSubmit(e){
e.preventDefault();
alert("Data Telah diinputkan!");
this.state.value.push(
this.state.jumlah,
this.state.nama_barang,
this.state.harga
)
this.setState(
this.state
)
console.log(this.state.value)
}
and display them like this
{this.state.value.map((v, i) => {
return <div key={i}>
<h1>{v.jumlah}</h1>
<h1>{v.nama_barang}</h1>
<h1>{v.harga}</h1>
</div>
})}
it works when i write {v} but it print whole array. i just want display it by number of array