Last active
February 28, 2017 17:51
-
-
Save pesterhazy/2540ab6458f6681656bfd8bf5a4af4cb to your computer and use it in GitHub Desktop.
Template for Reagent on Klipse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Try this online here: | |
; | |
; http://app.klipse.tech/?cljs_in.gist=pesterhazy%2F2540ab6458f6681656bfd8bf5a4af4cb&container=1 | |
(ns test.reagent | |
(:require [reagent.core :as r])) | |
(defonce !state (r/atom nil)) | |
(defn input-ui [] | |
(let [!input (r/atom nil)] | |
(fn [!model] | |
[:div | |
[:input {:value @!model | |
:on-change #(reset! !model | |
(aget % "target" "value")) | |
:ref (partial reset! !input)}] | |
[:button {:on-click (fn [] | |
(reset! !model nil) | |
(.focus @!input))} | |
"Clear and Focus"]]))) | |
(defn render [] | |
[:div | |
[:h1 "Reagent Test"] | |
[input-ui (r/cursor !state [:a])] | |
[input-ui (r/cursor !state [:b])]]) | |
(r/render [render] js/klipse-container) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See http://app.klipse.tech/?cljs_in.gist=pesterhazy%2F2540ab6458f6681656bfd8bf5a4af4cb&container=1