Search code examples
reactjstypescriptreact-dropzone

How to import the types of react-dropzone?


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)
  }, [])

Solution

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

    import { FileRejection } from 'react-dropzone';