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

Function useAtomRef

packages/atom/solid/src/Hooks.ts:294–302  ·  view source on GitHub ↗
(ref: () => AtomRef.ReadonlyRef<A>)

Source from the content-addressed store, hash-verified

292 * @since 4.0.0
293 */
294export const useAtomRef = <A>(ref: () => AtomRef.ReadonlyRef<A>): Accessor<A> => {
295 const [value, setValue] = createSignal(null as A)
296 createComputed(() => {
297 const r = ref()
298 setValue(r.value as any)
299 onCleanup(r.subscribe(setValue))
300 })
301 return value
302}
303
304/**
305 * Returns a Solid accessor for a property ref derived from an atom ref.

Callers 2

useAtomRefPropValueFunction · 0.70
renderAtomRefFunction · 0.50

Calls 2

subscribeMethod · 0.65
refFunction · 0.50

Tested by 1

renderAtomRefFunction · 0.40