Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hatemhosny/99653ca3e82e4d1a87dcb240dffe2370 to your computer and use it in GitHub Desktop.
Save hatemhosny/99653ca3e82e4d1a87dcb240dffe2370 to your computer and use it in GitHub Desktop.
ClojureScript Reagent (Scittle)
<div id="app"></div>
<script type="application/x-scittle">
(require '[reagent.core :as r]
'[reagent.dom :as rdom])
(def state (r/atom {:clicks 0}))
(defn my-component []
[:div
[:p "Clicks: " (:clicks @state)]
[:p
[:button {:on-click #(swap! state update :clicks inc)}
"Click me!"]]])
(rdom/render [my-component] (.getElementById js/document "app"))
</script>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.1.2/dist/scittle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.1.2/dist/scittle.reagent.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment