fortana-co / react-dropzone-uploader

React file dropzone and uploader
https://react-dropzone-uploader.js.org/
MIT License
447 stars 184 forks source link

Does not render preview and submit button on React StrictMode #200

Open Jason-CKY opened 2 years ago

Jason-CKY commented 2 years ago

As mentioned in the title, it does not render preview and submit button when i run the code on React.StrictMode

scd8418 commented 2 years ago

I am having the same problem.

fernandosmither commented 2 years ago

Same

aliMurtaja commented 2 years ago

after spending a couple of hours. I managed to solve this Issue.

all you need to update your state while uploading is running. the state can be anything.

ex::

const [isUpdatePreview, setIsUpdatePreview] = useState(false)

<Dropzone getUploadParams={getUploadParams} classNames={{ inputLabelWithFiles: defaultClassNames.inputLabel }} onChangeStatus={handleChangeStatus} />

now you need to update your state to tell react it does update the virtual DOM

const handleChangeStatus = ({ meta }, status) => {
    setIsUpdatePreview(!isUpdatePreview)
}

it will fix your Issue

eclipse-cmd commented 1 year ago

well, this works good

nsshah14 commented 1 year ago

Hey @aliMurtaja, Your answer work for me as well. Just one thing, I am not able to remove the dropzone label after uploading files.

raoufslv commented 9 months ago

@aliMurtaja thank you so much, it worked well !