From d66c2cf5d57a8571a1ed11c76bbf37b1c979742b Mon Sep 17 00:00:00 2001 From: Robert Bak Date: Tue, 14 Aug 2018 10:58:50 +0200 Subject: [PATCH 1/2] Update for React 16 compatibility --- README.md | 6 ++++-- lib/index.js | 3 ++- package.json | 14 +++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5d17342..939596f 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,11 @@ Usage is pretty simple: just use react-input-file instead of ` Date: Thu, 6 Sep 2018 13:04:15 +0200 Subject: [PATCH 2/2] Compatibility changes --- lib/index.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/index.js b/lib/index.js index a5bb8ee..cc3ee8d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,8 +1,7 @@ var React = require('react'); var createReactClass = require('create-react-class'); - var FileInput = createReactClass({ - getInitialState: function() { + getInitialState: function () { return { value: '', styles: { @@ -25,20 +24,20 @@ var FileInput = createReactClass({ }; }, - handleChange: function(e) { + handleChange: function (e) { this.setState({ value: e.target.value.split(/(\\|\/)/g).pop() }); if (this.props.onChange) this.props.onChange(e); }, - render: function() { - return React.DOM.div({ - style: this.state.styles.parent - }, + render: function () { + return React.createElement('div', { + style: this.state.styles.parent + }, // Actual file input - React.DOM.input({ + React.createElement('input', { type: 'file', name: this.props.name, className: this.props.className, @@ -49,13 +48,13 @@ var FileInput = createReactClass({ }), // Emulated file input - React.DOM.input({ + React.createElement('input', { type: 'text', tabIndex: -1, name: this.props.name + '_filename', value: this.state.value, className: this.props.className, - onChange: function() {}, + onChange: function () { }, placeholder: this.props.placeholder, disabled: this.props.disabled, style: this.state.styles.text