title: React Redux update item quantity (more than just one increment)
body: <p>I have a site where the user can increase the quantity on the product before adding it to cart. Now if the user decided to go back to the product and add 3 more by increasing the quantity on the product, then adding to cart - how do I update the quantity of the existing product in basket?</p>
  <p>At the moment I get duplicates of the product with different quantities depending on what is selected.</p>
  <p>Here is the code I have for my reducer:</p>
  <pre><code>import { createSlice } from &quot;@reduxjs/toolkit&quot;;
  
  const initialState = {
    items: [],
  };
  
  const basket = createSlice({
    name: &quot;basket&quot;,
    initialState,
    reducers: {
      addToBasket: (state, { payload }) =&gt; {
          // No idea what to do with this..
        state.items.filter((pizza) =&gt; pizza.name === payload.name);
  
        // This pushes the item fine, but I get multiple of the same item in the cart instead of just updating its quantity
        state.items.push(payload);
  
  
  
        //   state.items.map((pizza) =&gt;
        //     pizza.name === payload.name
        //       ? {
        //           ...pizza,
        //           quantity: pizza.quantity + payload.quantity,
        //         }
        //       : pizza
        //   );
  
  
      },
    },
  });
  
  export const { addToBasket } = basket.actions;
  export const basketItems = (state) =&gt; state.basket.items;
  
  export default basket.reducer;
  </code></pre>
  <p>The payload is the specific product, it will be an object:</p>
  <pre><code>{
   name: &quot;product name&quot;,
   image: &quot;url.jpeg&quot;,
   price: &quot;14.99&quot;
  }
  </code></pre>
  <p>I can not for the life of me figure out what to do here in order not to mutate the state. Nothing works, I feel like I have tried every possible way but clearly I am missing something.</p>
  <p>Any help much appreciated!!!</p>
  <p>Thanks</p>