react-query-firebase 3.3.3 → 3.5.0

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.
@@ -10,6 +10,7 @@ export type FirebaseContextValue = {
10
10
  firebase: FirebaseApp;
11
11
  remoteConfig: FirebaseRemoteConfigTypes.Module;
12
12
  firestore: Firestore;
13
+ isFIrestoreReady: boolean;
13
14
  messaging: Messaging;
14
15
  };
15
16
  /**
@@ -79,6 +79,11 @@ export type FirebaseContextProviderProps = PropsWithChildren & {
79
79
  * @defaultValue {}
80
80
  */
81
81
  firestoreSettings?: FirestoreSettings;
82
+ /**
83
+ * Specifies custom firestore database identifier
84
+ * @defaultValue `(default)`
85
+ */
86
+ firestoreDBId?: string;
82
87
  /**
83
88
  * Flag indicating whether Firebase Firestore should be enabled.
84
89
  * @defaultValue `true`
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo } from "react";
1
+ import React, { useEffect, useMemo, useState } from "react";
2
2
  import { connectAuthEmulator, getAuth } from "@react-native-firebase/auth";
3
3
  import { getMessaging } from "@react-native-firebase/messaging";
4
4
  import { setAnalyticsCollectionEnabled, setConsent, getAnalytics } from "@react-native-firebase/analytics";
@@ -29,8 +29,9 @@ import { FirebaseContext } from "./FirebaseContext.js";
29
29
  * };
30
30
  * ```
31
31
  */
32
- export const FirebaseContextProvider = ({ emulators, children, authEnabled = true, firestoreEnabled = true, analyticsEnabled = true, consentSettings = {}, remoteConfigEnabled = true, remoteConfigSettings, remoteConfigDefaults = {}, firestoreSettings }) => {
32
+ export const FirebaseContextProvider = ({ emulators, children, authEnabled = true, firestoreEnabled = true, analyticsEnabled = true, consentSettings = {}, remoteConfigEnabled = true, remoteConfigSettings, remoteConfigDefaults = {}, firestoreSettings, firestoreDBId = "(default)" }) => {
33
33
  const internalFirebase = useMemo(() => getApp(), []);
34
+ const [isFIrestoreReady, setIsFirestoreReady] = useState(false);
34
35
  useEffect(() => {
35
36
  setConsent(getAnalytics(internalFirebase), {
36
37
  ad_personalization: false,
@@ -44,18 +45,20 @@ export const FirebaseContextProvider = ({ emulators, children, authEnabled = tru
44
45
  });
45
46
  }, [consentSettings, internalFirebase]);
46
47
  useEffect(() => {
47
- initializeFirestore(internalFirebase, firestoreSettings || {});
48
+ initializeFirestore(internalFirebase, firestoreSettings || {}).then(() => {
49
+ setIsFirestoreReady(true);
50
+ });
48
51
  }, [firestoreSettings, internalFirebase]);
49
52
  const internalFirestore = useMemo(() => {
50
- if (firestoreEnabled) {
53
+ if (firestoreEnabled && isFIrestoreReady) {
51
54
  if (emulators?.firestore?.host && emulators?.firestore?.port) {
52
55
  connectFirestoreEmulator(getFirestore(internalFirebase), emulators.firestore.host, emulators.firestore.port);
53
56
  }
54
- const localFirestore = getFirestore(internalFirebase);
57
+ const localFirestore = getFirestore(internalFirebase, firestoreDBId);
55
58
  return localFirestore;
56
59
  }
57
60
  return null;
58
- }, [emulators, firestoreEnabled, internalFirebase]);
61
+ }, [emulators, firestoreEnabled, internalFirebase, firestoreDBId, isFIrestoreReady]);
59
62
  const internalAuth = useMemo(() => {
60
63
  if (authEnabled) {
61
64
  const localAuth = getAuth(internalFirebase);
@@ -92,8 +95,9 @@ export const FirebaseContextProvider = ({ emulators, children, authEnabled = tru
92
95
  analytics: internalAnalytics,
93
96
  firestore: internalFirestore,
94
97
  remoteConfig: internalRemoteConfig,
95
- messaging: getMessaging(internalFirebase)
96
- }), [internalFirebase, internalAuth, internalAnalytics, internalFirestore, internalRemoteConfig]);
98
+ messaging: getMessaging(internalFirebase),
99
+ isFIrestoreReady
100
+ }), [internalFirebase, internalAuth, internalAnalytics, internalFirestore, internalRemoteConfig, isFIrestoreReady]);
97
101
  useEffect(() => {
98
102
  if (contextValue.analytics) {
99
103
  setAnalyticsCollectionEnabled(contextValue.analytics, !!consentSettings?.analytics_storage);
@@ -84,6 +84,11 @@ export type FirebaseContextProviderProps = PropsWithChildren & {
84
84
  * @defaultValue `true`
85
85
  */
86
86
  firestoreEnabled?: boolean;
87
+ /**
88
+ * Specifies custom firestore database identifier
89
+ * @defaultValue `(default)`
90
+ */
91
+ firestoreDBId?: string;
87
92
  /**
88
93
  * Configuration options for Firebase Remote Config Settings. {@link https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings | Learn about the Firebase Remote COnfig Settings object}
89
94
  * @defaultValue `true`
@@ -29,7 +29,7 @@ import { FirebaseContext } from "./FirebaseContext.js";
29
29
  * };
30
30
  * ```
31
31
  */
32
- export const FirebaseContextProvider = ({ emulators, options, children, authEnabled = true, firestoreEnabled = true, analyticsEnabled = true, consentSettings = {}, remoteConfigEnabled = true, remoteConfigSettings, remoteConfigDefaults = {}, firestoreSettings, authPersistenceType }) => {
32
+ export const FirebaseContextProvider = ({ emulators, options, children, authEnabled = true, firestoreEnabled = true, analyticsEnabled = true, consentSettings = {}, remoteConfigEnabled = true, remoteConfigSettings, remoteConfigDefaults = {}, firestoreSettings, authPersistenceType, firestoreDBId = "(default)" }) => {
33
33
  const firebase = useMemo(() => {
34
34
  return initializeApp(options);
35
35
  }, [options]);
@@ -47,14 +47,14 @@ export const FirebaseContextProvider = ({ emulators, options, children, authEnab
47
47
  }, [consentSettings]);
48
48
  const firestore = useMemo(() => {
49
49
  if (firestoreEnabled) {
50
- const localFirestore = initializeFirestore(firebase, firestoreSettings || {});
50
+ const localFirestore = initializeFirestore(firebase, firestoreSettings || {}, firestoreDBId);
51
51
  if (emulators?.firestore?.host && emulators?.firestore?.port) {
52
52
  connectFirestoreEmulator(localFirestore, emulators.firestore.host, emulators.firestore.port);
53
53
  }
54
54
  return localFirestore;
55
55
  }
56
56
  return null;
57
- }, [firestoreSettings, emulators, firestoreEnabled, firebase]);
57
+ }, [firestoreSettings, emulators, firestoreEnabled, firebase, firestoreDBId]);
58
58
  const authPersistence = useMemo(() => {
59
59
  switch (authPersistenceType) {
60
60
  case "NONE":
@@ -108,7 +108,8 @@ export const FirebaseContextProvider = ({ emulators, options, children, authEnab
108
108
  analytics,
109
109
  firestore,
110
110
  remoteConfig,
111
- messaging: getMessaging(firebase)
111
+ messaging: getMessaging(firebase),
112
+ isFIrestoreReady: true
112
113
  }), [firebase, auth, analytics, firestore, remoteConfig]);
113
114
  useEffect(() => {
114
115
  if (contextValue.analytics) {
package/package.json CHANGED
@@ -31,26 +31,26 @@
31
31
  "@react-native-firebase/installations": "^24.0.0",
32
32
  "@react-native-firebase/messaging": "^24.0.0",
33
33
  "@react-native-firebase/remote-config": "^24.0.0",
34
- "@tanstack/react-query": "^5.99.2",
34
+ "@tanstack/react-query": "^5.100.11",
35
35
  "@types/react": "^19.2.14",
36
36
  "eslint": "^9.39.4",
37
37
  "eslint-config-prettier": "^10.1.8",
38
38
  "eslint-plugin-import": "^2.32.0",
39
39
  "eslint-plugin-jest": "^29.15.2",
40
- "eslint-plugin-jsonc": "^2.21.1",
40
+ "eslint-plugin-jsonc": "^3.1.2",
41
41
  "eslint-plugin-prettier": "^5.5.5",
42
42
  "eslint-plugin-react": "^7.37.5",
43
43
  "eslint-plugin-react-hooks": "^7.1.1",
44
- "firebase": "^12.12.1",
44
+ "firebase": "^12.13.0",
45
45
  "husky": "^9.1.7",
46
- "lint-staged": "^16.4.0",
46
+ "lint-staged": "^17.0.5",
47
47
  "prettier": "^3.8.3",
48
- "react": "^19.2.5",
48
+ "react": "^19.2.6",
49
49
  "typedoc": "^0.28.19",
50
50
  "typedoc-plugin-markdown": "^4.11.0",
51
51
  "typedoc-vitepress-theme": "^1.1.2",
52
52
  "typescript": "^5.9.3",
53
- "typescript-eslint": "^8.59.0",
53
+ "typescript-eslint": "^8.59.4",
54
54
  "vitepress": "^1.6.4"
55
55
  },
56
56
  "homepage": "https://github.com/vpishuk/react-query-firebase",
@@ -93,5 +93,5 @@
93
93
  "docs:build": "vitepress build docs",
94
94
  "docs:preview": "vitepress preview docs"
95
95
  },
96
- "version": "3.3.3"
96
+ "version": "3.5.0"
97
97
  }