class Search extends Component {
constructor(props) {
super(props);
this.state = {
searchTerm: 'some statement..'
};
}
onChangeHander(event) {
this.setState({
searchTerm: event.target.value
});
}
render() {
return (
<div>
<input
onChange="this.onChangeHander"
value={this.state.searchTerm}
type="text"
placeholder="Search"
/>
</div>
);
}
}
onChange(this.onChangeHandler.bind(this));
contructor(props) {
...
this.onChangeHandler = this.onChangeHandler.bind(this);
}
"plugins": [
"babel-plugin-transform-class-properties"
]
class Search extends Component {
// constructor(props) {
// super(props);
// this.state = {
// searchTerm: ''
// };
// this.onChageHandler = this.onChangeHander.bind(this);
// }
state = {
searchTerm: ''
};
// onChangeHandler(event) {
onChangeHandler = event => {
this.setState({
searchTerm: event.target.value
});
};
render() {
return (
<div>
<input
onChange="this.onChangeHandler"
value={this.state.searchTerm}
type="text"
placeholder="Search"
/>
</div>
);
}
}