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

useAtom.md

44 lines860 Bytes

function useAtom<TValue>(atom, options?): [Readonly<Ref<TValue, TValue>>, (fn) => void & (value) => void];

Defined in: node_modules/.pnpm/@tanstack+vue-store@0.11.1_vue@3.6.0-rc.9_typescript@6.0.3_/node_modules/@tanstack/vue-store/dist/useAtom.d.ts:20

Returns the current atom ref together with a setter.

Use this when a component needs to both read and update the same writable atom.

Type Parameters

TValue

TValue

Parameters

atom

Atom<TValue>

options?

UseSelectorOptions<TValue>

Returns

[Readonly<Ref<TValue, TValue>>, (fn) => void & (value) => void]

Example

const [count, setCount] = useAtom(countAtom)

setCount((prev) => prev + 1)
console.log(count.value)