react-query-firebase 2.0.0-rc3 → 2.0.0-rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,4 +15,4 @@ export type UseCollectionReferenceOptions<AppModelType extends FirebaseFirestore
15
15
  * @param {string[]} options.pathSegments - Additional path segments to append to the base path.
16
16
  * @returns {CollectionReference} A Firestore collection reference constructed using the specified path, reference, and path segments.
17
17
  */
18
- export declare const useCollectionReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseCollectionReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.CollectionReference<FirebaseFirestoreTypes.DocumentData>;
18
+ export declare const useCollectionReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseCollectionReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.CollectionReference<AppModelType> | null;
@@ -18,5 +18,5 @@ export const useCollectionReference = ({ path, reference, pathSegments }) => {
18
18
  return !reference
19
19
  ? collection(db, path || "", ...(pathSegments || []))
20
20
  : collection(reference, path, ...(pathSegments || []));
21
- }, [path, reference?.path, pathSegments]);
21
+ }, [db, reference, path, pathSegments]);
22
22
  };
@@ -14,6 +14,6 @@ export type UseDocReferenceOptions<AppModelType extends FirebaseFirestoreTypes.D
14
14
  * @param {DbModelType} options.reference - Reference data for the document, providing additional context or specifics.
15
15
  * @param {string[]} options.pathSegments - Parts of the path to construct the full document path dynamically.
16
16
  *
17
- * @returns {DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
17
+ * @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
18
18
  */
19
19
  export declare const useDocReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseDocReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
@@ -29,13 +29,13 @@ const getDocReference = (db, { path, pathSegments, reference }) => {
29
29
  * @param {DbModelType} options.reference - Reference data for the document, providing additional context or specifics.
30
30
  * @param {string[]} options.pathSegments - Parts of the path to construct the full document path dynamically.
31
31
  *
32
- * @returns {DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
32
+ * @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
33
33
  */
34
34
  export const useDocReference = ({ path, reference, pathSegments }) => {
35
35
  const db = useFirestore();
36
36
  const ref = useRef(getDocReference(db, { path, pathSegments, reference }));
37
37
  useEffect(() => {
38
38
  ref.current = getDocReference(db, { path, pathSegments, reference });
39
- }, [path, reference, pathSegments]);
39
+ }, [db, path, reference, pathSegments]);
40
40
  return ref.current;
41
41
  };
package/package.json CHANGED
@@ -70,5 +70,5 @@
70
70
  "docs:build": "vitepress build docs",
71
71
  "docs:preview": "vitepress preview docs"
72
72
  },
73
- "version": "2.0.0-rc3"
73
+ "version": "2.0.0-rc4"
74
74
  }
@@ -30,12 +30,20 @@ export const useCollectionReference = <
30
30
  path,
31
31
  reference,
32
32
  pathSegments
33
- }: UseCollectionReferenceOptions<AppModelType>) => {
33
+ }: UseCollectionReferenceOptions<AppModelType>): FirebaseFirestoreTypes.CollectionReference<AppModelType> | null => {
34
34
  const db = useFirestore();
35
35
 
36
36
  return useMemo(() => {
37
37
  return !reference
38
- ? collection(db, path || "", ...(pathSegments || []))
39
- : collection(reference, path, ...(pathSegments || []));
40
- }, [path, reference?.path, pathSegments]);
38
+ ? (collection(
39
+ db,
40
+ path || "",
41
+ ...(pathSegments || [])
42
+ ) as FirebaseFirestoreTypes.CollectionReference<AppModelType>)
43
+ : (collection(
44
+ reference,
45
+ path,
46
+ ...(pathSegments || [])
47
+ ) as FirebaseFirestoreTypes.CollectionReference<AppModelType>);
48
+ }, [db, reference, path, pathSegments]);
41
49
  };
@@ -50,7 +50,7 @@ const getDocReference = <
50
50
  * @param {DbModelType} options.reference - Reference data for the document, providing additional context or specifics.
51
51
  * @param {string[]} options.pathSegments - Parts of the path to construct the full document path dynamically.
52
52
  *
53
- * @returns {DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
53
+ * @returns {FirebaseFirestoreTypes.DocumentReference<AppModelType> | null} The Firestore document reference corresponding to the provided path and options, or null if not initialized.
54
54
  */
55
55
  export const useDocReference = <
56
56
  AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData
@@ -58,7 +58,7 @@ export const useDocReference = <
58
58
  path,
59
59
  reference,
60
60
  pathSegments
61
- }: UseDocReferenceOptions<AppModelType>) => {
61
+ }: UseDocReferenceOptions<AppModelType>): FirebaseFirestoreTypes.DocumentReference<AppModelType> | null => {
62
62
  const db = useFirestore();
63
63
  const ref = useRef<FirebaseFirestoreTypes.DocumentReference<AppModelType> | null>(
64
64
  getDocReference(db, { path, pathSegments, reference })
@@ -66,7 +66,7 @@ export const useDocReference = <
66
66
 
67
67
  useEffect(() => {
68
68
  ref.current = getDocReference(db, { path, pathSegments, reference });
69
- }, [path, reference, pathSegments]);
69
+ }, [db, path, reference, pathSegments]);
70
70
 
71
71
  return ref.current;
72
72
  };