Skip to content

Commit

Permalink
Revert "Address issues with firestore collection types. Fixes #180"
Browse files Browse the repository at this point in the history
This reverts commit a22fbd7.
  • Loading branch information
chrisbianca committed Nov 6, 2021
1 parent 94691d0 commit 0a97c0d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions firestore/useCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,52 @@ import {
Options,
} from './types';

export const useCollection = <T>(
query?: Query | null,
export const useCollection = <T = DocumentData>(
query?: Query<T> | null,
options?: Options
): CollectionHook<T> => {
return useCollectionInternal<T>(true, query, options);
};

export const useCollectionOnce = <T>(
query?: Query | null,
export const useCollectionOnce = <T = DocumentData>(
query?: Query<T> | null,
options?: OnceOptions
): CollectionHook<T> => {
return useCollectionInternal<T>(false, query, options);
};

export const useCollectionData = <
T,
T = DocumentData,
IDField extends string = '',
RefField extends string = ''
>(
query?: Query | null,
query?: Query<T> | null,
options?: DataOptions<T>
): CollectionDataHook<T, IDField, RefField> => {
return useCollectionDataInternal<T, IDField, RefField>(true, query, options);
};

export const useCollectionDataOnce = <
T,
T = DocumentData,
IDField extends string = '',
RefField extends string = ''
>(
query?: Query | null,
query?: Query<T> | null,
options?: OnceDataOptions<T>
): CollectionDataHook<T, IDField, RefField> => {
return useCollectionDataInternal<T, IDField, RefField>(false, query, options);
};

const useCollectionInternal = <T>(
const useCollectionInternal = <T = DocumentData>(
listen: boolean,
query?: Query | null,
query?: Query<T> | null,
options?: Options & OnceOptions
) => {
const { error, loading, reset, setError, setValue, value } = useLoadingValue<
QuerySnapshot,
QuerySnapshot<T>,
FirestoreError
>();
const ref = useIsFirestoreQueryEqual<Query>(query, reset);
const ref = useIsFirestoreQueryEqual<Query<T>>(query, reset);

useEffect(() => {
if (!ref.current) {
Expand Down Expand Up @@ -105,12 +105,12 @@ const useCollectionInternal = <T>(
};

const useCollectionDataInternal = <
T,
T = DocumentData,
IDField extends string = '',
RefField extends string = ''
>(
listen: boolean,
query?: Query | null,
query?: Query<T> | null,
options?: DataOptions<T> & OnceDataOptions<T>
): CollectionDataHook<T, IDField, RefField> => {
const idField = options ? options.idField : undefined;
Expand Down

0 comments on commit 0a97c0d

Please sign in to comment.