I have an input to download an image with react, I would like to be able to cancel what has been downloaded if I change my mind for example. So how to return the input to its initial state, i.e. empty? thank you for help.
const [ imageUrl, setImageUrl ] = useState(null);
const uploadImage = (e) =>{
const file = e.target.files[0];
setImageUrl(file)
}
const cancelImage = (e) =>{
e.preventDefault();
setImageUrl(null)
}
<label htmlFor="Image du produit">
Image du produit:
<input id="uploadImage" type="file" onChange={uploadImage}/>
<button onClick={cancelImage}>X</button>
</label>