I Used the following code to append my json structured values to a state variable:
var value = JSON.stringify({"id":event.target.name,"amount":event.target.value})
this.setState({temp:[...this.state.temp, value]},function () {
console.log(this.state.temp);
});
And i got the result as:
["{"id":"1","amount":"10"}","{"id":"2","amount":"20"}"]
How can i get it restructured as following:
[{"id":"1","amount":"10"},{"id":"2","amount":"20"}]
Update: When i removed JSON.stringify like this
var value = {"id":event.target.name,"amount":event.target.value} i got null array as result
JSON.stringify(...)