Using a Reagent atom within a Helix component

As part of my subscriptions library which makes use or reagent I implemented a react hook to subscribe to reagent atoms, reactions, and cursors.

The entry namespace is here:

and the actual hook implementation is here (which was originally copied/inspired from the one linked above, but found it didn’t work):

This implementation memoizes the subscription vectors to prevent needless re-renders, as well as retaining every subscription a component uses for its lifetime so that those subscriptions are cached for the entire lifetime of the component.

A simple example usage is in the readme:

1 Like