Wrapper around react hooks.
Many functions take a deps
argument, corresponding to their React
equivalent. This is an argument which can either be a a vector of
deps or a special keyword:
vector of deps Use specified deps explicitly. :always Re-run hook on every render, equivalent to passing no deps vector to the hook. :once Equivalent to using [] as the deps. :auto-deps Infer the dependencies automatically from the code by finding local vars. Not available for the function form of a hook.
Wrapper around react hooks. Many functions take a `deps` argument, corresponding to their React equivalent. This is an argument which can either be a a vector of deps or a special keyword: vector of deps Use specified deps explicitly. :always Re-run hook on every render, equivalent to passing no deps vector to the hook. :once Equivalent to using [] as the deps. :auto-deps Infer the dependencies automatically from the code by finding local vars. Not available for the function form of a hook.
(use-callback deps & fn-body)
Like react/useCallback. See namespace doc for deps
. fn-body
should
be a code form which returns a function.
Like react/useCallback. See namespace doc for `deps`. `fn-body` should be a code form which returns a function.
(use-callback* f)
(use-callback* f deps)
f
is a function which will be passed to react/useCallback. See
namespace doc for deps
.
`f` is a function which will be passed to react/useCallback. See namespace doc for `deps`.
(use-effect deps & body)
Like react/useEffect. See namespace doc for deps
. body
should be a
code form which will be wrapped in a function and passed to
react/useEffect. If it returns a function, that will be used to clean up.
Unlike react/useEffect, only if you return a function will it be used, you DO NOT need to return js/undefined.
Like react/useEffect. See namespace doc for `deps`. `body` should be a code form which will be wrapped in a function and passed to react/useEffect. If it returns a function, that will be used to clean up. Unlike react/useEffect, only if you return a function will it be used, you DO NOT need to return js/undefined.
(use-effect* f)
(use-effect* f deps)
Like react/useEffect. See use-effect
for details on what f
's return values. See namespace doc for deps
.
Like react/useEffect. See `use-effect` for details on what `f`'s return values. See namespace doc for `deps`.
(use-imperative-handle ref deps & body)
Like react/useImperativeHandle. ref
is unchanged in meaning. See
namespace doc for deps
. body
should be a code form which will be
wrapped in a function.
Like react/useImperativeHandle. `ref` is unchanged in meaning. See namespace doc for `deps`. `body` should be a code form which will be wrapped in a function.
(use-imperative-handle* ref f)
(use-imperative-handle* ref f deps)
Like react/useImperativeHandle. ref
and f
are unchanged in meaning.
See namespace doc for deps
Like react/useImperativeHandle. `ref` and `f` are unchanged in meaning. See namespace doc for `deps`
(use-layout-effect deps & body)
Like use-effect
but instead calls react/useLayoutEffect.
Like `use-effect` but instead calls react/useLayoutEffect.
(use-layout-effect* f)
(use-layout-effect* f deps)
Like use-effect*
but instead calls react/useLayoutEffect.
Like `use-effect*` but instead calls react/useLayoutEffect.
(use-memo deps & body)
Like react/useMemo. See namespace doc for deps
. body
should be a
code form which will be wrapped in a function.
Like react/useMemo. See namespace doc for `deps`. `body` should be a code form which will be wrapped in a function.
(use-memo* f)
(use-memo* f deps)
Like react/useMemo. f
is unchanged in meaning. See namespace doc for
deps
.
Like react/useMemo. `f` is unchanged in meaning. See namespace doc for `deps`.
(use-reducer reducer init-state)
(use-reducer reducer init-state init)
Just react/useReducer.
Just react/useReducer.
(use-ref x)
Like react/useRef. Supports accessing the "current" property via
dereference (@) and updating the "current" property via reset!
and
swap!
Like react/useRef. Supports accessing the "current" property via dereference (@) and updating the "current" property via `reset!` and `swap!`
(use-state initial)
Like react/useState
, but the update function returned can be used similar
to swap!
.
Example:
(let [[state set-state] (use-state {:count 0})]
;; ...
(set-state update :count inc))
Like `react/useState`, but the update function returned can be used similar to `swap!`. Example: ``` (let [[state set-state] (use-state {:count 0})] ;; ... (set-state update :count inc)) ```
(use-subscription {:keys [get-current-value subscribe]})
Hook used for safely managing subscriptions, respecting Clojure equality.
In order to avoid removing and re-adding subscriptions each time this hook is
called, the parameters passed to this hook should be memoized in some way–
either by wrapping the entire params object with use-memo
or by wrapping the
individual callbacks with use-callback
.
Hook used for safely managing subscriptions, respecting Clojure equality. In order to avoid removing and re-adding subscriptions each time this hook is called, the parameters passed to this hook should be memoized in some way– either by wrapping the entire params object with `use-memo` or by wrapping the individual callbacks with `use-callback`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close