'Disable form submit while file is loading FilePond

I am using FilePond for image file in my form. I want form submit to be disabled while image/file is loading. and reenabled once image is loaded.

I searched their docs but couldn't find what might help

This when Submit button should be disabled

enter image description here



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohit Kushwaha