-
Notifications
You must be signed in to change notification settings - Fork 0
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
How would you manage existing files? #2
Comments
Good point, I should add a way to provide some default values. Will be on this, thanks for the feedback! |
Hey, const [fileStatuses, dispatch] = useReducer(fileStatusReducer, [], () => {
if (props.defaultFiles?.length && props.defaultFiles.length > 0) {
return props.defaultFiles.map((defaultFile) => {
const id = crypto.randomUUID()
return {
id,
fileName: defaultFile.name,
file: defaultFile,
status: 'success',
result: URL.createObjectURL(defaultFile) as TUploadRes,
tries: 1
} satisfies FileStatus<TUploadRes, TUploadError>
})
}
return []
}) also add the type to defaultFiles?: File[] |
is there any way to set default files that fetched from API? |
I didn't test it but this should work: const buf = Buffer.from('Hello World!') // buffer returned by the api
const blob = new Blob([buf])
const defaultFile = new File([blob], "filename") |
how pass it to useDropzone hook? defaultFiles is difined in useDropzone.
when mobx store change state and fetch data from API, defaultFiles is not detect changes. |
Maybe try to wrap But i've never used mobx so i can't really help you with that. |
any asynchronous opration to set defaultFiles in useDropzone would be fine. |
i fixed it, now i can get data from mobx API calls, i edited
and this is my code:
and this:
|
Hi there, I'm testing the component and it works really well. I was wondering, how would you manage existing files? Let's say you have a grid of images that you display and you also have the dropzone to add more images.
The text was updated successfully, but these errors were encountered: