Fork me on GitHub
#helix
<
2022-09-03
>
Ferdinand Beyer07:09:08

I noticed that helix.hooks contains an implementation of use-subscribe. React 18 comes with a native hook for this: useSyncExternalStore, and for older versions there is a shim: https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore https://www.npmjs.com/package/use-sync-external-store I am wondering if we should just use this for use-subscribe — less code to maintain, plus it will work with React 18? Moreover, while evaluating Reagent alternatives, I also had a look at uix, which also comes with its own hooks wrappers, that are pretty similar to helix’s. I am wondering if we should join forces and create a separate library just for ClojureScript react hooks? I am willing to contribute a use-watch hook that uses use-subscribe (or useSyncExternalStore) for refs/atoms (`IWatchable` + IDeref). This would make it super easy to run a simple state management solution based on just atoms!

Ferdinand Beyer13:09:49

…then again Helix provides :auto-deps which might be less portable. 🤷

lilactown17:09:33

yeah, uSES should be preferred over use-subscribe

lilactown17:09:48

I think that it's fine for uix and helix to have different wrappers. Helix's goal is to provide the bare minimum needed, mostly just wrappers around React's core hooks. e.g. you probably wouldn't bother using helix.hooks unless you were using helix.core

lilactown17:09:43

I think that it would be great if more libs were created in the CLJS ecosystem that provided custom hooks. like your use-watch that uses useSyncExternalStore

👍 1