javascript - How to call debounce correctly? lodash -
i working on reactnative project , having bit of trouble using _.debounce
method of lodash. current code:
class googleplacesautocompletemodal extends component { constructor(props) { super(props); this.getpredictions = this.getpredictions.bind(this); } getpredictions(input) { function getautocompletepredictions(input) { rngoogleplaces.getautocompletepredictions(input) .then(results => { console.log('autocomplete results: ', results); this.setstate({ predictions: results }) }) .catch(error => console.log(error.message)) } _.debounce(getautocompletepredictions, 300); } render() { return ( <textinput style={inputstyle} autocorrect={false} maxlength={40} autocapitalize={'words'} onchangetext={this.getpredictions} /> ) } }
i dont see why debounce not working since followed documentation , understand function itself. welcome!
Comments
Post a Comment