viclafouch / mui-file-input

A file input designed for the React library MUI
https://viclafouch.github.io/mui-file-input/
MIT License
77 stars 17 forks source link

Event Listener for Clear #10

Closed chicagocomputerclasses closed 1 year ago

chicagocomputerclasses commented 1 year ago

How can we assign an event when the little (x) clear button is pressed to clear the file input?

I suppose we can just useEffect and react when file input changes, but it would be nice to have a cleaner way like <MuiFileInput onClear={ () => {} } />

viclafouch commented 1 year ago

Hello @chicagocomputerclasses !

What about this ?

  const handleChange = (newValue: File[]) => {
    if (newValue.length === 0) {
      // clear ?
    }
  }