Fork me on GitHub
#reagent
<
2016-10-11
>
mikethompson06:10:58

@colindresj I'm not entirely sure of your requirement, but remember that hiccup is just about vectors and maps

mikethompson06:10:19

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.

mikethompson06:10:15

When you rerender children you can quite literately merge in new props into the map

mikethompson06:10:36

(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.

mikethompson06:10:40

@mattsfrey not had that problem. Post the offending style in here. Might be easy to see the problem

colindresj13:10:11

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

colindresj14:10:37

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