Skip to content
This repository was archived by the owner on Jun 5, 2022. It is now read-only.

Clear Images on Submit #101

Open
MusabAkram opened this issue May 7, 2019 · 6 comments · May be fixed by #191
Open

Clear Images on Submit #101

MusabAkram opened this issue May 7, 2019 · 6 comments · May be fixed by #191

Comments

@MusabAkram
Copy link

I want to remove all the selected images that are being previewed after the images are uploaded successfully.

@andobotar
Copy link

The best solution I found is to pass a new key prop to it, which will get the component reloaded.

@RobertStuff
Copy link

@andobotar Please show some example regarding how to pass props. Thanks

@andobotar
Copy link

andobotar commented Oct 1, 2019

@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
Copy link

@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...

@RobertStuff
Copy link

@andobotar

It works thanks...

@RobertStuff
Copy link

@andobotar
One more thing. Have you encounter when you have a defaultImages. It always shows even if you added a new image?

@khai93 khai93 linked a pull request Sep 30, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants