Skip to content

Commit

Permalink
Remove ref prop on text field
Browse files Browse the repository at this point in the history
This is an anti pattern. It's not possible to pass ref down inot the component. So having it as a prop is useless and will prevent refrencing the component.
  • Loading branch information
alitaheri committed Dec 29, 2015
1 parent 9d654b1 commit 98ab4d5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/TextField/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const TextField = React.createClass({
onEnterKeyDown: React.PropTypes.func,
onFocus: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
ref: React.PropTypes.string,
rows: React.PropTypes.number,
rowsMax: React.PropTypes.number,

Expand Down Expand Up @@ -302,7 +301,7 @@ const TextField = React.createClass({

inputProps = {
id: inputId,
ref: this._getRef(),
ref: 'input',
onBlur: this._handleInputBlur,
onFocus: this._handleInputFocus,
disabled: this.props.disabled,
Expand Down Expand Up @@ -408,7 +407,7 @@ const TextField = React.createClass({
}
else if (this.isMounted()) {
if (this.props.multiLine) {
this.refs[this._getRef()].setValue(newValue);
this.refs.input.setValue(newValue);
}
else {
this._getInputNode().value = newValue;
Expand All @@ -418,13 +417,9 @@ const TextField = React.createClass({
}
},

_getRef() {
return this.props.ref ? this.props.ref : 'input';
},

_getInputNode() {
return (this.props.children || this.props.multiLine) ?
this.refs[this._getRef()].getInputNode() : ReactDOM.findDOMNode(this.refs[this._getRef()]);
this.refs.input.getInputNode() : ReactDOM.findDOMNode(this.refs.input);
},

_handleInputBlur(e) {
Expand Down

0 comments on commit 98ab4d5

Please sign in to comment.