From 985620622116a428cdcb460a58569aa342e56088 Mon Sep 17 00:00:00 2001 From: Adrian Smijulj Date: Tue, 1 Jan 2019 21:42:16 +0100 Subject: [PATCH] fix: manage additional props passed on to getDropZoneProps --- src/Files.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Files.js b/src/Files.js index 52bb4f3..d4fe855 100644 --- a/src/Files.js +++ b/src/Files.js @@ -195,31 +195,37 @@ class Files extends React.Component { return (
{this.props.children({ - browseFiles: params => { - this.browseFilesPassedParams = params; - - // Opens the file browser. - this.input && this.input.click(); - }, getLabelProps: (props: ?Object) => { return { ...props, htmlFor: id || this.id }; }, - getDropZoneProps: (props: ?Object) => { + browseFiles: ({ onSuccess, onError }: Object = {}) => { + this.browseFilesPassedParams = { onSuccess, onError }; + + // Opens the file browser. + this.input && this.input.click(); + }, + getDropZoneProps: ({ + onSuccess, + onError, + onDragOver, + onDrop, + ...rest + }: Object = {}) => { + this.browseFilesPassedParams = { onSuccess, onError }; + return { - ...props, + ...rest, onDragOver: e => { e.preventDefault(); - props && - typeof props.onDragOver === "function" && - props.onDragOver(); + typeof onDragOver === "function" && onDragOver(); }, onDrop: async e => { e.preventDefault(); await this.processSelectedFiles(e.dataTransfer.files); - props && typeof props.onDrop === "function" && props.onDrop(); + typeof onDrop === "function" && onDrop(); } }; }