Search code examples
reactjsprimereact

primereact file upload uploadHandler change status of uplaod


I'm using Primereact's file upload component with customUpload prop and Uploadhandler callback. I want to change the status of the uploaded file when my uploadHandler function finishes executing.

<FileUpload className={`w-full`} name="demo[]" customUpload={true} uploadHandler={async (e) =>{
} }.... /> 

enter image description here


Solution

  • Yes but you must be using PrimeReact 9.6.0 which was released today. just make sure you get a ref to your FileUpload.

    <FileUpload ref={ref} ...
    

    Then with that ref you can update the list of uploaded files like..

    const yourFiles = []; // array of your already uloaded files
    ref.current.setUploadedFiles(yourFiles);