On Tuesday, February 16, 2016 at 8:40:03 AM UTC+1, Feifan Zhou wrote:
> Hello,
> I have a a data structure that looks like this:
> 
> {:data "foo"
>  :children {
>     :data "bar"
>     :children {
>       :data "baz"}}}
> 
> I'd like to render it into components like this:
> 
> <Comp>
>   foo
>   <Comp>
>     bar
>     <Comp>
>       baz
>     </Comp>
>   </Comp>
> </Comp>
> 
> Conceptually it makes sense to recurse over the data structure to generate 
> the view, but AFAIK the Om.next component has to be turned into a factory 
> (via a separate `def`) before it can be used in Comp's `render`. Since `def`s 
> aren't hoisted, how would I go about referencing the factory in the `render`?

There are examples of recursive components in the Om repository. Here's the 
link: for the particular examples: 
https://github.com/omcljs/om/blob/master/src/devcards/om/devcards/core.cljs#L242-L408

I have also written 2 blog posts that cover recursive queries and components 
with Om Next. I hope you find them useful:
http://anmonteiro.com/2016/01/exploration-patterns-om-next-part-1/
http://anmonteiro.com/2016/01/exploration-patterns-om-next-part-2/

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to