const { items } = this.state;
this.setState({
items: this.state.items.slice(0, this.state.items.length - 1)
});
I know the code above can work well in react
However,
const { items } = this.state;
items.pop();
this.setState({ items });
I just don't know why this can still update the dom if there is a list rendered by the this.state.items (like <div className="list">{this.state.items}</div>).
I am confused that the items.pop() have changed the origin state, isn't the next state's items equal the origin state's items.Why this can still update the dom .