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.
- package/dist/src/firestore/useCollectionReference.d.ts +1 -1
- package/dist/src/firestore/useCollectionReference.js +1 -1
- package/dist/src/firestore/useDocReference.d.ts +1 -1
- package/dist/src/firestore/useDocReference.js +2 -2
- package/package.json +1 -1
- package/src/firestore/useCollectionReference.ts +12 -4
- package/src/firestore/useDocReference.ts +3 -3
|
@@ -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<
|
|
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
|
-
}, [
|
|
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
|
@@ -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(
|
|
39
|
-
|
|
40
|
-
|
|
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
|
};
|