Skip to content

Commit

Permalink
fix: execute onDragOver / onDrop callbacks only if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Dec 28, 2018
1 parent 3aa6e76 commit 5ea58f0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Files.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,19 @@ class Files extends React.Component<Props> {
// Opens the file browser.
this.input && this.input.click();
},
getDropZoneProps: (props: Object) => {
getDropZoneProps: (props: ?Object) => {
return {
...props,
onDragOver: e => {
e.preventDefault();
typeof props.onDragOver === "function" && props.onDragOver();
props &&
typeof props.onDragOver === "function" &&
props.onDragOver();
},
onDrop: async e => {
e.preventDefault();
await this.processSelectedFiles(e.dataTransfer.files);
typeof props.onDrop === "function" && props.onDrop();
props && typeof props.onDrop === "function" && props.onDrop();
}
};
}
Expand Down

0 comments on commit 5ea58f0

Please sign in to comment.