-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Typescript incompatibility with onupdatefiles and files props #245
Comments
As a workaround I am coercing typescript into thinking the types are correct. though this works for now, idk if there are going to be unforeseen problems later with this:
|
@anthonysgro Hey, I'm unfortunately not proficient enough in TypeScript to solve this based on the descriptions above. I guess coercing will work for now and I don't see that causing any issues. |
I ran into this also and it took me awhile to figure out how to get the sample above working since the import { FilePondFile, FilePondInitialFile } from 'filepond' Thanks @anthonysgro for the fix! @rikschennink Maybe a sample/help on the docs could be a fix in the meantime. I just copied the example from the site for react but hit type errors and this ticket helped me solve it! So like even just a |
@OscarGodson Thanks for the suggestion, I've updated the docs with a short annotation. |
This is what I did in my case. import { FilePondFile } from 'filepond';
...
const [files, setFiles] = useState<File[]>([]);
...
<FilePond
files={files}
onupdatefiles={(fileItems: FilePondFile[]) => {
setFiles(fileItems.map((f: FilePondFile) => f.file as File));
}}
allowMultiple={true}
maxFiles={3}
server="/api"
name="files"
labelIdle='Drag & Drop your files or <span class="filepond--label-action">Browse</span>'
/>
... |
Is there an existing issue for this?
Have you updated React FilePond, FilePond, and all plugins?
Describe the bug
I am a new adopter of this library, and I am using typescript. However, I cannot figure out how to have my files in state match the type demanded by onupdatefiles.
Reproduction
Here I am getting an error with onupdatefiles:
And when I switch the setFiles type to
I get an error on the files prop:
So I am not entirely sure what to do here since they are expecting two different types but they handle the same objects
Environment
The text was updated successfully, but these errors were encountered: