Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/inputfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ var InputField = function (_Component) {
var _this2 = this;

var _props = this.props,
component = _props.component,
onInputChange = _props.onInputChange,
restProps = _objectWithoutProperties(_props, ['onInputChange']);
inputRef = _props.inputRef,
restProps = _objectWithoutProperties(_props, ['component', 'onInputChange', 'inputRef']);

return _react2.default.createElement('input', _extends({
type: 'text'
}, restProps, {
return _react2.default.createElement(component, _extends({}, restProps, {
ref: function ref(input) {
_this2.input = input;
if (inputRef) inputRef(input);
},
value: this.state.value,
onChange: this.handleInputChange,
Expand All @@ -122,6 +123,7 @@ InputField.propTypes = {
onInputChange: _propTypes2.default.func
};
InputField.defaultProps = {
component: 'input',
onChange: noop,
onInputChange: noop
};
Expand Down
25 changes: 13 additions & 12 deletions src/inputfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class InputField extends Component {
}

static defaultProps = {
component: 'input',
onChange: noop,
onInputChange: noop
}
Expand Down Expand Up @@ -71,18 +72,18 @@ class InputField extends Component {
}

render() {
const { onInputChange, ...restProps } = this.props
return (
<input
type='text'
{...restProps}
ref={(input)=>{this.input = input}}
value={this.state.value}
onChange={this.handleInputChange}
onCompositionStart={this.handleComposition}
onCompositionEnd={this.handleComposition}
/>
)
const { component, onInputChange, inputRef, ...restProps } = this.props
return React.createElement(component, {
...restProps,
ref: input => {
this.input = input;
if(inputRef) inputRef(input);
},
value: this.state.value,
onChange: this.handleInputChange,
onCompositionStart: this.handleComposition,
onCompositionEnd: this.handleComposition,
});
}
}

Expand Down