diff --git a/src/components/inputs/StringInput.jsx b/src/components/inputs/StringInput.jsx index 6d8a60eb..b7f661fd 100644 --- a/src/components/inputs/StringInput.jsx +++ b/src/components/inputs/StringInput.jsx @@ -9,15 +9,32 @@ class StringInput extends React.Component { onChange: React.PropTypes.func, } + constructor(props) { + super(props) + this.state = { + value: props.value + } + } + + changeValue(newValue) { + //TODO: In feature we can try to do validation here as well + this.setState({ value: newValue }) + } + + componentWillReceiveProps(nextProps) { + this.setState({ value: nextProps.value }) + } + render() { return this.props.onChange(e.target.value)} + onChange={e => this.changeValue(e.target.value)} + onBlur={() => this.props.onChange(this.state.value)} /> } }