I'm quite new to React and I'm trying to build the classic to do list! However, I'm struggling to track the array items.
I'm creating the items as follows:
this.setState({item: {
text: event.target.value,
index: this.state.items.length++,
completed:false
}
And I've been adding to the array of items like this:
this.setState({items:this.state.items.concat(this.state.item)});
But this method creates a new array every time, so I can't use the index of the item. However when I try using push to add to the array, I can't seem to display it! Any help would be much appreciated!
push? OR - could you place an id on each item so you don't need positional indexes?