Quick update on Halogen Hooks: there have been a couple new releases over the last few weeks, which in sum:
Simplifies the type signatures when you’re writing Hooks of your own
Introduces some performance improvements, including memoComponent to control when to render when receiving new input
Replaces state tokens with a modifyState function
Fixes some bugs and introduces a full test suite for Hooks – in the future, this will be released as its own package so you can test your own custom Hooks, too
@JordanMartinez has been particularly helpful and active in contributing to these releases, so many thanks to you. If you’ve been using Hooks I highly recommend updating! I suspect the current version, 0.3.0, will be stable for some time.
Oh, I wasn’t aware of halogen-hooks-extra.
Most of my custom hooks are specific to my application, but there’s one that could be useful for other people. I made a throttling hook out of the debouncer one from the examples.
useDebouncer only runs the action if no new values are passed for the length of the interval you specify. The throttling hook will run the action continuously, but at most once every interval.
For instance, let’s say you need to update something for every mouse movement, and you set a 100ms interval. useDebouncer will only run the action once the mouse move events stop for 100ms. The throttling hook will make the update happen every 100ms and will only stop if no new values are passed.