3 ms·
I kind of want to show him this code to upset him more. I think React is great, especially when using it through ClojureScript. (defn todo-list [] (let [
by bschwindHN 10y ago
I kind of want to show him this code to upset him more. I think React is great, especially when using it through ClojureScript.
(defn todo-list []
(let [todos (atom [])
text (atom "")
add-todo #(do
(swap! todos conj @text)
(reset! text ""))]
(fn []
[:form {:on-submit add-todo
:action "javascript:"}
[:input {:type "text"
:value @text
:on-change #(reset! text (.-target.value %))}]
[:button {:type "submit"} "Add"]
[:ul
(for [todo @todos]
^{:key todo} [:li (str todo "!")])]])))
- throwaw12ay 10y agoIt's great that you don't need Clojurescript or even JSX to do that. You can write plain ES5 and get the same result. And it would stay readable for most.