In the case of using hiccup syntax for react elements, a function to be a proper render function in Reagent it must return valid hiccup. The `kino-mit-program` fn isn't returning valid hiccup since it has no tag for the surrounding vector.
React 16 does actually support what is called "fragments" that do allow you to return multiple elements without a wrapping div. Reagent also has support for this https://github.com/reagent-project/reagent/issues/319 However, you may not be that cutting edge yet and to solve your issue here you do need to use a normal function call because the function `kino-mit-pgoram` is not a valid "component" function. Only component functions should be represented in hiccup directly, e.g. `[kino-liste]`. I typically wouldn't put `kino-mit-program` in it's own top-level function to avoid the confusion. All it is is a helper to generate parts of hiccup for a "real component render function" to use - `kino-liste`. If you do make it a separate fn, that's fine, just perhaps make it clear that its role is a helper and not a what would typically be called a component. On Wednesday, December 6, 2017 at 8:43:36 AM UTC-5, Mathias Picker wrote: > > Hi all, > > I'm new to reagent, and do not seem to understand it well enough for the > following. > > My problem: how do I write description lists. In all the examples I've > seen, there were only simple lists, returning a single <li> element. > > For a description list, I need to return two sibling elements, <dt> and > <dd>. Other examples returning more than one element used a workaround: > just put a <div> around your elements, but that's (bad html and) not > possible in this situation. > > I tried this and it seems to work > > (defn programm-für-kino > [programm] > (into [:dl.filmprogramm-für-kino] > (apply concat (for [termin programm] > [[:dt [:a {:href (:full_url termin) :target > "_blank"} > (:title termin)] ] > [:dd (:date termin)]])))) > > > but, since I have nested <dl> elements, I tried this and it failed, > returning the component as object (I guess) and some data from my maps??? > > (defn kino-mit-programm [kino] > (let [programm (<sub [::subs/programm-für-kino (:k_id kino)])] > [ [:dt (:title kino) > [:dd [programm-für-kino programm]]])) > > (defn kino-liste [] > (let [kinos (<sub [::subs/aktive-kinos])] > [:div (when kinos > (into [:dl.kinos-mit-programm] > (apply concat (for [kino kinos] > [kino-mit-programm kino]))))])) > > > If I change the component in the last line into a function call it works > again...??? > > (for [kino kinos] (kino-mit-programm kino)) > > So this works if I return the list of [:dt] [:dd] inside a component, but > if I try it with a component it bombs? > > I think this shows that I do not understand when and how the component > creation works here... > > Can someone explain to me what might be going on? > > Thanks, Mathias > > > > > > > -- You received this message because you are subscribed to the Google Groups "Reagent-Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to reagent-project+unsubscr...@googlegroups.com. To post to this group, send email to reagent-project@googlegroups.com. Visit this group at https://groups.google.com/group/reagent-project. For more options, visit https://groups.google.com/d/optout.