Skip to content

Commit

Permalink
adding setValue() to input
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantMStevens committed Apr 11, 2016
1 parent b9af0ac commit 1e0be60
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dist/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class Input extends Component {
this.setPristine = this.setPristine.bind(this);
this.setInvalid = this.setInvalid.bind(this);
this.focus = this.focus.bind(this);
this.setValue = this.setValue.bind(this);
}

updateInputState(){
Expand All @@ -53,7 +54,7 @@ export default class Input extends Component {
}

componentWillReceiveProps(nextProps){
if (this.state.value === '' || this.state.value === undefined){
if ((this.state.value === '' || this.state.value === undefined) && (nextProps.defaultValue !== '' && nextProps.defaultValue !== undefined)){
this.setState({
value: nextProps.defaultValue
})
Expand Down Expand Up @@ -248,6 +249,12 @@ export default class Input extends Component {
ReactDOM.findDOMNode(this.refs.currentInput).blur();
}

setValue(value){
this.setState({
value: value
})
}

render() {
var classes = classNames({
'valid': this.state.valid,
Expand Down

0 comments on commit 1e0be60

Please sign in to comment.