function useAtom<TValue>(atom, options?): [TValue, (fn) => void & (value) => void];function useAtom<TValue>(atom, options?): [TValue, (fn) => void & (value) => void];Defined in: preact-store/src/useAtom.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.
TValue
Atom<TValue>
UseSelectorOptions<TValue>
[TValue, (fn) => void & (value) => void]
const [count, setCount] = useAtom(countAtom)
return (
<button type="button" onClick={() => setCount((prev) => prev + 1)}>
{count}
</button>
)const [count, setCount] = useAtom(countAtom)
return (
<button type="button" onClick={() => setCount((prev) => prev + 1)}>
{count}
</button>
)