This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-03
Channels
- # aleph (3)
- # announcements (1)
- # beginners (116)
- # boot (8)
- # braveandtrue (4)
- # cider (40)
- # cljdoc (120)
- # cljsrn (10)
- # clojure (29)
- # clojure-austin (4)
- # clojure-dev (43)
- # clojure-germany (1)
- # clojure-italy (4)
- # clojure-nl (17)
- # clojure-russia (19)
- # clojure-uk (76)
- # clojurescript (118)
- # cursive (13)
- # datascript (11)
- # datomic (73)
- # emacs (24)
- # figwheel-main (176)
- # fulcro (40)
- # hyperfiddle (4)
- # leiningen (3)
- # off-topic (1)
- # pedestal (4)
- # re-frame (6)
- # reagent (22)
- # reitit (1)
- # ring (3)
- # rum (8)
- # shadow-cljs (41)
- # spacemacs (11)
- # specter (19)
- # unrepl (1)
I want to be able to pass say a
:p
keyword to a component, to have it render as a paragraph;; component
(defn foo-pick-a-tag [tag]
[tag "foo"])
;; use it like this
[:div
[foo-pick-a-tag :h3]
[foo-pick-a-tag :p]
(doall
(for [tag [:h1 :h2 :h3 :h4]
:let [k (name tag)]]
^{:key k}
[foo-pick-a-tag tag]))
]
RAtom
in reagent is based on Atom
patten/class in Clojure
which helps in managing mutable state. What is reagent Reaction
based on ? Is there something similar in other Clojure/CLJS projects?
I am writing some detailed docs on reagent and wanted to know the background on Reaction
This https://cljdoc.xyz/d/reagent/reagent/0.8.1/doc/tutorials/-wip-managing-state-atoms-cursors-reactions-and-tracking some, otherwise looking at the code is about the only option. A Reaction is a type that implements a bunch of protocols
Reaction is reagent’s special sauce that allows it to re-render your component when a RAtom changes
I haven’t really seen anything analogous in the wider Clojure(Script) ecosystem. it’s very much toeing the line of “too magical”
Hoplon/Javelin cells are very similar to Reagent Atoms and Reactions: https://github.com/hoplon/javelin
And reactive programming libs will have similar concepts.
Thanks for the reply @jsa-aerial @lilactown @juhoteperi If I want to define Reaction in 2 lines what will it be ?
so using r/with-let, is there a way to ref the component itself? I need to know the bounding rect of the component node
just answering myself - using r/current-component in the let block works (https://stackoverflow.com/questions/39831137/force-reagent-component-to-update-on-window-resize/52156770#52156770)