I have the following:
constructor() {
super();
this.state = {
lists: [],
items: {}
};
}
So this.state.items
is an object.
Now I have:
handleAddItem(s) {
var key = Object.keys(s)[0];
var value = s[key];
var allItems = {...this.state.items};
allItems[key].push({name: value});
console.log(allItems);
console.log(this.state.items);
}
this.state.items is initially null just {} and s is an object with a key value pair of name: snoopy
var s={};
s[this.props.idName] = this.refs.id.value;
Why in the console.log
are both the same?