This is my render function:
render: function() {
return <div className="input-group search-box">
<input
onChange={this.handleTextChange}
type="text"
value={this.state.text}
className="form-control search-item" />
<span className="input-group-btn"></span>
</div>
}
and I have this as my event handler:
handleTextChange: function(event) {
console.log(event.target.value);
this.setState({
text: event.target.value
});
}
The problem is that when I "save" an item, or console.log print the output, the last character is missing - for instance, if I enter "first", I'll get "firs" printed out, and there needs to be another key event to capture the last character. I've tried onKeyUp
- which doesn't let me type anything in, and I've also tried onKeyDown
and onKeyPress
, which output nothing.
What is happening here and why? and how can I get that last character to show up?
getInitialState()
?console.log
ing it exactly? Remember thatsetState
is async: stackoverflow.com/questions/32674174/…