Idiomatic ClojureScript interface to modern React.js
"Oh god, I just started learning reagent. Don’t tell me I’ll have to switch" /r/clojure
API compatibility: React v18.2.0
UIx v1 is in roman01la/uix repo
Discuss at #uix on Clojurians Slack
yarn add react@18.2.0 react-dom@18.2.0
{:deps {com.pitch/uix.core {:mvn/version "0.9.0"}
com.pitch/uix.dom {:mvn/version "0.9.0"}}}
npx create-uix-app my-app
to scaffold a new project(ns my.app
(:require [uix.core :refer [defui $]]
[uix.dom]))
(defui button [{:keys [on-click children]}]
($ :button.btn {:on-click on-click}
children))
(defui app []
(let [[state set-state!] (uix.core/use-state 0)]
($ :<>
($ button {:on-click #(set-state! dec)} "-")
($ :span state)
($ button {:on-click #(set-state! inc)} "+"))))
(defonce root
(uix.dom/create-root (js/document.getElementById "root")))
(uix.dom/render-root ($ app) root)
scripts/test
Note: to ensure you're using the right Node.js version, you can use nvm and run nvm use
once in the directory. Otherwise the Node.js version you use is in the .nvmrc
file. See nvm repo for more documentation.
core
and dom
packages to Clojarscd core && CLOJARS_PASSWORD={YOUR_CLOJARS_TOKEN} clj -A:release --skip-tag
cd dom && CLOJARS_PASSWORD={YOUR_CLOJARS_TOKEN} clj -A:release --skip-tag
Can you improve this documentation? These fine people already did:
roman01la, Roman Liutikov, DjebbZ, Brandon Stubbs, Karlis Lauva & den1kEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close