This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-21
Channels
- # beginners (38)
- # boot (88)
- # cljs-dev (142)
- # cljsrn (2)
- # clojars (1)
- # clojure (107)
- # clojure-berlin (2)
- # clojure-italy (8)
- # clojure-russia (76)
- # clojure-spec (325)
- # clojure-taiwan (3)
- # clojure-uk (28)
- # clojurescript (80)
- # clojurewest (2)
- # core-async (36)
- # core-logic (1)
- # cursive (21)
- # datomic (16)
- # dirac (18)
- # docs (2)
- # emacs (1)
- # euroclojure (3)
- # garden (3)
- # gsoc (2)
- # hoplon (3)
- # immutant (4)
- # jobs-discuss (16)
- # lein-figwheel (5)
- # liberator (17)
- # lumo (19)
- # off-topic (2)
- # om (20)
- # onyx (28)
- # pedestal (50)
- # planck (4)
- # re-frame (5)
- # reagent (3)
- # ring-swagger (13)
- # spacemacs (1)
- # specter (43)
- # testing (3)
- # timbre (3)
- # uncomplicate (1)
- # vim (2)
- # yada (4)
How do I allow Form-2 component to return a list of multiple elements instead of a vector?
I need to render two :div
elements per iteration for a Semantic accordion, but (list [:div ...] [:div ...])
breaks when you add local state. Returning a single div breaks the CSS. Here is my component:
(defn customer-accordion [customer]
(let [active? (atom false)]
(fn [customer]
(list
^{:key (str (:id customer) ":accordion")}
[:div.title
{:on-click #(swap! active? not)
:class (if @active? "active")}
[:i.dropdown.icon] (:name customer)]
^{:key (str (:id customer ":accordion-content")}
[:div.content
{:class (if @active? "active")}
[:div "Some more data goes here"]]))))
React doesn't (currently) support components which render multiple nodes: https://github.com/facebook/react/issues/2127