I'm trying to upload a file using Formik and setFieldValue.
I don't understand why i'm getting
InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement': This input element > accepts a filename, which may only be programmatically set to the empty string.
When i'm uploading a file
I have some knowledge of React, but it's my first time with Formik.
Some (maybe useful) code
export const ImageUploaderField = ({ ...props }) => {
const { setFieldValue } = useFormikContext()
const [field] = useField(props)
return (
<Field
{...field}
{...props}
onChange={(event) => {
setFieldValue(field.name, event.currentTarget.files)
}}
/>
)
}
Call site
<ImageUploaderField name="filename" type="file" />