When i used onchange event to update my state i have a delay character
this is my class
var DivInput = React.createClass({
getInitialState: function() {
return {
content: ''
}
},
onChange: function(e) {
var value = e.target.value
var name = e.target.name
this.setState({
content: value
});
console.log(this.state.content)
this.props.onUpdateState(name, value)
},
render: function() {
return (
<div className="form-group">
<label className="col-md-4 control-label" for="textinput">{this.props.content}</label>
<div className="col-md-4">
<input onChange={this.onChange} name={this.props.name} type={this.props.type} value={this.state.content} className="form-control input-md" />
</div>
</div>
)
}
})
i have yet initiated my state at '' with getInitialState, and update it when my input change but i have this problem :
if i write : "a"
this.state.content = ""
if i write : "ab"
this.state.content = "a"
for input at = "abc"
this.state.content = "ab"
etc...
Someone has already fixed this problem ?
thanks