-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove file from widget after upload. #254
Comments
Hey @stevesizer const [value, setValue] = useState();
const onChange = (fileInfo) => {
setValue(null);
};
<Widget
value={value}
publicKey="demopublickey"
onChange={onChange}
/> |
I can't make this work:
|
you need to use separate state for you value of the widget to make it work. |
@stevesizer thanks for you quick response.
|
It might be best to have some state for the image.
|
@nd0ut Not sure if you'd prefer to resurrect an old question or open a new one, but I'm working on the same use case and notice that the example you provided (https://codesandbox.io/s/laughing-golick-f95t2?file=/src/App.js:0-523) only works once. The first upload is cleared, but after a second file is uploaded, the state persists. This matches the behavior I'm seeing with my own project. How can we guarantee that the |
Apologies for the unnecessary update to an old question - the issue was with |
@barbalex I struggled with that for a while as well. I think it's because the Widget itself wants to "own" the list of files inside it, whereas it would be very useful to have a more React-y component that allowed us to control it from top to bottom. |
Hey guys, I agree that the Therefore, I want to rename the |
I was able to clear the selected file more than once by randomizing the const [key, setKey] = useState(0);
function onChange() {
setKey(Math.random());
}
<Widget key={key} onChange={onChange} /> |
I'm using the widget api to open the dialog and then on file change creating my object to save to the database. After I have uploaded the image I am trying to remove it from widget using the getInput function.
This is not removing the image. So when I go to reopen the widget the last image uploaded is in preview mode. ANy help would be appreciated. Here is my code below.
const fileChange = (fileInfo) => {
let newAttachment = {
name: fileInfo.name,
file_type: fileInfo.mimeType,
size: fileInfo.size,
attachment_url: fileInfo.cdnUrl,
};
};
The text was updated successfully, but these errors were encountered: