khteh
khteh

Reputation: 3976

react-dropzone error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'

"react-dropzone": "^14.2.2"

 const { getRootProps, getInputProps, isDragActive } = useDropzone({
    accept: {
      "image/*": [".jpeg", ".png", ".jpg"],
    },

Error:

MediaField.tsx:266:5 - error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'.
  Type 'string' is not assignable to type 'Accept'.

266     accept: {
        ~~~~~~

  node_modules/react-dropzone/typings/react-dropzone.d.ts:31:3
    31   accept?: Accept;
         ~~~~~~
    The expected type comes from property 'accept' which is declared here on type 'DropzoneOptions'

What do I miss?

Upvotes: 0

Views: 928

Answers (1)

Vetesla
Vetesla

Reputation: 11

Use this code Instead.

 accept:{
    'image/png': ['.png'],
    'image/jpg': ['.jpg'],
    'image/jpeg': ['.jpeg'],
    },

Upvotes: 1

Related Questions