Call Signature#
function useCreateAtom<T>(getValue, options?): ReadonlyAtom<T>;
Defined 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/useCreateAtom.d.ts:16
Creates a stable atom instance for the lifetime of the component.
Pass an initial value to create a writable atom, or a getter function to create a readonly derived atom. This hook mirrors the overloads from createAtom, but ensures the atom is only created once per mount.
Type Parameters#
T#
T
Parameters#
getValue#
(prev?) => T
options?#
AtomOptions<T>
Returns#
ReadonlyAtom<T>
Example#
const countAtom = useCreateAtom(0)
Call Signature#
function useCreateAtom<T>(initialValue, options?): Atom<T>;
Defined 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/useCreateAtom.d.ts:17
Creates a stable atom instance for the lifetime of the component.
Pass an initial value to create a writable atom, or a getter function to create a readonly derived atom. This hook mirrors the overloads from createAtom, but ensures the atom is only created once per mount.
Type Parameters#
T#
T
Parameters#
initialValue#
T
options?#
AtomOptions<T>
Returns#
Atom<T>
Example#
const countAtom = useCreateAtom(0)