Simple React hook to create a HTML5-compliant drag'n'drop zone for files with support for auto-upload. This is based on react-dropzone
npm install --save selfmade-react-dropzone
or:
yarn add selfmade-react-dropzone
Please refer to react-dropzone for most of the functionality it offers.
For auto-uploading files, you need to pass uploadConfig
prop. To monitor the progress, you can access the files with status through uploadedFiles
state.
const {
acceptedFiles,
uploadedFiles,
draggedFiles,
getRootProps,
getInputProps
} = useDropzone({
uploadConfig: {
url: "https://httpbin.org/post", // required
metadata: {}, // optional
headers: {}, // optional
withCredentials: true, // optional
responseType: "json" // optional
}
});
MIT