This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-17
Channels
- # announcements (3)
- # babashka (41)
- # beginners (118)
- # calva (4)
- # cider (22)
- # clj-kondo (4)
- # clj-on-windows (1)
- # clj-together (1)
- # clojure (164)
- # clojure-europe (46)
- # clojure-filipino (1)
- # clojure-indonesia (1)
- # clojure-my (1)
- # clojure-nl (3)
- # clojure-sg (1)
- # clojure-spec (13)
- # clojure-uk (16)
- # clojurescript (18)
- # cloverage (3)
- # conjure (5)
- # core-async (8)
- # cursive (21)
- # datomic (4)
- # deps-new (15)
- # emacs (12)
- # expound (4)
- # fulcro (45)
- # graalvm (32)
- # jobs (1)
- # malli (5)
- # nextjournal (63)
- # off-topic (27)
- # other-languages (3)
- # pathom (27)
- # proletarian (1)
- # rdf (24)
- # re-frame (10)
- # reagent (9)
- # releases (2)
- # shadow-cljs (72)
- # spacemacs (4)
- # timbre (4)
- # tools-deps (29)
- # xtdb (4)
Hey. What's the equivalent to `useEffect` in Reagent? Is it just a function that does some work and mutates an atom?
technically using component-did-update
in a form 3 component is the closest equivalent of useEffect in reagent
I actually googled this a couple of days ago, is it not advisable to use the useEffect
hook directly?
functions used as reagent components get turned into react classes under the hood, which cannot use hooks within the body of the render function
reagent does have new capability to render a function as a true function component (rather than a class) using the :f>
kw. e.g.
(defn my-component
[]
(useEffect #(prn "rendered"))
[:div "hi"])
(defn app
[]
[:f> my-component])
Yea, appending :f
to my-component
is required, defn my-component:f [] ...)
Right, that's what I was suggesting / asking about
Functional components+hooks are generally easier to manage in Typescript, nice lifecycle management syntax etc. Not sure about Reagent, still learning