API reference > @kontsedal/olas-react > useValue
useValue() function
Subscribe to a single read-signal and return its current value. AnyReadSignal works: a signal, a computed, a Field, a Form or aFieldArray.
Built on useSyncExternalStore — concurrent-safe, no tearing. Use this when a component depends on one signal; for Field<T> and AsyncState<T>, prefer useField and useQuery which batch multiple subscribes into one render trigger.
Optional select projects the signal value into a derived slice; isEqual (default Object.is) controls when React re-renders. Combine to subscribe to a slice of an object-shaped signal without re-rendering on unrelated changes:
ts
const name = useValue(userSignal, { select: u => u.name })
const tags = useValue(postSignal, {
select: p => p.tags,
isEqual: (a, b) => a.length === b.length && a.every((x, i) => x === b[i]),
})Signature:
typescript
export declare function useValue<T, U>(signal: ReadSignal<T>, options: UseValueSelectOptions<T, U>): U;Parameters
Parameter | Type | Description |
|---|---|---|
signal | ReadSignal<T> | |
options | UseValueSelectOptions<T, U> |
Returns:
U