Home > Net >  How to import the types of react-dropzone?
How to import the types of react-dropzone?

Time:03-14

I'm using react-dropzone with typescript, but I don't know how to import the types off react-dropzone. I could not find it in the documentation. What is the type of rejectedFiles?

Code example

  const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
    onDropRejected,
  })

const onDropRejected = useCallback(rejectedFiles => {
    setFilesRejected(rejectedFiles)
  }, [])

CodePudding user response:

This is the type, and declare your state with this type: FileRejection[]

import { FileRejection } from 'react-dropzone';
  • Related