I’ve released @cshooks/usetrie.
It’s a React Hook for Typeahead/autocompletion.
@cshooks/hooks will be the home 🏠 of Computer Science data structures/algorithms related hooks.
When you have a list of texts you want to match by prefix, you have to match each text in an array one by one, which can be time consuming.
Check out the README file, which explains the usage in detail.
Here are some quick demo Sandboxes for the impatients.
➕ Additional Info
I’ve created this initially for academic purposes to learn Trie data structure so
Trie class is imperative and
useTrie hook was forced to fit to work with declarative nature of React as shown below, which is not ideal.
I’d really appreciate any feedback on how I can improve the code base.
I will share in the next post what I’ve learned and failures.