如何正确调用去抖? lodash

时间:2017-09-12 08:43:39

标签: javascript

我目前正在开发一个reactNative项目,我在使用lodash的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} /> ) } } 方法时遇到了一些麻烦。这是我目前的代码:

ARKitExample

我不明白为什么debounce不起作用,因为我遵循文档甚至理解函数本身。欢迎任何帮助!

0 个答案:

没有答案