brandonstubbs / uix

Idiomatic ClojureScript interface to modern React.js

Home Page:https://github.com/pitch-io/uix#docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idiomatic ClojureScript interface to modern React.js

API compatibility: React v17

UIx v1 is in roman01la/uix repo

Discuss at #uix on Clojurians Slack

CircleCI Clojars Project Clojars Project

Installation

yarn add react@17.0.2 react-dom@17.0.2
{:deps {com.pitch/uix.core {:mvn/version "0.3.0"}
        com.pitch/uix.dom {:mvn/version "0.3.0"}}}

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)} "+"))))

(uix.dom/render ($ app) (js/document.getElementById "root"))

Docs

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 and dogfooding the work

About

Idiomatic ClojureScript interface to modern React.js

https://github.com/pitch-io/uix#docs

License:Eclipse Public License 2.0


Languages

Language:Clojure 97.9%Language:JavaScript 1.4%Language:Shell 0.7%