I was building a component that did address autocompletion against a GraphQL endpoint using react-apollo
.
The value of the input field was used to search for addresses, but I didn't want every single keystroke to result
in a new GraphQL query. So, I needed some sort of debounce function (Apollo doesn't provide this natively).
While I could have used a class component for something like this, I wanted to see if it could be done more simply with Hooks. This is what I came up with.