Fork me on GitHub
#reagent
<
2016-09-07
>
mac00:09:16

@peterbak There is the monet library.

lwhorton17:09:14

is it common practice if writing a “composable” component that accepts arbitrary children to simply do this:

(defn wrapper [props & children]
  [:div “my wrapper”
    (first children)])
in order to “unwrap” the spread &? Is there a more idiomatic way?

gadfly36117:09:46

Not sure if it is idiomatic, but i generally do something like this

(defn wrapper [props & children]
  (into [:div "my wrapper"] children))

gadfly36117:09:49

if doing this, just good to note that the component will rerender a lot ... so good for leafy components, not sure about top-level ones

eyelidlessness20:09:36

@gadfly361: i’m not sure that it would re-render any more than it would sans wrapper. If those props or children have cause to change, whatever is receiving them is going to re-render

gadfly36120:09:24

@eyelidlessness I guess I am thinking of a specific scenario when you are iterating over a list (like rows in a table or something). Normally, you'd add a :key to the metadata to help React know that certain items don't need to be updated ... with into, it will rerender the entire list every time it tries to render (while also silencing the keys warning).