Clear Images on Submit
I want to remove all the selected images that are being previewed after the images are uploaded successfully.
The best solution I found is to pass a new key prop to it, which will get the component reloaded.
@andobotar Please show some example regarding how to pass props. Thanks
@RobertStuff
I use this in a bigger form component, where I keep a number in state for the 'key':
const [ImageUploaderKey, setImageUploaderKey] = useState(0);
And when the form is submitted successfully, I increment this number:
setImageUploaderKey(ImageUploaderKey + 1);
Then I pass this key to the component:
<ImageUploader key={ImageUploaderKey} ... />
Hope this helps.
@RobertStuff
I use this in a bigger form component, where I keep a number in state for the 'key':
const [ImageUploaderKey, setImageUploaderKey] = useState(0);And when the form is submitted successfully, I increment this number:setImageUploaderKey(ImageUploaderKey + 1);Then I pass this key to the component:<ImageUploader key={ImageUploaderKey} ... />Hope this helps.
thank I will try it later...
@andobotar
It works thanks...
@andobotar One more thing. Have you encounter when you have a defaultImages. It always shows even if you added a new image?