Comment

Comment by lilactown

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

parent lilactown 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton