We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 462178d commit 69cbe03Copy full SHA for 69cbe03
src/om_tutorial/core.cljs
@@ -5,15 +5,22 @@
5
6
(enable-console-print!)
7
8
-(defui HelloWorld
+(def app-state (atom {:count 0}))
9
+
10
+(defui Counter
11
Object
12
(render [this]
- (dom/div nil (get (om/props this) :title))))
13
+ (let [{:keys [count]} (om/props this)]
14
+ (dom/div nil
15
+ (dom/span nil (str "Count: " count))
16
+ (dom/button
17
+ #js {:onClick
18
+ (fn [e]
19
+ (swap! app-state update-in [:count] inc))}
20
+ "Click me!")))))
21
-(def hello (om/factory HelloWorld))
22
+(def reconciler
23
+ (om/reconciler {:state app-state}))
24
-(js/ReactDOM.render
- (apply dom/div nil
- (map #(hello {:title (str "Hello " %)})
- (range 3)))
- (gdom/getElement "app"))
25
+(om/add-root! reconciler
26
+ Counter (gdom/getElement "app"))
0 commit comments