Using object spread operator in redux.
Since one of the core principles of Redux is to never mutate state, you’ll often find yourself using
Object.assign() to create copies of objects with new or updated values.
Using Object.assign can quickly make reducers of myApp simple but it is difficult to read.
An alternative approach is to use object spread syntax which lets you spread(…) operator to copy enumerable properties from one object to another object in more brief way.
The object spread operator is conceptually similar to the ES6 array spread operator.
We can simplify our function saveQty with use of spread operator.
Note that this is still an experimental language feature proposal so it may change in the future.
If you liked this, click the ❤️ below so other people will see this here on Medium.