MCPcopy Create free account
hub / github.com/Effect-TS/effect / useAtomRef

Function useAtomRef

packages/atom/react/src/Hooks.ts:437–441  ·  view source on GitHub ↗
(ref: AtomRef.ReadonlyRef<A>)

Source from the content-addressed store, hash-verified

435 * @since 4.0.0
436 */
437export const useAtomRef = <A>(ref: AtomRef.ReadonlyRef<A>): A => {
438 const [, setValue] = React.useState(ref.value)
439 React.useEffect(() => ref.subscribe(setValue), [ref])
440 return ref.value
441}
442
443/**
444 * Returns a memoized atom ref for a property of another atom ref.

Callers 1

useAtomRefPropValueFunction · 0.70

Calls 1

subscribeMethod · 0.65

Tested by

no test coverage detected