Skip to content

Instantly share code, notes, and snippets.

@zehnpaard
Created November 13, 2016 21:46
Show Gist options
  • Save zehnpaard/4b0a5bfaf6cb51ebb58ecb561e2b6b2f to your computer and use it in GitHub Desktop.
Save zehnpaard/4b0a5bfaf6cb51ebb58ecb561e2b6b2f to your computer and use it in GitHub Desktop.
Reagent Form-2 Component Nesting Part 2 (Purely Demonstrative Purposes)
(ns clicker2.core
(:require [reagent.core :as r]))
(def message (r/atom "Hello"))
(defn clicker [some-message]
(let [john? (r/atom true)]
(fn [some-message]
(let [clicks (r/atom 0)]
(fn [some-message]
[:div
[:h1 {:on-click #(swap! john? not)} (if @john? "John" "James")]
[:p {:on-click #(swap! clicks inc)} "Clicks: " @clicks]
[:p {:on-click #(reset! message "Good Bye")} some-message]])))))
(defn my-app []
[:div
[clicker @message]])
(r/render
[my-app]
(js/document.getElementById "app"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment