Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

useAtom.md

41 lines802 Bytes

1---
2id: useAtom
3title: useAtom
4---
5​
6```ts
7function useAtom<TValue>(atom, options?): [TValue, (fn) => void & (value) => void];
8```
9​
10Defined in: node\_modules/.pnpm/@tanstack+react-store@0.11.0\_react-dom@19.2.8\_react@19.2.8\_\_react@19.2.8/node\_modules/@tanstack/react-store/dist/useAtom.d.ts:16
11​
12Returns the current atom value together with a stable setter.
13​
14This is the writable-atom convenience hook for components that need to both
15read and update the same atom.
16​
17## Type Parameters
18​
19### TValue
20​
21`TValue`
22​
23## Parameters
24​
25### atom
26​
27[`Atom`](../interfaces/Atom.md)\<`TValue`\>
28​
29### options?
30​
31[`UseSelectorOptions`](../interfaces/UseSelectorOptions.md)\<`TValue`\>
32​
33## Returns
34​
35\[`TValue`, (`fn`) => `void` & (`value`) => `void`\]
36​
37## Example
38​
39```tsx
40const [count, setCount] = useAtom(countAtom)
41```