Skip to content
/ uix Public
forked from roman01la/uix

Idiomatic ClojureScript interface to modern React.js

License

Notifications You must be signed in to change notification settings

pitch-io/uix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

CircleCI Clojars Project Clojars Project

Installation

npm install react@18.3.1 react-dom@18.3.1 --save-dev
{:deps {com.pitch/uix.core {:mvn/version "1.2.0"}
        com.pitch/uix.dom {:mvn/version "1.2.0"}}}

How to start a new project with UIx

Usage

(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)

Docs

Who's using UIx?

Contributing

There are several ways how you can contribute to the project:

  • Improve documentation: cover missing pieces, add code examples
  • Add, improve docstrings
  • Propose and implement improvements and new features
  • File and fix bugs
  • Increase test coverage

Support

You can support this project via Github Sponsors or Buy Me a Coffee.

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.

Thanks to

  • UIx v1 for initial set of ideas and learnings
  • Helix for even more ideas
  • Pitch for sponsoring initial development and dogfooding the work

Languages

  • Clojure 99.3%
  • Other 0.7%