3 ms·
Just for fun, here is what I would currently call nirvana when it comes to writing React components (12 lines compared to 35~38 from the article) (ns demos.c
by capableweb 7y ago
Just for fun, here is what I would currently call nirvana when it comes to writing React components (12 lines compared to 35~38 from the article)
(ns demos.core
(:require [reagent.core :as reagent]))
(defn DarkMode []
(let [dark? (reagent/atom false)]
(fn []
(.setAttribute js/document.body "data-theme" (if @dark? "dark" "light"))
[:label
[:span "Dark Mode"]
[:input {:type "checkbox"
:onChange #(reset! dark? (not @dark?))
:checked (when @dark? "checked")}]])))
Done with ClojureScript + Reagent