StringInput fires change if state and props values do not match

Now it is also possible to call onChange listener if new value is empty string
This commit is contained in:
jirik 2017-01-16 13:31:02 +01:00
parent 07523c00f0
commit fab004cdfe

View file

@ -27,7 +27,7 @@ class StringInput extends React.Component {
placeholder={this.props.default}
onChange={e => this.setState({ value: e.target.value })}
onBlur={() => {
if(this.state.value) this.props.onChange(this.state.value)
if(this.state.value!==this.props.value) this.props.onChange(this.state.value)
}}
/>
}