Why is my Jotai setter function not cumulatively building my array here?

Viewed 24

const BulkEditProductImagesModal = () => {
  const [uploadedImages, setUploadedImages] = useAtom(atoms.productImages.bulk.uploaded)
  
  const handleUpload = (filename, base64) => {
    const payload = { sku: 'testItem01', base64 }
    const results = uploadProductImages([payload])
    setUploadedImages([...uploadedImages, payload])
  }
 
  // ....
}

Why would my uploadedImages variable not cumulatively build my array here as expected? I always end up with 1 entry in the array no matter how many times handleUpload() is called.

0 Answers
Related