4 ms·
I’m surprised Reagent’s ratoms weren’t an inspiration. They give you a lot of Hooks functionality largely through Clojure’s native atom.
by city41 8y ago
I’m surprised Reagent’s ratoms weren’t an inspiration. They give you a lot of Hooks functionality largely through Clojure’s native atom.
- lilactown 8y agoYep. 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.
- deleted 8y ago[deleted]
- dmitriid 8y agoKeyword: clojure's native ratoms. You'd need to come up with a native ratom for Javascript somehow