Lodash debounce with React Input
问题 I'm trying to add debouncing with lodash to a search function, called from an input onChange event. The code below generates a type error 'function is expected', which I understand because lodash is expecting a function. What is the right way to do this and can it be done all inline? I have tried nearly every example thus far on SO to no avail. search(e){ let str = e.target.value; debounce(this.props.relay.setVariables({ query: str }), 500); }, 回答1: The debounce function can be passed inline