I wanted to make the value of imageUrl to be null if the remove button is click using uploadcare/react-widget. Right now, it doesn't set the value to null, it still returns the value of the original imageUrl. How do you call the function when you click the 'remove button'?
<Widget
tabs="file"
name="imageUrl"
clearable="true"
imagesOnly="true"
previewStep="true"
value={props.values.imageUrl}
onChange={upload =>
props.setFieldValue('imageUrl', upload.originalUrl)
}
publicKey={process.env.UPLOADCARE_KEY}
/>
The
onChangecallback fires only when a file is uploaded. If you need to handle this case, consider usingonFileSelectinstead. For example,Make sure to update
react-widgetto the latest version (1.3.7) to be able to use this method.Basically,
onFileSelectis a binding to theonChangemethod of the vanilla JS API of the widget.