Fork me on GitHub
#om
<
2015-07-16
>
denik00:07:47

Is there an equivalent to reacts this.props.children in om?

mattly18:07:51

@denik: short answer, yes but it’s awkward

denik18:07:43

@mattly thanks! I can just use -children on the parent as well but it seems backwards considering the virtual dom

denik18:07:42

@mattly how awkward is it? or do you know of another way to access the children of a component through om?

mattly18:07:57

This is a helper function I have

mattly18:07:30

and it gets used like, (om/build component-name (children child-components))

mattly18:07:33

you can’t really do them inline

denik18:07:39

so it builds the child components before the parent but does not render it?

mattly18:07:26

it builds the child components and then you’d just put the :children item from your data/props map into your output somewhere in render

mattly18:07:43

the way most materials for om are written, what becomes this.props in React is described as datafor om

mattly18:07:08

which when you start getting into cursors makes sense – you’re passing around data that will be rendered

mattly18:07:46

however a lot of the components that I’ve written before have props that are more typically “options”, such as switches for displaying something differently, etc

mattly18:07:56

or callback functions

mattly18:07:03

they’re not really data

mattly18:07:28

you can provide a third argument to om/build that is a map with an :opts key that is available to your component constructor

mattly18:07:19

but I think it’s a different take on what props are, coming from working in-depth on large react/flux projects in JS