News for hackers. Stuff that matters.
Re:Web-dev nirvana, and why I needed to let go of React to r... by capableweb on Monday September 23, 2019 @06:33PM (#21054478)
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

There are no comments on this comment yet.