Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Last active February 28, 2017 17:51
Show Gist options
  • Save pesterhazy/2540ab6458f6681656bfd8bf5a4af4cb to your computer and use it in GitHub Desktop.
Save pesterhazy/2540ab6458f6681656bfd8bf5a4af4cb to your computer and use it in GitHub Desktop.
Template for Reagent on Klipse
; 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)
@pesterhazy
Copy link
Author

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