File Upload in TypeScript/React using formIK
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
FormIk does not support file uploading and we need to do it in custom way. Just trigger onChange event and set the file.
If you face any error of setFieldValue in TypeScript, then you simply do this:
onChange={(event) => {
if (event.currentTarget.files) {
formik.setFieldValue(
"file",
event.currentTarget.files[0]
);
}