score:0

Accepted answer
useEffect(() => {
  const newData = {
    ...data,
    libraries: data.libraries.map(library => {
      if (library.id !== libraryId) {
        return library;
      }
      return {
        ...library,
        products: library.products.map(p => {
          if (p.id !== product.id) {
            return p;
          }
          return {
            ...p,
            quantity: parseInt(selectedItemQuantity)
          }
        });
      }
    })
  }
  setData(newData);
  setItemPrice((product.unitPrice*selectedItemQuantity).toFixed(2));
}, [selectedItemQuantity]);

Related Query

More Query from same tag