You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ClojureScript optimized for modern React development.
(nsmy-app.core
(:require [helix.core :refer [defnc $]]
[helix.hooks :as hooks]
[helix.dom :as d]
["react-dom/client":as rdom]))
;; define components using the `defnc` macro
(defncgreeting"A component which greets a user."
[{:keys [name]}]
;; use helix.dom to create DOM elements
(d/div"Hello, " (d/strong name) "!"))
(defncapp []
(let [[state set-state] (hooks/use-state {:name"Helix User"})]
(d/div
(d/h1"Welcome!")
;; create elements out of components
($ greeting {:name (:name state)})
(d/input {:value (:name state)
:on-change #(set-state assoc :name (.. % -target -value))}))))
;; start your app with your favorite React renderer
(defonceroot (rdom/createRoot (js/document.getElementById"app")))
(.render root ($ app))
Installation
Install the latest version from clojars in your project.
Install JS dependencies:
npm init # initialize NPM project if necessary
npm i react react-refresh # install react, and react-refresh for hot reloading support (see docs)
npm i react-dom # install renderer. alternatives could be react-native, react-three-fiber, etc.