Home > Enterprise >  Disable form submit while file is loading FilePond
Disable form submit while file is loading FilePond

Time:03-17

I am using enter image description here

CodePudding user response:

By using these callbacks, you can disable the submit button while the files load.

onaddfilestart(file) – Started file load

onaddfileprogress(file, progress) Made progress loading a file

onaddfile(error, file) If no error, file has been successfully loaded.

function App() {
  const [files, setFiles] = useState([]);
  const [loading,setLoading] = useState(false);

  return (
    <div className="App">
      <FilePond
        files={files}
        allowReorder={true}
        allowMultiple={true}
        onupdatefiles={setFiles}
        onaddfilestart={()=> setLoading(true)}
        onaddfile={()=> setLoading(false)}
      />
      <button disabled={loading}>Submit</button>
    </div>
  );
}

reference - https://pqina.nl/filepond/docs/api/instance/properties/#callbacks

  • Related