From c1eda4c45085c8267ad1efe9d0970e36f7198a4b Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 17 Dec 2019 13:25:58 -0600 Subject: [PATCH] feat(file-uploader): add support for onChange --- .../react/src/components/FileUploader/FileUploader.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/FileUploader/FileUploader.js b/packages/react/src/components/FileUploader/FileUploader.js index bc886b7eb7ac..8669da725c0c 100644 --- a/packages/react/src/components/FileUploader/FileUploader.js +++ b/packages/react/src/components/FileUploader/FileUploader.js @@ -297,6 +297,12 @@ export default class FileUploader extends Component { */ name: PropTypes.string, + /** + * Provide an optional `onChange` hook that is called each time the input is + * changed + */ + onChange: PropTypes.func, + /** * Provide an optional `onClick` hook that is called each time the button is * clicked @@ -347,7 +353,9 @@ export default class FileUploader extends Component { Array.prototype.map.call(evt.target.files, file => file.name) ), }); - this.props.onChange(evt); + if (this.props.onChange) { + this.props.onChange(evt); + } }; handleClick = (evt, index) => {