reagent.hooks

use-action-state

(use-action-state f initial-state)(use-action-state f initial-state permalink)
Update state based on the result of a form action.

use-callback

(use-callback f dependencies)
Cache a function between re-renders.

Differences to React.js:
- Dependency comparison is using clojure equality vs React.js uses `Object.is` which would
  only work for JS primitive values.

use-clj-deps

(use-clj-deps deps)
Check the new clj deps value against the previous value, stored in a
ref hook, so we can use clj equality check to see if the value changed.

Only not= value is stored to the ref, so the effect dependency value
only updates when the equality changed.

use-context

(use-context ctx)
Read and subscribe to React Context.

use-debug-value

(use-debug-value value)(use-debug-value value format)
Add a label to custom Hook in React Devtools.

use-deferred-value

(use-deferred-value value)
Defer updating a part of the UI.

use-effect

(use-effect setup)(use-effect setup dependencies)
Run side-effect on component mount or dependency changes.

If the setup fn returns a function, that will be used as a cleanup function,
and will run on unmount, or when depenendecies changes.

Dependency changes consider Clojure value equality, i.e., you can use
clojure maps and other data structures in the dependencies vector.

Differences to React.js:
- Any non-fn return value from setup fn is considered to mean no cleanup fn is used,
  vs React.js requires `undefined` to be returned.
- Dependency comparison is using clojure equality vs React.js uses `Object.is` which would
  only work for JS primitive values.

use-id

(use-id)
Generate unique ID that can be passed to accessibility attributes.

use-imperative-handle

(use-imperative-handle ref create-handler)(use-imperative-handle ref create-handler dependencies)
Customize the handle exposed as a ref.

use-layout-effect

(use-layout-effect setup)(use-layout-effect setup dependencies)
Version of use-effect that fires before the browser repaints the screen.

If the setup fn returns a function, that will be used as a cleanup function,
and will run on unmount, or when depenendecies changes.

Dependency changes consider Clojure value equality, i.e., you can use
clojure maps and other data structures in the dependencies vector.

Differences to React.js:
- Any non-fn return value from setup fn is considered to mean no cleanup fn is used,
  vs React.js requires `undefined` to be returned.
- Dependency comparison is using clojure equality vs React.js uses `Object.is` which would
  only work for JS primitive values.

use-memo

(use-memo calculate-value dependencies)
Cache the result of a calculation between re-renders.

Dependency changes consider Clojure value equality, i.e., you can use
clojure maps and other data structures in the dependencies vector.

Differences to React.js:
- Dependency comparison is using clojure equality vs React.js uses `Object.is` which would
  only work for JS primitive values.

use-optimistic

(use-optimistic state update-fn)
Optimistically update the UI

use-reducer

(use-reducer reducer initial-arg)(use-reducer reducer initial-arg init)
Create a state store that is updated by calling reducer with the current
state and a dispatch event.

Differences to React.js:
- The result of reducer fn is compared to the previous state value using
  clojure equality check, and if the value is equal, the previous state
  is kept. This ensures React.js `Object.is` check for checking if the
  state changed works.

use-ref

(use-ref v)
Keep a reference to a value that is not needed for rendering.

use-state

(use-state initial-state)
Create a state store

Differences to React.js:
- The new state is compared to the old state using clojure equality,
  and if the value is equal, the previous state is kept. This
  ensures React.js `Object.is` check for checking if the state
  changed works.

use-sync-external-store

(use-sync-external-store subscribe get-snapshot)(use-sync-external-store subscribe get-snapshot get-server-snapshot)
Subscribe to an external store.

use-transition

(use-transition)
Render a part of the UI in the background.

with-return-value-check

(with-return-value-check f)
Consider any non-fn value from effect callbacks as no callback.