Comment

Comment by pgt

(Edit: it is worth noting that Hooks are based on Reagent's reactive atoms.)

Compare the complexity of Hooks with the simplicity of state management in [Reagent](http://reagent-project.github.io/) or [Rum](https://github.com/tonsky/rum).

Complete ClojureScript example using Reagent:

  (ns reagent-example.core
    (:require [reagent.core :as r])

  (def !count (atom 0)) ;; ! prefix is convention for state

  (defn counter-component []
    [:div
      [:p "You have clicked the button " @!count " times."]
      [:button {:on-click #(swap! !count inc)} "Increment"]])

  (r/render [counter-component] (js/document.getElementById "app"))
The same example using Rum:

  (ns rum-example.core
    (:require [rum.core :as rum])

  (def !count (atom 0))

  (rum/defc counter-component < rum/reactive []
    [:div
      [:p "You have clicked the button " (rum/react !count) " times."]
      [:button {:on-click #(swap! !count inc)} "Increment"]])

  (rum/mount (counter-component) (js/document.getElementById "app"))
parent pgt 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton