react-firebase-hooks
Version:
React Hooks for Firebase
74 lines (70 loc) • 1.83 kB
Flow
// @flow
import type {
DocumentReference,
DocumentSnapshot,
GetOptions,
Query,
QuerySnapshot,
SnapshotListenOptions,
} from 'firebase/firestore';
type LoadingHook<T> = [T | void, boolean, Error | void];
export type CollectionHook = LoadingHook<QuerySnapshot>;
export type CollectionDataHook<T> = LoadingHook<T[]>;
export type DocumentHook = LoadingHook<DocumentSnapshot>;
export type DocumentDataHook<T> = LoadingHook<T>;
declare export function useCollection(
query?: Query | null,
options?: {
snapshotListenOptions?: SnapshotListenOptions,
}
): CollectionHook;
declare export function useCollectionOnce(
query?: Query | null,
options?: {
getOptions?: GetOptions,
}
): CollectionHook;
declare export function useCollectionData<T>(
query?: Query | null,
options?: {
idField?: string,
refField?: string,
snapshotListenOptions?: SnapshotListenOptions,
}
): CollectionDataHook<T>;
declare export function useCollectionDataOnce<T>(
query?: Query | null,
options?: {
getOptions?: GetOptions,
idField?: string,
refField?: string,
}
): CollectionDataHook<T>;
declare export function useDocument(
ref?: DocumentReference | null,
options?: {
snapshotListenOptions?: SnapshotListenOptions,
}
): DocumentHook;
declare export function useDocumentOnce(
ref?: DocumentReference | null,
options?: {
getOptions?: GetOptions,
}
): DocumentHook;
declare export function useDocumentData<T>(
ref?: DocumentReference | null,
options?: {
idField?: string,
refField?: string,
snapshotListenOptions?: SnapshotListenOptions,
}
): DocumentDataHook<T>;
declare export function useDocumentDataOnce<T>(
ref?: DocumentReference | null,
options?: {
getOptions?: GetOptions,
idField?: string,
refField?: string,
}
): DocumentDataHook<T>;