react-dropzone
Advanced tools
Comparing version 11.0.1 to 11.0.2
@@ -17,7 +17,12 @@ By providing `accept` prop you can make the dropzone accept specific file types and reject the others. | ||
function Accept(props) { | ||
const {acceptedFiles, rejectedFiles, getRootProps, getInputProps} = useDropzone({ | ||
const { | ||
acceptedFiles, | ||
fileRejections, | ||
getRootProps, | ||
getInputProps | ||
} = useDropzone({ | ||
accept: 'image/jpeg, image/png' | ||
}); | ||
const acceptedFilesItems = acceptedFiles.map(file => ( | ||
const acceptedFileItems = acceptedFiles.map(file => ( | ||
<li key={file.path}> | ||
@@ -28,5 +33,10 @@ {file.path} - {file.size} bytes | ||
const rejectedFilesItems = rejectedFiles.map(file => ( | ||
const fileRejectionItems = fileRejections.map({ file, errors}) => ( | ||
<li key={file.path}> | ||
{file.path} - {file.size} bytes | ||
<ul> | ||
{errors.map(e => ( | ||
<li key={e.code}>{e.message}</li> | ||
)} | ||
</ul> | ||
</li> | ||
@@ -37,3 +47,3 @@ )); | ||
<section className="container"> | ||
<div {...getRootProps({className: 'dropzone'})}> | ||
<div {...getRootProps({ className: 'dropzone' })}> | ||
<input {...getInputProps()} /> | ||
@@ -45,9 +55,5 @@ <p>Drag 'n' drop some files here, or click to select files</p> | ||
<h4>Accepted files</h4> | ||
<ul> | ||
{acceptedFilesItems} | ||
</ul> | ||
<ul>{acceptedFileItems}</ul> | ||
<h4>Rejected files</h4> | ||
<ul> | ||
{rejectedFilesItems} | ||
</ul> | ||
<ul>{fileRejectionItems}</ul> | ||
</aside> | ||
@@ -54,0 +60,0 @@ </section> |
@@ -168,3 +168,3 @@ { | ||
}, | ||
"version": "11.0.1", | ||
"version": "11.0.2", | ||
"engines": { | ||
@@ -171,0 +171,0 @@ "node": ">= 8" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328170
5216