You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you updated React FilePond, FilePond, and all plugins?
I have updated FilePond and its 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
export default function FreePollForm() {
// State for the file input
const [files, setFiles] = useState<Array<FilePondInitialFile | File | Blob | string>>([]);
const [formData, setFormData] = useState({});
const filepondRef = useRef<FilePond>(null)
return (
<FormItem>
<FormLabel>Image</FormLabel>
<FormControl>
<FilePond
ref={filepondRef}
files={files}
onupdatefiles={setFiles}
allowMultiple={false}
name="files"
labelIdle='Drag & Drop your files or <span className="filepond--label-action">Browse</span>'
/>
</FormControl>
</FormItem>
)
Here I am getting an error with onupdatefiles:
No overload matches this call.
Overload 1 of 2, '(props: FilePondProps): FilePond', gave the following error.
Type 'Dispatch<SetStateAction<(string | Blob | FilePondInitialFile | File)[]>>' is not assignable to type '(files: FilePondFile[]) => void'.
Types of parameters 'value' and 'files' are incompatible.
Type 'FilePondFile[]' is not assignable to type 'SetStateAction<(string | Blob | FilePondInitialFile | File)[]>'.
Type 'FilePondFile[]' is not assignable to type '(string | Blob | FilePondInitialFile | File)[]'.
Type 'FilePondFile' is not assignable to type 'string | Blob | FilePondInitialFile | File'.
Property 'options' is missing in type 'FilePondFile' but required in type 'FilePondInitialFile'.
Overload 2 of 2, '(props: FilePondProps, context: any): FilePond', gave the following error.
Type 'Dispatch<SetStateAction<(string | Blob | FilePondInitialFile | File)[]>>' is not assignable to type '(files: FilePondFile[]) => void'.ts(2769)
No overload matches this call.
Overload 1 of 2, '(props: FilePondProps): FilePond', gave the following error.
Type 'FilePondFile[]' is not assignable to type '(string | Blob | FilePondInitialFile | ActualFileObject)[]'.
Type 'FilePondFile' is not assignable to type 'string | Blob | FilePondInitialFile | ActualFileObject'.
Property 'options' is missing in type 'FilePondFile' but required in type 'FilePondInitialFile'.
Overload 2 of 2, '(props: FilePondProps, context: any): FilePond', gave the following error.
Type 'FilePondFile[]' is not assignable to type '(string | Blob | FilePondInitialFile | ActualFileObject)[]'.ts(2769)
So I am not entirely sure what to do here since they are expecting two different types but they handle the same objects
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.
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: