Skip to content

Commit

Permalink
docs(drop-container): reduce mock upload calls when multiple is fal…
Browse files Browse the repository at this point in the history
…se (#5731)
  • Loading branch information
emyarod authored Apr 1, 2020
1 parent 2e14d83 commit a7ae576
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions packages/react/examples/drag-and-drop-file-uploader/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ExampleDropContainerApp(props) {
const [files, setFiles] = useState([]);
const uploadFile = async fileToUpload => {
// file size validation
if (fileToUpload.size > 512000) {
if (fileToUpload.filesize > 512000) {
const updatedFile = {
...fileToUpload,
status: 'edit',
Expand Down Expand Up @@ -101,10 +101,13 @@ function ExampleDropContainerApp(props) {
status: 'uploading',
iconDescription: 'Uploading',
}));
props.multiple
? setFiles([...files, ...newFiles])
: setFiles([...files, newFiles[0]]);
newFiles.forEach(uploadFile);
if (props.multiple) {
setFiles([...files, ...newFiles]);
newFiles.forEach(uploadFile);
} else {
setFiles([newFiles[0]]);
uploadFile(newFiles[0]);
}
},
[files, props.multiple]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ExampleDropContainerApp(props) {
const [files, setFiles] = useState([]);
const uploadFile = async fileToUpload => {
// file size validation
if (fileToUpload.size > 512000) {
if (fileToUpload.filesize > 512000) {
const updatedFile = {
...fileToUpload,
status: 'edit',
Expand Down Expand Up @@ -74,10 +74,13 @@ function ExampleDropContainerApp(props) {
status: 'uploading',
iconDescription: 'Uploading',
}));
props.multiple
? setFiles([...files, ...newFiles])
: setFiles([newFiles[0]]);
newFiles.forEach(uploadFile);
if (props.multiple) {
setFiles([...files, ...newFiles]);
newFiles.forEach(uploadFile);
} else {
setFiles([newFiles[0]]);
uploadFile(newFiles[0]);
}
},
[files, props.multiple]
);
Expand Down

0 comments on commit a7ae576

Please sign in to comment.