This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-11
Channels
- # aleph (7)
- # bangalore-clj (11)
- # boot (70)
- # cider (11)
- # cljsjs (3)
- # cljsrn (17)
- # clojure (88)
- # clojure-brasil (8)
- # clojure-dev (17)
- # clojure-greece (1)
- # clojure-italy (6)
- # clojure-poland (8)
- # clojure-russia (2)
- # clojure-spec (44)
- # clojure-uk (32)
- # clojurescript (176)
- # cloverage (2)
- # component (5)
- # cursive (3)
- # datomic (23)
- # defnpodcast (6)
- # dirac (15)
- # emacs (6)
- # garden (19)
- # hoplon (126)
- # leiningen (1)
- # off-topic (3)
- # om (66)
- # onyx (56)
- # re-frame (8)
- # reagent (7)
- # ring-swagger (43)
- # specter (18)
- # untangled (110)
- # vim (3)
- # yada (39)
@colindresj I'm not entirely sure of your requirement, but remember that hiccup is just about vectors and maps
It's just data. <--- this is where the power comes from. And you can construct those vectors and maps in whatever way you want, using the full capabilities of clojurescript.
When you rerender children you can quite literately merge
in new props into the map
(defn view
[with-extras?]
(let [extra-style (when with-extras? {:background-color "blue"})]
[:div {:style (merge extra-style {:font-size "14px"})}
"Hello"
(when with-extras? " extra child")]))
So here, if with-extras?
becomes true, the props for the child change.@mattsfrey not had that problem. Post the offending style in here. Might be easy to see the problem
That’s close to what I’m doing @mikethompson, but I happen to be passing in a children into the parent component. Because it’s written out as a vector, the child component is instantiated by Reagent as a React element. Within the parent component, the child is represented as a vector of [<reactElement> <map of props>]
. So, I’ve been merging the second item in the vector with my additional props, and that seems to be working, but just wanted to make sure I wasn’t missing something
Here’s a simplified example:
(defn parent-component [props [child-element child-props]]
(let [merged-props (r/merge-props child-props {:my “props”})]
[child-element merged-props]))