Open History to see the last commit
function useAtom<TValue>(atom, options?): [TValue, (fn) => void & (value) => void];
Defined in: node_modules/.pnpm/@tanstack+preact-store@0.13.2_preact@10.29.8/node_modules/@tanstack/preact-store/dist/useAtom.d.ts:22
Returns the current atom value together with a stable 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#
[TValue, (fn) => void & (value) => void]
Example#
const [count, setCount] = useAtom(countAtom)
return (
<button type="button" onClick={() => setCount((prev) => prev + 1)}>
{count}
</button>
)