I'm learning React. There is a component. When I write text to the input (for example, the text: "stackoverflow"), onChange fires, "stackoverflow" is written to the state (That's right), but for some reason console.log displays "stackoverflo" for me (without last letter).
Why is this happening?
import { Component } from "react";
import "./style.css";
class SearchPanel extends Component {
constructor(props) {
super(props);
this.state = { value: "" };
}
handleInputChange = (event) => {
// let term = event.target.value;
this.setState({ value: event.target.value });
console.log(this.state.value);
// this.props.searchUpdate(this.state.value);
};
render() {
return (
<input
type="text"
className="form-control search-input"
placeholder="Test"
value={this.state.value}
onChange={this.handleInputChange}
/>
);
}
}
export default SearchPanel;