effect-io-ai

Package: @effect/atom-react
Module: Hooks

Hooks.useAtomValue

Subscribes to an atom in the current React registry and returns its current value, optionally mapped through a selector.

When to use

Use when a React component needs to render from an atom value without also returning a setter.

Details

When a selector is provided, the hook maps the atom before subscribing so the component reads the selected value from the current RegistryContext.

See

Signature

declare const useAtomValue: { <A>(atom: Atom.Atom<A>): A; <A, B>(atom: Atom.Atom<A>, f: (_: A) => B): B; }

Source

Since v4.0.0