/uix

Idiomatic ClojureScript interface to modern React.js

Primary LanguageHTMLEclipse Public License 2.0EPL-2.0

Idiomatic ClojureScript interface to modern React.js

Docs and Guides

CircleCI

{:deps {uix.core {:git/url "https://github.com/pitch-io/uix.git"
                  :deps/root "core"
                  :sha "de150bc794fa50d7c3e1de2d1950561a27261362"}
        uix.dom {:git/url "https://github.com/pitch-io/uix.git"
                 :deps/root "dom"
                 :sha "de150bc794fa50d7c3e1de2d1950561a27261362"}
        uix.rn {:git/url "https://github.com/pitch-io/uix.git"
                :deps/root "rn"
                :sha "de150bc794fa50d7c3e1de2d1950561a27261362"}}}
(ns my.app
  (:require [uix.core :refer [defui]]
            [uix.dom]))

(defui button [{:keys [on-click children]}]
  #el [:button.btn {:on-click on-click}
        children])

(defui app []
  (let [[state set-state!] (uix.core/use-state 0)]
    #el [:<>
      #el [button {:on-click #(set-state! dec)} "-"]
      #el [:span state]
      #el [button {:on-click #(set-state! inc)} "+"]]))

(uix.dom/render #el [app] (js/document.getElementById "root"))

Testing

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.