[SOLVED] How to import the types of react-dropzone?

Issue

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';

Answered By – Soufiane Boutahlil

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *