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

Function useAtomInitialValues

packages/atom/react/src/Hooks.ts:78–91  ·  view source on GitHub ↗
(initialValues: Iterable<readonly [Atom.Atom<any>, any]>)

Source from the content-addressed store, hash-verified

76 * @since 4.0.0
77 */
78export const useAtomInitialValues = (initialValues: Iterable<readonly [Atom.Atom<any>, any]>): void => {
79 const registry = React.useContext(RegistryContext)
80 let set = initialValuesSet.get(registry)
81 if (set === undefined) {
82 set = new WeakSet()
83 initialValuesSet.set(registry, set)
84 }
85 for (const [atom, value] of initialValues) {
86 if (!set.has(atom)) {
87 set.add(atom)
88 ;(registry as any).ensureNode(atom).setValue(value)
89 }
90 }
91}
92
93/**
94 * Subscribes to an atom in the current React registry and returns its current

Callers

nothing calls this directly

Calls 6

ensureNodeMethod · 0.80
getMethod · 0.65
setMethod · 0.65
addMethod · 0.65
hasMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected