Last active
July 26, 2017 01:23
-
-
Save shurane/ffcba49be3e4570488ea3dda3db2e759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { debounce } from 'lodash'; | |
class SearchBox extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {value: ''}; | |
// https://stackoverflow.com/a/28046731/198348 | |
// this.handleChange = this.handleChange.bind(this); | |
this.handleChange = debounce(this.handleChange.bind(this), 300); | |
} | |
handleChange(event) { | |
event.persist(); | |
console.log(event); | |
this.setState({value: event.target.value}); | |
console.log(event.target.value); | |
} | |
render() { | |
return ( | |
<label> | |
Search: <input type="text" value={this.state.value} onChange={this.handleChange} /> | |
</label> | |
) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment