Working on ReactJS working on drag and drop multiple files upload functionality Using react-dropzone libraries. I’m not able to display errors message for file limit, same as I need error message for file types I’m Using below code for onrejected function.to display errors but I’m not able to do how to display error for rejected files based on error type.
function DragandDrop(props) {
const {
acceptedFiles,
fileRejections,
getRootProps,
getInputProps
} = useDropzone({
maxFiles:2
});
const acceptedFileItems = acceptedFiles.map(file => (
<li key={file.path}>
{file.path} - {file.size} bytes
</li>
));
const fileRejectionItems = fileRejections.map(({ file, errors }) => {
Console.log(file)
});
return (
<section className="container">
<div {...getRootProps({ className: 'dropzone' })}>
<input {...getInputProps()} />
<p>Drag 'n' drop some files here, or click to select files</p>
<em>(2 files are the maximum number of files you can drop here)</em>
</div>
{acceptedFileItems}
{fileRejectionItems}
</section>
)
<DragandDrop />```