Yuvaleros / material-ui-dropzone

A Material-UI file upload dropzone
MIT License
484 stars 247 forks source link

Cannot update unmounted component #261

Open mattcorner opened 4 years ago

mattcorner commented 4 years ago

Bug Report

Describe the bug

When the callback for onChange on the DropzoneArea results in the dropzone being unmounted, React throws the following error:

image

Steps to reproduce

https://codesandbox.io/s/confident-feynman-xvfpn?file=/src/App.js

I've put together a simple sandbox to show the issue. As soon as a file is added, the dropzone is unmounted, but something is still trying to update its state.

Expected behavior

No error for a valid use case.

Versions

Additional context

Use case is that I have a wizard where the user uploads a file. The file is automatically parsed and the user is moved to the next step of the wizard which unmounts the dropzone.

punit-viasimplex commented 3 years ago

Facing the same issue

gaitat commented 3 years ago

My workaround:

const handleChange = (files) =>
  window.setTimeout(() => {
    setShowDropzone(!Boolean(files.length));
  }, 100);
invincibleyolk commented 3 years ago

Same. Just used a component to wrap it, and shows the same bug