This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-13
Channels
- # admin-announcements (6)
- # beginners (19)
- # boot (1)
- # cbus (2)
- # cider (3)
- # clara (24)
- # cljs-dev (4)
- # cljsrn (18)
- # clojure (168)
- # clojure-boston (1)
- # clojure-dev (55)
- # clojure-russia (199)
- # clojure-sg (2)
- # clojurescript (38)
- # clojurex (1)
- # core-async (15)
- # css (16)
- # cursive (62)
- # datomic (23)
- # editors-rus (17)
- # events (3)
- # funcool (1)
- # hoplon (360)
- # ldnclj (37)
- # lein-figwheel (11)
- # leiningen (1)
- # nginx (1)
- # off-topic (13)
- # om (361)
- # onyx (1)
- # re-frame (56)
- # reagent (24)
- # robots (1)
- # spacemacs (46)
- # yada (9)
Hi all. Anyone know if there's a way to get the this
reference in a :reagent-render
function?
Or am I stuck going with :render
and using argv
?
Need to have both 😕
By coincidence, this link was recently posted: https://github.com/reagent-project/reagent/issues/47#issuecomment-61056999
In fact, just look back to the last code block.
Yeah, saw that. Was hoping to get it the other direction, but I guess there’s no advantage or disadvantage
Perhaps you want reagent.core/current-component
Hello guys, maybe this has already been answered, but is there another way to layout dynamic components with Reagent? I found this but it looks convoluted..http://stackoverflow.com/q/25371926/1888507
@mikethompson: It’s to get a value out of an input field in the dom. It's legacy code, not the way I’d handle it, but I’d like to see how to handle these kinds of scenarios in Reagent.
In the current Om-based code, I’ll always have access to this
in all lifecycle methods, so getting a DOM node is simple. Less so in Reagent, it seems
(reagent.core/current-component)
looks easy enough to me
You can use that in the renderer
But not in the lifecycle fns
Anway, have a read of the above
Oh, seems I have another problem, since I’m using refs. Is it correct that I’ll need to wrap all refs in components, since I cannot use React’s refs directly?
@grav did you solve it? how did you access the laid-out DOM within, say, :component-did-mount
?
I am using this approch now and I would like to ask if it is a good one:
(defn build-section-ui
"Builds the UI for a section."
[section]
(let [name "section-ui-component"
dynamic-map (reagent/atom {:topics {:min-width "20px"}})]
(reagent/create-class
{:display-name name
:component-did-mount
(fn []
(reagent.debug/prn name "component-did-mount -> dyn-map" "dyn-map is" @dynamic-map)
;; change :min-width here
)
:reagent-render
(fn [section]
(reagent.debug/prn name "rendering -> dyn-map" @dynamic-map)
[section-ui-render @dynamic-map section])})))
is there a way to get a child of the this
by name (or anything else) ?