React File Input Reset


Topic: React File Input Reset

Dan The Goodman pro asked 6 years ago

Does anyone know of any way to reset the file input?


Aliaksandr Andrasiuk staff answered 6 years ago

Hello,

There is no such functionality for now. We will add it in the near future.

Best regards,

Aliaksandr from MDB.


Roman Mzh pro premium priority answered 5 years ago

bump.

case: reset value after uploading file.

passing empty array to value prop does not help.


Roman Mzh pro premium priority answered 5 years ago

quick solution:

move filechange to useState hook with dependency on props:

+ useEffect(() => { fileChange(props.value) }, [props.value]);

- fileChange(e.target.files); in onChangeHandler function


Piotr Glejzer staff commented 5 years ago

Thanks for this fix. Thank you very much. Have a nice day.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.10.0
  • Device: Any
  • Browser: Electron
  • OS: Any
  • Provided sample code: No
  • Provided link: No