| 76 | * @since 4.0.0 |
| 77 | */ |
| 78 | export 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 |