Skip to content

Instantly share code, notes, and snippets.

Last active December 30, 2015 05:29
What would you like to do?
(ns react-cljs.core
(:require React))
(declare render-ui)
(defn render-counter [id state root]
(let [cnt (or (get-in state [id :count]) 0)]
(React/DOM.div nil
(React/DOM.label nil cnt)
(js-obj "onClick" #(root (assoc-in state [id :count] (inc cnt))))
(js-obj "onClick" #(root (assoc-in state [id :count] (dec cnt))))
(defn render-ui [n]
(letfn [(root [state]
(React/DOM.div nil
[(React/DOM.h1 nil "A Counting Widget!")]
(map #(render-counter % state root) (range n)))))
(root (zipmap (range n) nil))))
(render-ui 10)
Copy link

(zipmap (range 10) nil) returns {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment