Fork me on GitHub
#reagent
<
2018-09-03
>
Charlot00:09:04

One other question...

Charlot00:09:37

Is it possible to set the html key of a hiccup expression programmatically?

Charlot00:09:11

I want to be able to pass say a

:p
keyword to a component, to have it render as a paragraph

Charlot00:09:41

and be able to use that same component with an

:h3
passed in, as a header?

Charlot00:09:57

I get errors about dangerously set html if i just use a straight variable

gadfly36100:09:51

@shawx538

;; 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]))
 ]

Charlot00:09:48

Okay. I'm realizing my errors might be coming from someplace else

Charlot00:09:07

Will come back when I have a concrete example/question

rnagpal17:09:35

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

jsa-aerial17:09:10

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

lilactown18:09:50

Reaction is reagent’s special sauce that allows it to re-render your component when a RAtom changes

lilactown18:09:33

I haven’t really seen anything analogous in the wider Clojure(Script) ecosystem. it’s very much toeing the line of “too magical”

juhoteperi18:09:56

Hoplon/Javelin cells are very similar to Reagent Atoms and Reactions: https://github.com/hoplon/javelin

juhoteperi18:09:20

And reactive programming libs will have similar concepts.

rnagpal19:09:58

Thanks for the reply @jsa-aerial @lilactown @juhoteperi If I want to define Reaction in 2 lines what will it be ?

rnagpal19:09:41

I can see that its is the building block of reagent

rnagpal19:09:46

and how its working

rnagpal19:09:02

but unable to come up with a good definition for what it does

rnagpal19:09:31

as it has both state + functionality + interacts with other parts

kaosko19:09:29

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