Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.react.hooks

Simple wrappers for React hooks support, along with additional predefined functions that do useful things with hooks in the context of Fulcro.

Simple wrappers for React hooks support, along with additional predefined functions that do useful things
with hooks in the context of Fulcro.
raw docstring

use-callbackclj/s

(use-callback cb)
(use-callback cb args)

A simple wrapper around React/useCallback. Converts args to js array before send.

React docs: https://reactjs.org/docs/hooks-reference.html#usecallback

A simple wrapper around React/useCallback. Converts args to js array before send.

React docs: https://reactjs.org/docs/hooks-reference.html#usecallback
sourceraw docstring

use-contextclj/s

(use-context ctx)

A simple wrapper around React/useContext.

A simple wrapper around React/useContext.
sourceraw docstring

use-debug-valueclj/s

(use-debug-value value)
(use-debug-value value formatter)

A simple wrapper around React/useDebugValue.

React docs: https://reactjs.org/docs/hooks-reference.html#uselayouteffect

A simple wrapper around React/useDebugValue.

React docs: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
sourceraw docstring

use-effectclj/smacro

(use-effect f)
(use-effect f dependencies)

A simple macro wrapper around React/useEffect that does compile-time conversion of dependencies to a js-array for convenience without affecting performance.

React docs: https://reactjs.org/docs/hooks-reference.html#useeffect

A simple macro wrapper around React/useEffect that does compile-time conversion of `dependencies` to a js-array
for convenience without affecting performance.

 React docs: https://reactjs.org/docs/hooks-reference.html#useeffect
sourceraw docstring

use-fulcro-mountclj/s

(use-fulcro-mount parent-this {:keys [child-class initial-state-params]})

Generate a new sub-root.

;; important, you must use hooks (`defhc` or `:use-hooks? true`)
(defsc NewRoot [this props]
  {:use-hooks? true}
  (let [f (use-fulcro-mount this {:child-class SomeChild})]
    ;; parent props will show up in SomeChild as computed props.
    (f props)))

WARNING: Requires you use multi-root-renderer.

Generate a new sub-root.

```
;; important, you must use hooks (`defhc` or `:use-hooks? true`)
(defsc NewRoot [this props]
  {:use-hooks? true}
  (let [f (use-fulcro-mount this {:child-class SomeChild})]
    ;; parent props will show up in SomeChild as computed props.
    (f props)))
```

WARNING: Requires you use multi-root-renderer.
sourceraw docstring

use-gcclj/s

(use-gc this-or-app ident edges)

Effect handler. Creates an effect that will garbage-collect the given ident from fulcro app state on cleanup, and will follow any edges (a set of keywords) and remove any things pointed through those keywords as well. See normalized-state's remove-entity.

(defsc NewRoot [this props]
  {:use-hooks? true}
  (let [generated-id (hooks/use-generated-id)
        f (use-fulcro-mount this {:child-class SomeChild
                                  :initial-state-params {:id generated-id})]
    ;; will garbage-collect the floating root child on unmount
    (use-gc this [:child/id generated-id] #{})
    (f props)))
Effect handler. Creates an effect that will garbage-collect the given ident from fulcro app state on cleanup, and
will follow any `edges` (a set of keywords) and remove any things pointed through those keywords as well. See
normalized-state's `remove-entity`.

```
(defsc NewRoot [this props]
  {:use-hooks? true}
  (let [generated-id (hooks/use-generated-id)
        f (use-fulcro-mount this {:child-class SomeChild
                                  :initial-state-params {:id generated-id})]
    ;; will garbage-collect the floating root child on unmount
    (use-gc this [:child/id generated-id] #{})
    (f props)))
```
sourceraw docstring

use-generated-idclj/s

(use-generated-id)

Returns a constant ident with a generated ID component.

Returns a constant ident with a generated ID component.
sourceraw docstring

use-imperative-handleclj/s

(use-imperative-handle ref f)

A simple wrapper around React/useImperativeHandle.

React docs: https://reactjs.org/docs/hooks-reference.html#useimperativehandle

A simple wrapper around React/useImperativeHandle.

React docs: https://reactjs.org/docs/hooks-reference.html#useimperativehandle
sourceraw docstring

use-layout-effectclj/s

(use-layout-effect f)
(use-layout-effect f args)

A simple wrapper around React/useLayoutEffect.

React docs: https://reactjs.org/docs/hooks-reference.html#uselayouteffect

A simple wrapper around React/useLayoutEffect.

React docs: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
sourceraw docstring

use-lifecycleclj/smacro

(use-lifecycle setup)
(use-lifecycle setup teardown)

A macro shorthand that evaulates to low-level js at compile time for (use-effect (fn [] (when setup (setup)) (when teardown teardown)) [])

A macro shorthand that evaulates to low-level js at compile time for
`(use-effect (fn [] (when setup (setup)) (when teardown teardown)) [])`
sourceraw docstring

use-memoclj/s

(use-memo cb)
(use-memo cb args)

A simple wrapper around React/useMemo. Converts args to js array before send.

React docs: https://reactjs.org/docs/hooks-reference.html#usememo

A simple wrapper around React/useMemo. Converts args to js array before send.

React docs: https://reactjs.org/docs/hooks-reference.html#usememo
sourceraw docstring

use-reducerclj/s

(use-reducer reducer initial-arg)
(use-reducer reducer initial-arg init)

A simple wrapper around React/useReducer. Returns a cljs vector for easy destructuring

React docs: https://reactjs.org/docs/hooks-reference.html#usecontext

A simple wrapper around React/useReducer. Returns a cljs vector for easy destructuring

React docs: https://reactjs.org/docs/hooks-reference.html#usecontext
sourceraw docstring

use-refclj/s

(use-ref)
(use-ref value)

A simple wrapper around React/useRef.

React docs: https://reactjs.org/docs/hooks-reference.html#useref

A simple wrapper around React/useRef.

React docs: https://reactjs.org/docs/hooks-reference.html#useref
sourceraw docstring

use-stateclj/s

(use-state initial-value)

A simple wrapper around React/useState. Returns a cljs vector for easy destructuring.

React docs: https://reactjs.org/docs/hooks-reference.html#usestate

A simple wrapper around React/useState. Returns a cljs vector for easy destructuring.

React docs: https://reactjs.org/docs/hooks-reference.html#usestate
sourceraw docstring

useEffectclj/s

(useEffect f)
(useEffect f js-deps)

A CLJC wrapper around js/React.useEffect that does NO conversion of dependencies. You probably want the macro use-effect instead.

React docs: https://reactjs.org/docs/hooks-reference.html#useeffect

A CLJC wrapper around js/React.useEffect that does NO conversion of
dependencies. You probably want the macro use-effect instead.

React docs: https://reactjs.org/docs/hooks-reference.html#useeffect
sourceraw docstring

useStateclj/s

(useState initial-value)

A simple CLJC wrapper around React/useState. Returns a JS vector for speed. You probably want use-state, which is more convenient.

React docs: https://reactjs.org/docs/hooks-reference.html#usestate

A simple CLJC wrapper around React/useState. Returns a JS vector for speed. You probably want use-state, which is more
convenient.

React docs: https://reactjs.org/docs/hooks-reference.html#usestate
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close