javascript – Spreading a wayward bug of the browser of the operator

I have a function that adds items to the basket. It works but seems to be capricious. In some cases, only gifts are added to the cart and if I exchange the … gifts and … bottles around while the bottles are added.

Is there a better way to rewrite this.

addToCart (event) {
event.preventDefault ();
const {bottles, gifts} = this.state

const products = {
... bottles
... gifts
}

//

this.addProductsToCart (products)
}

Whereas this is valid.

var obj1 = {foo: "bar", x: 42};
var obj2 = {foo: baz & # 39 ;, y: 13};



var mergedObj = {... obj1, ... obj2};