Skip to content

Instantly share code, notes, and snippets.

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