Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

51
Vistas
How to remove react-dropzone array Base64 event

This is my code uploader

const MyUploader = ({ imageData }) => {
  // specify upload params and url for your files
  const getUploadParams = ({ meta, file }) => {
    return { url: "https://httpbin.org/post" };
  };

  const handleChangeStatus = ({ meta, file }, status) => {
    // console.log(meta.previewUrl);
    const reader = new FileReader();
    reader.onabort = () => console.log('file reading was aborted')
    reader.onload = (event) => {
      // console.log(event.target.result);
      if (status === "done") {
        imageData(event.target.result);
      }
    };
    reader.readAsDataURL(file);
  };

  // receives array of files that are done uploading when submit button is clicked
  const handleSubmit = (files, allFiles) => {
    allFiles.forEach((f) => f.remove());
  };

  return (
    <Dropzone
      getUploadParams={getUploadParams}
      onChangeStatus={handleChangeStatus}
      onSubmit={handleSubmit}
      onDelete={(file) => console.log(file, "Helo")}
      accept="image/*"
    />
  );
};

    <MyUploader
                    imageData={(data) =>
                      setFormData({
                        ...formData,
                        images: [...formData.images, data],
                      })
                    }
                  />

But when I insert file is fine, but when I remove my preview the array won't remove , like image below:

enter image description here

How to remove that?

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos