hx
fully embraces vanilla React development; it does not provide any
additional functionality than the core React library.
However, React already provides a rich API for doing state management and other common effects in a UI application: React Hooks.
React Hooks are a powerful system for representing side effects we want to occur while our application is operating such as changing state, firing network requests, subscribing to external sources, etc.
hx
provides a small helper library called hx.hooks
that offers a
Clojure-first API to the React Hooks API.
You may also leverage any Hooks libraries that you may find, since hx
components are pure React components that are compatible with all of the
external React ecosystem.
The idiom that this library provides is: any Hook starts with <-
(instead of use
) to provide at-a-glance recognition of what Hooks a component
uses.
Anything missing from here can also be accessed via the React library, e.g.:
(react/useMemo)
.
All of the Rules of Hooks apply.
Takes an initial value. Returns an atom that will re-render component on change.
Takes an initial value. Returns an atom that will NOT re-render component on change.
Takes an atom. Returns the currently derefed value of the atom, and re-renders the component on change.
Just react/useReducer.
Just react/useEffect.
deps
can be a CLJS collection.
Just react/useContext.
Just react/useMemo.
deps
can be a CLJS collection.
Just react/useCallback.
Just react/useImperativeHandle.
deps
can be a CLJS collection.
Just react/useLayoutEffect.
deps
can be a CLJS collection.
Just react/useDebugValue.
deps
can be a CLJS collection.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close