This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-07
Channels
- # adventofcode (62)
- # babashka (88)
- # beginners (52)
- # boot (2)
- # bristol-clojurians (1)
- # calva (7)
- # cider (16)
- # circleci (4)
- # clj-kondo (12)
- # cljdoc (5)
- # cljsrn (4)
- # clojure (53)
- # clojure-dev (1)
- # clojure-spec (7)
- # clojure-uk (7)
- # clojurescript (25)
- # core-async (14)
- # duct (1)
- # emacs (10)
- # figwheel-main (3)
- # fulcro (11)
- # garden (14)
- # jobs (1)
- # klipse (2)
- # luminus (1)
- # malli (9)
- # re-frame (6)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (124)
- # sql (1)
- # testing (15)
- # tools-deps (13)
- # uncomplicate (1)
- # vim (1)
Hello! How is hiccup imported into this namespace :thinking_face: https://github.com/jonase/reagent-tutorial ? I can not see what line enables Hiccup here
Huccup is just a way to represent DOM elements with Clojure data structures. Reagent transforms Huccup into React's objects for you.
but the problem is that there is only thing of imports [reagent.core :as r]
And it is not obvious how it works actually?
Oh boy. You're basically asking how the whole Reagent works. 🙂
You need only to call reagent.core/render
. Everything else from Reagent is optional. That function will traverse all data structures in the Hiccup form and all functions, and will create all the necessary React objects and let React do the rest.
The r/atom
s are magic. Basically, when you dereference them in a view function, they're registered in an internal Reagent registry that propagates any changes to them to a function that re-renders that very same component.
1 thing : how then [:div...
form works? does it register some reader macro before compilation
No-no-no. It's a plain vector. Reagent then just sees the vector, turns its first element into a component, and the rest of the elements into its parameters. Plain data manipulation.
aaah this one r/render-component
then does the magic. Now it is all clear. thanks 👍:skin-tone-2: