3 ms·
Yep. We've been using what is akin to an apollo-client hook at work for the past ~9 months or so: (defn my-component [] (let [user-data (data/pull! :
by lilactown 8y ago
Yep. We've been using what is akin to an apollo-client hook at work for the past ~9 months or so:
(defn my-component []
(let [user-data (data/pull! :user "{ user { firstName } }")]
(fn []
(if (:loading @user-data)
[:div "Loading..."]
[:div "Hello, "
(get-in @user-data [:data :user firstName]) "!"])))
I'm a bit surprised this pattern isn't more popular; having side-effectful functions return ratoms in a form-2 component seems almost as flexible as Hooks. It seems that most CLJS people try and keep their views more pure, which I think is honestly to their overall detriment. You miss out on the encapsulation and composition that React is espousing.
That being said, I intend to replace reagent soon with just raw React + a few helpers :P
- lauritzsh 8y ago> That being said, I intend to replace reagent soon with just raw React + a few helpers Do you intend to keep using ClojureScript or use JavaScript/TypeScript? I read pure React with ClojureScript is rather painful (mostly due to the props conversion but maybe that's what your helpers are for?) I am asking since I am still considering between React (JS/TS) and Reagent/Rum (CLJS) for a side project of mine.