UNPKG

958 BTypeScriptView Raw
1import type { Atom, ExtractAtomArgs, ExtractAtomResult, ExtractAtomValue, WritableAtom } from 'jotai/vanilla';
2import { useAtomValue } from './useAtomValue';
3type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
4type Options = Parameters<typeof useAtomValue>[1];
5export declare function useAtom<Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, options?: Options): [Awaited<Value>, SetAtom<Args, Result>];
6export declare function useAtom<Value>(atom: Atom<Value>, options?: Options): [Awaited<Value>, never];
7export declare function useAtom<AtomType extends WritableAtom<unknown, unknown[], unknown>>(atom: AtomType, options?: Options): [
8 Awaited<ExtractAtomValue<AtomType>>,
9 SetAtom<ExtractAtomArgs<AtomType>, ExtractAtomResult<AtomType>>
10];
11export declare function useAtom<AtomType extends Atom<unknown>>(atom: AtomType, options?: Options): [Awaited<ExtractAtomValue<AtomType>>, never];
12export {};