reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
2020-06-13T21:46:05.159Z

How do you access a components children in reagent?

2020-06-13T21:46:35.159500Z

(defn container [props]
  (let [comp (r/current-component)
        children (r/children comp)]
    [rn/view {:style (merge {:padding 24} (:style props))}
     [children]]))
I tried using r/current-component and r/children but children is coming back as null

lilactown 2020-06-13T22:04:18.159700Z

children are passed as arguments

lilactown 2020-06-13T22:04:43.160200Z

so assuming you're rendering like [container {} [child1] [child2]]

lilactown 2020-06-13T22:05:15.160900Z

the arguments passed to container will be:

(defn container [props child1 child2]
  ,,,)

lilactown 2020-06-13T22:05:39.161400Z

you can use [props & children] to refer to a variable number of children