react-query-firebase 2.0.0-rc5 → 2.0.0-rc7

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.
Files changed (274) hide show
  1. package/package.json +16 -13
  2. package/{dist/src → react-native}/firestore/useCollectionReference.d.ts +1 -1
  3. package/{src → react-native}/firestore/useCollectionReference.ts +1 -1
  4. package/{dist/src → react-native}/firestore/useDocReference.d.ts +1 -1
  5. package/{dist/src → react-native}/firestore/useDocReference.js +4 -9
  6. package/{src → react-native}/firestore/useDocReference.ts +5 -14
  7. package/web/analytics/index.d.ts +3 -0
  8. package/web/analytics/index.js +3 -0
  9. package/web/analytics/index.ts +3 -0
  10. package/web/analytics/useAnalytics.d.ts +5 -0
  11. package/web/analytics/useAnalytics.js +10 -0
  12. package/web/analytics/useAnalytics.ts +12 -0
  13. package/web/analytics/useLogEvent.d.ts +17 -0
  14. package/web/analytics/useLogEvent.js +21 -0
  15. package/web/analytics/useLogEvent.ts +34 -0
  16. package/web/analytics/useSetAnalyticsCollectionEnabled.d.ts +10 -0
  17. package/web/analytics/useSetAnalyticsCollectionEnabled.js +16 -0
  18. package/web/analytics/useSetAnalyticsCollectionEnabled.ts +22 -0
  19. package/web/auth/index.d.ts +13 -0
  20. package/web/auth/index.js +13 -0
  21. package/web/auth/index.ts +13 -0
  22. package/web/auth/mutation-keys.d.ts +7 -0
  23. package/web/auth/mutation-keys.js +19 -0
  24. package/web/auth/mutation-keys.ts +19 -0
  25. package/web/auth/useAuth.d.ts +5 -0
  26. package/web/auth/useAuth.js +10 -0
  27. package/web/auth/useAuth.ts +12 -0
  28. package/web/auth/useAuthStateReady.d.ts +6 -0
  29. package/web/auth/useAuthStateReady.js +19 -0
  30. package/web/auth/useAuthStateReady.ts +24 -0
  31. package/web/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +15 -0
  32. package/web/auth/useCreateUserWitEmailAndPasswordMutation.js +19 -0
  33. package/web/auth/useCreateUserWitEmailAndPasswordMutation.ts +33 -0
  34. package/web/auth/useCurrentUser.d.ts +6 -0
  35. package/web/auth/useCurrentUser.js +20 -0
  36. package/web/auth/useCurrentUser.ts +24 -0
  37. package/web/auth/useIdToken.d.ts +30 -0
  38. package/web/auth/useIdToken.js +66 -0
  39. package/web/auth/useIdToken.ts +83 -0
  40. package/web/auth/useReauthenticateWitCredentialMutation.d.ts +16 -0
  41. package/web/auth/useReauthenticateWitCredentialMutation.js +18 -0
  42. package/web/auth/useReauthenticateWitCredentialMutation.ts +31 -0
  43. package/web/auth/useReauthenticateWitRedirectMutation.d.ts +17 -0
  44. package/web/auth/useReauthenticateWitRedirectMutation.js +18 -0
  45. package/web/auth/useReauthenticateWitRedirectMutation.ts +37 -0
  46. package/web/auth/useSendEmailVerificationMutation.d.ts +13 -0
  47. package/web/auth/useSendEmailVerificationMutation.js +16 -0
  48. package/web/auth/useSendEmailVerificationMutation.ts +28 -0
  49. package/web/auth/useSignInWitEmailAndPasswordMutation.d.ts +15 -0
  50. package/web/auth/useSignInWitEmailAndPasswordMutation.js +19 -0
  51. package/web/auth/useSignInWitEmailAndPasswordMutation.ts +34 -0
  52. package/web/auth/useSignInWitRedirectMutation.d.ts +14 -0
  53. package/web/auth/useSignInWitRedirectMutation.js +18 -0
  54. package/web/auth/useSignInWitRedirectMutation.ts +33 -0
  55. package/web/auth/useSignOutMutation.d.ts +10 -0
  56. package/web/auth/useSignOutMutation.js +19 -0
  57. package/web/auth/useSignOutMutation.ts +25 -0
  58. package/web/auth/useUpdateProfileMutation.d.ts +15 -0
  59. package/web/auth/useUpdateProfileMutation.js +17 -0
  60. package/web/auth/useUpdateProfileMutation.ts +30 -0
  61. package/web/context/FirebaseContext.d.ts +19 -0
  62. package/web/context/FirebaseContext.js +8 -0
  63. package/web/context/FirebaseContext.ts +25 -0
  64. package/web/context/FirebaseContextProvider.d.ts +127 -0
  65. package/web/context/FirebaseContextProvider.js +100 -0
  66. package/web/context/FirebaseContextProvider.tsx +231 -0
  67. package/web/context/index.d.ts +1 -0
  68. package/web/context/index.js +1 -0
  69. package/web/context/index.ts +1 -0
  70. package/web/firestore/index.d.ts +16 -0
  71. package/web/firestore/index.js +16 -0
  72. package/web/firestore/index.ts +16 -0
  73. package/web/firestore/useAddDocMutation.d.ts +23 -0
  74. package/web/firestore/useAddDocMutation.js +26 -0
  75. package/web/firestore/useAddDocMutation.ts +62 -0
  76. package/web/firestore/useBatchWrite.d.ts +15 -0
  77. package/web/firestore/useBatchWrite.js +21 -0
  78. package/web/firestore/useBatchWrite.ts +31 -0
  79. package/web/firestore/useCollectionReference.d.ts +18 -0
  80. package/web/firestore/useCollectionReference.js +24 -0
  81. package/web/firestore/useCollectionReference.ts +37 -0
  82. package/web/firestore/useCompositeFilter.d.ts +30 -0
  83. package/web/firestore/useCompositeFilter.js +43 -0
  84. package/web/firestore/useCompositeFilter.ts +86 -0
  85. package/web/firestore/useCountQuery.d.ts +23 -0
  86. package/web/firestore/useCountQuery.js +30 -0
  87. package/web/firestore/useCountQuery.ts +65 -0
  88. package/web/firestore/useDeleteDocMutation.d.ts +18 -0
  89. package/web/firestore/useDeleteDocMutation.js +23 -0
  90. package/web/firestore/useDeleteDocMutation.ts +47 -0
  91. package/web/firestore/useDocReference.d.ts +19 -0
  92. package/web/firestore/useDocReference.js +45 -0
  93. package/web/firestore/useDocReference.ts +68 -0
  94. package/web/firestore/useDocReferences.d.ts +23 -0
  95. package/web/firestore/useDocReferences.js +31 -0
  96. package/web/firestore/useDocReferences.ts +44 -0
  97. package/web/firestore/useFirestore.d.ts +7 -0
  98. package/web/firestore/useFirestore.js +12 -0
  99. package/web/firestore/useFirestore.ts +13 -0
  100. package/web/firestore/useGetDocData.d.ts +18 -0
  101. package/web/firestore/useGetDocData.js +18 -0
  102. package/web/firestore/useGetDocData.ts +41 -0
  103. package/web/firestore/useGetRealtimeDocData.d.ts +57 -0
  104. package/web/firestore/useGetRealtimeDocData.js +56 -0
  105. package/web/firestore/useGetRealtimeDocData.ts +104 -0
  106. package/web/firestore/useInfiniteQuery.d.ts +18 -0
  107. package/web/firestore/useInfiniteQuery.js +28 -0
  108. package/web/firestore/useInfiniteQuery.ts +91 -0
  109. package/web/firestore/useQuery.d.ts +25 -0
  110. package/web/firestore/useQuery.js +34 -0
  111. package/web/firestore/useQuery.ts +72 -0
  112. package/web/firestore/useRunTransaction.d.ts +15 -0
  113. package/web/firestore/useRunTransaction.js +19 -0
  114. package/web/firestore/useRunTransaction.ts +31 -0
  115. package/web/firestore/useSetDocMutation.d.ts +20 -0
  116. package/web/firestore/useSetDocMutation.js +25 -0
  117. package/web/firestore/useSetDocMutation.ts +52 -0
  118. package/web/firestore/useUpdateDocMutation.d.ts +31 -0
  119. package/web/firestore/useUpdateDocMutation.js +37 -0
  120. package/web/firestore/useUpdateDocMutation.ts +74 -0
  121. package/web/firestore/utils/getDocData.d.ts +18 -0
  122. package/web/firestore/utils/getDocData.js +22 -0
  123. package/web/firestore/utils/getDocData.ts +39 -0
  124. package/web/firestore/utils/getDocRef.d.ts +19 -0
  125. package/web/firestore/utils/getDocRef.js +25 -0
  126. package/web/firestore/utils/getDocRef.ts +46 -0
  127. package/web/firestore/utils/getDocSnap.d.ts +20 -0
  128. package/web/firestore/utils/getDocSnap.js +25 -0
  129. package/web/firestore/utils/getDocSnap.ts +41 -0
  130. package/web/index.d.ts +5 -0
  131. package/web/index.js +5 -0
  132. package/web/index.ts +5 -0
  133. package/web/remoteConfig/index.d.ts +3 -0
  134. package/web/remoteConfig/index.js +3 -0
  135. package/web/remoteConfig/index.ts +3 -0
  136. package/web/remoteConfig/useFetchAndActivate.d.ts +11 -0
  137. package/web/remoteConfig/useFetchAndActivate.js +31 -0
  138. package/web/remoteConfig/useFetchAndActivate.ts +36 -0
  139. package/web/remoteConfig/useGetValue.d.ts +7 -0
  140. package/web/remoteConfig/useGetValue.js +15 -0
  141. package/web/remoteConfig/useGetValue.ts +16 -0
  142. package/web/remoteConfig/useRemoteConfig.d.ts +5 -0
  143. package/web/remoteConfig/useRemoteConfig.js +10 -0
  144. package/web/remoteConfig/useRemoteConfig.ts +11 -0
  145. /package/{dist/src → react-native}/analytics/index.d.ts +0 -0
  146. /package/{dist/src → react-native}/analytics/index.js +0 -0
  147. /package/{src → react-native}/analytics/index.ts +0 -0
  148. /package/{dist/src → react-native}/analytics/useAnalytics.d.ts +0 -0
  149. /package/{dist/src → react-native}/analytics/useAnalytics.js +0 -0
  150. /package/{src → react-native}/analytics/useAnalytics.ts +0 -0
  151. /package/{dist/src → react-native}/analytics/useLogEvent.d.ts +0 -0
  152. /package/{dist/src → react-native}/analytics/useLogEvent.js +0 -0
  153. /package/{src → react-native}/analytics/useLogEvent.ts +0 -0
  154. /package/{dist/src → react-native}/analytics/useSetAnalyticsCollectionEnabled.d.ts +0 -0
  155. /package/{dist/src → react-native}/analytics/useSetAnalyticsCollectionEnabled.js +0 -0
  156. /package/{src → react-native}/analytics/useSetAnalyticsCollectionEnabled.ts +0 -0
  157. /package/{dist/src → react-native}/auth/index.d.ts +0 -0
  158. /package/{dist/src → react-native}/auth/index.js +0 -0
  159. /package/{src → react-native}/auth/index.ts +0 -0
  160. /package/{dist/src → react-native}/auth/mutation-keys.d.ts +0 -0
  161. /package/{dist/src → react-native}/auth/mutation-keys.js +0 -0
  162. /package/{src → react-native}/auth/mutation-keys.ts +0 -0
  163. /package/{dist/src → react-native}/auth/useAuth.d.ts +0 -0
  164. /package/{dist/src → react-native}/auth/useAuth.js +0 -0
  165. /package/{src → react-native}/auth/useAuth.ts +0 -0
  166. /package/{dist/src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.d.ts +0 -0
  167. /package/{dist/src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.js +0 -0
  168. /package/{src → react-native}/auth/useCreateUserWitEmailAndPasswordMutation.ts +0 -0
  169. /package/{dist/src → react-native}/auth/useCurrentUser.d.ts +0 -0
  170. /package/{dist/src → react-native}/auth/useCurrentUser.js +0 -0
  171. /package/{src → react-native}/auth/useCurrentUser.ts +0 -0
  172. /package/{dist/src → react-native}/auth/useIdToken.d.ts +0 -0
  173. /package/{dist/src → react-native}/auth/useIdToken.js +0 -0
  174. /package/{src → react-native}/auth/useIdToken.ts +0 -0
  175. /package/{dist/src → react-native}/auth/useReauthenticateWitCredentialMutation.d.ts +0 -0
  176. /package/{dist/src → react-native}/auth/useReauthenticateWitCredentialMutation.js +0 -0
  177. /package/{src → react-native}/auth/useReauthenticateWitCredentialMutation.ts +0 -0
  178. /package/{dist/src → react-native}/auth/useReauthenticateWitRedirectMutation.d.ts +0 -0
  179. /package/{dist/src → react-native}/auth/useReauthenticateWitRedirectMutation.js +0 -0
  180. /package/{src → react-native}/auth/useReauthenticateWitRedirectMutation.ts +0 -0
  181. /package/{dist/src → react-native}/auth/useSendEmailVerificationMutation.d.ts +0 -0
  182. /package/{dist/src → react-native}/auth/useSendEmailVerificationMutation.js +0 -0
  183. /package/{src → react-native}/auth/useSendEmailVerificationMutation.ts +0 -0
  184. /package/{dist/src → react-native}/auth/useSignInWitEmailAndPasswordMutation.d.ts +0 -0
  185. /package/{dist/src → react-native}/auth/useSignInWitEmailAndPasswordMutation.js +0 -0
  186. /package/{src → react-native}/auth/useSignInWitEmailAndPasswordMutation.ts +0 -0
  187. /package/{dist/src → react-native}/auth/useSignInWitRedirectMutation.d.ts +0 -0
  188. /package/{dist/src → react-native}/auth/useSignInWitRedirectMutation.js +0 -0
  189. /package/{src → react-native}/auth/useSignInWitRedirectMutation.ts +0 -0
  190. /package/{dist/src → react-native}/auth/useSignOutMutation.d.ts +0 -0
  191. /package/{dist/src → react-native}/auth/useSignOutMutation.js +0 -0
  192. /package/{src → react-native}/auth/useSignOutMutation.ts +0 -0
  193. /package/{dist/src → react-native}/auth/useUpdateProfileMutation.d.ts +0 -0
  194. /package/{dist/src → react-native}/auth/useUpdateProfileMutation.js +0 -0
  195. /package/{src → react-native}/auth/useUpdateProfileMutation.ts +0 -0
  196. /package/{dist/src → react-native}/context/FirebaseContext.d.ts +0 -0
  197. /package/{dist/src → react-native}/context/FirebaseContext.js +0 -0
  198. /package/{src → react-native}/context/FirebaseContext.ts +0 -0
  199. /package/{dist/src → react-native}/context/FirebaseContextProvider.d.ts +0 -0
  200. /package/{dist/src → react-native}/context/FirebaseContextProvider.js +0 -0
  201. /package/{src → react-native}/context/FirebaseContextProvider.tsx +0 -0
  202. /package/{dist/src → react-native}/context/index.d.ts +0 -0
  203. /package/{dist/src → react-native}/context/index.js +0 -0
  204. /package/{src → react-native}/context/index.ts +0 -0
  205. /package/{dist/src → react-native}/firestore/index.d.ts +0 -0
  206. /package/{dist/src → react-native}/firestore/index.js +0 -0
  207. /package/{src → react-native}/firestore/index.ts +0 -0
  208. /package/{dist/src → react-native}/firestore/useAddDocMutation.d.ts +0 -0
  209. /package/{dist/src → react-native}/firestore/useAddDocMutation.js +0 -0
  210. /package/{src → react-native}/firestore/useAddDocMutation.ts +0 -0
  211. /package/{dist/src → react-native}/firestore/useBatchWrite.d.ts +0 -0
  212. /package/{dist/src → react-native}/firestore/useBatchWrite.js +0 -0
  213. /package/{src → react-native}/firestore/useBatchWrite.ts +0 -0
  214. /package/{dist/src → react-native}/firestore/useCollectionReference.js +0 -0
  215. /package/{dist/src → react-native}/firestore/useCompositeFilter.d.ts +0 -0
  216. /package/{dist/src → react-native}/firestore/useCompositeFilter.js +0 -0
  217. /package/{src → react-native}/firestore/useCompositeFilter.ts +0 -0
  218. /package/{dist/src → react-native}/firestore/useCountQuery.d.ts +0 -0
  219. /package/{dist/src → react-native}/firestore/useCountQuery.js +0 -0
  220. /package/{src → react-native}/firestore/useCountQuery.ts +0 -0
  221. /package/{dist/src → react-native}/firestore/useDeleteDocMutation.d.ts +0 -0
  222. /package/{dist/src → react-native}/firestore/useDeleteDocMutation.js +0 -0
  223. /package/{src → react-native}/firestore/useDeleteDocMutation.ts +0 -0
  224. /package/{dist/src → react-native}/firestore/useDocReferences.d.ts +0 -0
  225. /package/{dist/src → react-native}/firestore/useDocReferences.js +0 -0
  226. /package/{src → react-native}/firestore/useDocReferences.ts +0 -0
  227. /package/{dist/src → react-native}/firestore/useFirestore.d.ts +0 -0
  228. /package/{dist/src → react-native}/firestore/useFirestore.js +0 -0
  229. /package/{src → react-native}/firestore/useFirestore.ts +0 -0
  230. /package/{dist/src → react-native}/firestore/useGetDocData.d.ts +0 -0
  231. /package/{dist/src → react-native}/firestore/useGetDocData.js +0 -0
  232. /package/{src → react-native}/firestore/useGetDocData.ts +0 -0
  233. /package/{dist/src → react-native}/firestore/useGetRealtimeDocData.d.ts +0 -0
  234. /package/{dist/src → react-native}/firestore/useGetRealtimeDocData.js +0 -0
  235. /package/{src → react-native}/firestore/useGetRealtimeDocData.ts +0 -0
  236. /package/{dist/src → react-native}/firestore/useInfiniteQuery.d.ts +0 -0
  237. /package/{dist/src → react-native}/firestore/useInfiniteQuery.js +0 -0
  238. /package/{src → react-native}/firestore/useInfiniteQuery.ts +0 -0
  239. /package/{dist/src → react-native}/firestore/useQuery.d.ts +0 -0
  240. /package/{dist/src → react-native}/firestore/useQuery.js +0 -0
  241. /package/{src → react-native}/firestore/useQuery.ts +0 -0
  242. /package/{dist/src → react-native}/firestore/useRunTransaction.d.ts +0 -0
  243. /package/{dist/src → react-native}/firestore/useRunTransaction.js +0 -0
  244. /package/{src → react-native}/firestore/useRunTransaction.ts +0 -0
  245. /package/{dist/src → react-native}/firestore/useSetDocMutation.d.ts +0 -0
  246. /package/{dist/src → react-native}/firestore/useSetDocMutation.js +0 -0
  247. /package/{src → react-native}/firestore/useSetDocMutation.ts +0 -0
  248. /package/{dist/src → react-native}/firestore/useUpdateDocMutation.d.ts +0 -0
  249. /package/{dist/src → react-native}/firestore/useUpdateDocMutation.js +0 -0
  250. /package/{src → react-native}/firestore/useUpdateDocMutation.ts +0 -0
  251. /package/{dist/src → react-native}/firestore/utils/getDocData.d.ts +0 -0
  252. /package/{dist/src → react-native}/firestore/utils/getDocData.js +0 -0
  253. /package/{src → react-native}/firestore/utils/getDocData.ts +0 -0
  254. /package/{dist/src → react-native}/firestore/utils/getDocRef.d.ts +0 -0
  255. /package/{dist/src → react-native}/firestore/utils/getDocRef.js +0 -0
  256. /package/{src → react-native}/firestore/utils/getDocRef.ts +0 -0
  257. /package/{dist/src → react-native}/firestore/utils/getDocSnap.d.ts +0 -0
  258. /package/{dist/src → react-native}/firestore/utils/getDocSnap.js +0 -0
  259. /package/{src → react-native}/firestore/utils/getDocSnap.ts +0 -0
  260. /package/{dist/src → react-native}/index.d.ts +0 -0
  261. /package/{dist/src → react-native}/index.js +0 -0
  262. /package/{src → react-native}/index.ts +0 -0
  263. /package/{dist/src → react-native}/remoteConfig/index.d.ts +0 -0
  264. /package/{dist/src → react-native}/remoteConfig/index.js +0 -0
  265. /package/{src → react-native}/remoteConfig/index.ts +0 -0
  266. /package/{dist/src → react-native}/remoteConfig/useFetchAndActivate.d.ts +0 -0
  267. /package/{dist/src → react-native}/remoteConfig/useFetchAndActivate.js +0 -0
  268. /package/{src → react-native}/remoteConfig/useFetchAndActivate.ts +0 -0
  269. /package/{dist/src → react-native}/remoteConfig/useGetValue.d.ts +0 -0
  270. /package/{dist/src → react-native}/remoteConfig/useGetValue.js +0 -0
  271. /package/{src → react-native}/remoteConfig/useGetValue.ts +0 -0
  272. /package/{dist/src → react-native}/remoteConfig/useRemoteConfig.d.ts +0 -0
  273. /package/{dist/src → react-native}/remoteConfig/useRemoteConfig.js +0 -0
  274. /package/{src → react-native}/remoteConfig/useRemoteConfig.ts +0 -0
package/package.json CHANGED
@@ -13,19 +13,22 @@
13
13
  "@react-native-firebase/installations": "^21.0.0",
14
14
  "@react-native-firebase/remote-config": "^21.0.0",
15
15
  "@tanstack/react-query": "^5.0.0",
16
+ "firebase": "^11.0.0",
16
17
  "react": "^18.0.0 || ^19.0.0"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public"
20
21
  },
21
- "description": "This module offers react hooks to work with Firebase",
22
+ "description": "This module offers react hooks to work with Firebase on react-native and web platforms",
22
23
  "devDependencies": {
23
24
  "@laverve/eslint-utils": "^5.1.1",
24
- "@react-native-firebase/analytics": "^21.12.2",
25
- "@react-native-firebase/app": "^21.12.2",
26
- "@react-native-firebase/auth": "^21.12.2",
27
- "@react-native-firebase/firestore": "^21.12.2",
28
- "@react-native-firebase/remote-config": "^21.12.2",
25
+ "@react-native-firebase/analytics": "^21.0.0",
26
+ "@react-native-firebase/app": "^21.0.0",
27
+ "@react-native-firebase/auth": "^21.0.0",
28
+ "@react-native-firebase/crashlytics": "^21.0.0",
29
+ "@react-native-firebase/firestore": "^21.0.0",
30
+ "@react-native-firebase/installations": "^21.0.0",
31
+ "@react-native-firebase/remote-config": "^21.0.0",
29
32
  "@types/react": "^19.0.2",
30
33
  "husky": "^9.1.1",
31
34
  "lint-staged": "^15.1.0",
@@ -35,25 +38,25 @@
35
38
  "typedoc-plugin-markdown": "^4.4.1",
36
39
  "typedoc-vitepress-theme": "^1.1.2",
37
40
  "typescript": "^5.2.2",
38
- "vitepress": "^1.5.0"
41
+ "vitepress": "^1.5.0",
42
+ "firebase": "^11.0.1"
39
43
  },
40
44
  "homepage": "https://github.com/vpishuk/react-query-firebase",
41
45
  "keywords": [
42
46
  "firebase",
43
47
  "react",
44
- "hooks"
48
+ "hooks",
49
+ "react-native"
45
50
  ],
46
51
  "license": "MIT",
47
- "main": "./dist/src/index.js",
48
- "types": "./dist/src/index.d.ts",
49
52
  "name": "react-query-firebase",
50
53
  "repository": {
51
54
  "type": "git",
52
55
  "url": "https://github.com/vpishuk/react-query-firebase.git"
53
56
  },
54
57
  "files": [
55
- "./dist/src/",
56
- "./src/",
58
+ "./web/",
59
+ "./react-native/",
57
60
  "package.json",
58
61
  "package-lock.json",
59
62
  "README.md",
@@ -70,5 +73,5 @@
70
73
  "docs:build": "vitepress build docs",
71
74
  "docs:preview": "vitepress preview docs"
72
75
  },
73
- "version": "2.0.0-rc5"
76
+ "version": "2.0.0-rc7"
74
77
  }
@@ -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<AppModelType> | null;
18
+ export declare const useCollectionReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseCollectionReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.CollectionReference<AppModelType>;
@@ -30,7 +30,7 @@ export const useCollectionReference = <
30
30
  path,
31
31
  reference,
32
32
  pathSegments
33
- }: UseCollectionReferenceOptions<AppModelType>): FirebaseFirestoreTypes.CollectionReference<AppModelType> | null => {
33
+ }: UseCollectionReferenceOptions<AppModelType>): FirebaseFirestoreTypes.CollectionReference<AppModelType> => {
34
34
  const db = useFirestore();
35
35
 
36
36
  return useMemo(() => {
@@ -16,4 +16,4 @@ export type UseDocReferenceOptions<AppModelType extends FirebaseFirestoreTypes.D
16
16
  *
17
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
- export declare const useDocReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseDocReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.DocumentReference<AppModelType> | null;
19
+ export declare const useDocReference: <AppModelType extends FirebaseFirestoreTypes.DocumentData = FirebaseFirestoreTypes.DocumentData>({ path, reference, pathSegments }: UseDocReferenceOptions<AppModelType>) => FirebaseFirestoreTypes.DocumentReference<AppModelType>;
@@ -1,5 +1,5 @@
1
1
  import { doc } from "@react-native-firebase/firestore";
2
- import { useEffect, useRef } from "react";
2
+ import { useMemo } from "react";
3
3
  import { useFirestore } from "./useFirestore";
4
4
  /**
5
5
  * Generates a document reference for a specified path or reference in Firestore.
@@ -14,9 +14,6 @@ import { useFirestore } from "./useFirestore";
14
14
  * @returns {DocumentReference<AppModelType> | null} A Firestore document reference if the path is specified; otherwise, returns null if path is not provided.
15
15
  */
16
16
  const getDocReference = (db, { path, pathSegments, reference }) => {
17
- if (!path) {
18
- return null;
19
- }
20
17
  return (!reference ? doc(db, path || "", ...(pathSegments || [])) : doc(reference, path, ...(pathSegments || [])));
21
18
  };
22
19
  /**
@@ -33,9 +30,7 @@ const getDocReference = (db, { path, pathSegments, reference }) => {
33
30
  */
34
31
  export const useDocReference = ({ path, reference, pathSegments }) => {
35
32
  const db = useFirestore();
36
- const ref = useRef(getDocReference(db, { path, pathSegments, reference }));
37
- useEffect(() => {
38
- ref.current = getDocReference(db, { path, pathSegments, reference });
39
- }, [db, path, reference, pathSegments]);
40
- return ref.current;
33
+ return useMemo(() => {
34
+ return getDocReference(db, { path, pathSegments, reference });
35
+ }, [db, reference, path, pathSegments]);
41
36
  };
@@ -1,6 +1,6 @@
1
1
  import { doc, FirebaseFirestoreTypes } from "@react-native-firebase/firestore";
2
2
 
3
- import { useEffect, useRef } from "react";
3
+ import { useMemo } from "react";
4
4
  import { useFirestore } from "./useFirestore";
5
5
 
6
6
  export type UseDocReferenceOptions<
@@ -31,10 +31,6 @@ const getDocReference = <
31
31
  db: FirebaseFirestoreTypes.Module,
32
32
  { path, pathSegments, reference }: UseDocReferenceOptions<AppModelType>
33
33
  ) => {
34
- if (!path) {
35
- return null;
36
- }
37
-
38
34
  return (
39
35
  !reference ? doc(db, path || "", ...(pathSegments || [])) : doc(reference, path, ...(pathSegments || []))
40
36
  ) as FirebaseFirestoreTypes.DocumentReference<AppModelType>;
@@ -58,15 +54,10 @@ export const useDocReference = <
58
54
  path,
59
55
  reference,
60
56
  pathSegments
61
- }: UseDocReferenceOptions<AppModelType>): FirebaseFirestoreTypes.DocumentReference<AppModelType> | null => {
57
+ }: UseDocReferenceOptions<AppModelType>): FirebaseFirestoreTypes.DocumentReference<AppModelType> => {
62
58
  const db = useFirestore();
63
- const ref = useRef<FirebaseFirestoreTypes.DocumentReference<AppModelType> | null>(
64
- getDocReference(db, { path, pathSegments, reference })
65
- );
66
-
67
- useEffect(() => {
68
- ref.current = getDocReference(db, { path, pathSegments, reference });
69
- }, [db, path, reference, pathSegments]);
70
59
 
71
- return ref.current;
60
+ return useMemo(() => {
61
+ return getDocReference(db, { path, pathSegments, reference });
62
+ }, [db, reference, path, pathSegments]);
72
63
  };
@@ -0,0 +1,3 @@
1
+ export * from "./useLogEvent";
2
+ export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -0,0 +1,3 @@
1
+ export * from "./useLogEvent";
2
+ export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -0,0 +1,3 @@
1
+ export * from "./useLogEvent";
2
+ export * from "./useAnalytics";
3
+ export * from "./useSetAnalyticsCollectionEnabled";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook to access Firebase analytics from the Firebase context.
3
+ * @returns {any} The analytics object from the Firebase context.
4
+ */
5
+ export declare const useAnalytics: () => import("@firebase/analytics").Analytics;
@@ -0,0 +1,10 @@
1
+ import { useContext } from "react";
2
+ import { FirebaseContext } from "../context/FirebaseContext";
3
+ /**
4
+ * Hook to access Firebase analytics from the Firebase context.
5
+ * @returns {any} The analytics object from the Firebase context.
6
+ */
7
+ export const useAnalytics = () => {
8
+ const { analytics } = useContext(FirebaseContext);
9
+ return analytics;
10
+ };
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+
3
+ import { FirebaseContext } from "../context/FirebaseContext";
4
+
5
+ /**
6
+ * Hook to access Firebase analytics from the Firebase context.
7
+ * @returns {any} The analytics object from the Firebase context.
8
+ */
9
+ export const useAnalytics = () => {
10
+ const { analytics } = useContext(FirebaseContext);
11
+ return analytics;
12
+ };
@@ -0,0 +1,17 @@
1
+ type UseLogEventOptions = {
2
+ eventName: string;
3
+ eventParams?: {
4
+ [key: string]: unknown;
5
+ };
6
+ };
7
+ /**
8
+ * Custom hook to create a log event function that logs an analytics event with specified parameters.
9
+ * @param {Object} options - The options for the log event.
10
+ * @param {string} options.eventName - The name of the event to be logged.
11
+ * @param {Object} options.eventParams - The parameters to be sent along with the event.
12
+ * @returns {Object} An object containing a `logEvent` function that, when called, logs the event.
13
+ */
14
+ export declare const useLogEvent: ({ eventName, eventParams }: UseLogEventOptions) => {
15
+ logEvent: () => void;
16
+ };
17
+ export {};
@@ -0,0 +1,21 @@
1
+ import { logEvent } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useCallback, useMemo } from "react";
4
+ /**
5
+ * Custom hook to create a log event function that logs an analytics event with specified parameters.
6
+ * @param {Object} options - The options for the log event.
7
+ * @param {string} options.eventName - The name of the event to be logged.
8
+ * @param {Object} options.eventParams - The parameters to be sent along with the event.
9
+ * @returns {Object} An object containing a `logEvent` function that, when called, logs the event.
10
+ */
11
+ export const useLogEvent = ({ eventName, eventParams }) => {
12
+ const analytics = useAnalytics();
13
+ const logEventCallback = useCallback(() => {
14
+ if (analytics) {
15
+ logEvent(analytics, eventName, eventParams);
16
+ }
17
+ }, [eventName, eventParams]);
18
+ return useMemo(() => ({
19
+ logEvent: logEventCallback
20
+ }), [logEventCallback]);
21
+ };
@@ -0,0 +1,34 @@
1
+ import { logEvent } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useCallback, useMemo } from "react";
4
+
5
+ type UseLogEventOptions = {
6
+ eventName: string;
7
+ eventParams?: {
8
+ [key: string]: unknown;
9
+ };
10
+ };
11
+
12
+ /**
13
+ * Custom hook to create a log event function that logs an analytics event with specified parameters.
14
+ * @param {Object} options - The options for the log event.
15
+ * @param {string} options.eventName - The name of the event to be logged.
16
+ * @param {Object} options.eventParams - The parameters to be sent along with the event.
17
+ * @returns {Object} An object containing a `logEvent` function that, when called, logs the event.
18
+ */
19
+ export const useLogEvent = ({ eventName, eventParams }: UseLogEventOptions) => {
20
+ const analytics = useAnalytics();
21
+
22
+ const logEventCallback = useCallback(() => {
23
+ if (analytics) {
24
+ logEvent(analytics, eventName, eventParams);
25
+ }
26
+ }, [eventName, eventParams]);
27
+
28
+ return useMemo(
29
+ () => ({
30
+ logEvent: logEventCallback
31
+ }),
32
+ [logEventCallback]
33
+ );
34
+ };
@@ -0,0 +1,10 @@
1
+ type UseSetAnalyticsCollectionEnabledOptions = {
2
+ enabled?: boolean;
3
+ };
4
+ /**
5
+ * Custom hook to enable or disable analytics collection
6
+ * @param {Object} options - The options for hook.
7
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
8
+ */
9
+ export declare const useSetAnalyticsCollectionEnabled: ({ enabled }: UseSetAnalyticsCollectionEnabledOptions) => void;
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import { setAnalyticsCollectionEnabled } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useEffect } from "react";
4
+ /**
5
+ * Custom hook to enable or disable analytics collection
6
+ * @param {Object} options - The options for hook.
7
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
8
+ */
9
+ export const useSetAnalyticsCollectionEnabled = ({ enabled = false }) => {
10
+ const analytics = useAnalytics();
11
+ useEffect(() => {
12
+ if (analytics) {
13
+ setAnalyticsCollectionEnabled(analytics, enabled);
14
+ }
15
+ }, [analytics]);
16
+ };
@@ -0,0 +1,22 @@
1
+ import { setAnalyticsCollectionEnabled } from "firebase/analytics";
2
+ import { useAnalytics } from "./useAnalytics";
3
+ import { useEffect } from "react";
4
+
5
+ type UseSetAnalyticsCollectionEnabledOptions = {
6
+ enabled?: boolean;
7
+ };
8
+
9
+ /**
10
+ * Custom hook to enable or disable analytics collection
11
+ * @param {Object} options - The options for hook.
12
+ * @param {string} options.enabled - Flag that identifies if analytics collection is enabled.
13
+ */
14
+ export const useSetAnalyticsCollectionEnabled = ({ enabled = false }: UseSetAnalyticsCollectionEnabledOptions) => {
15
+ const analytics = useAnalytics();
16
+
17
+ useEffect(() => {
18
+ if (analytics) {
19
+ setAnalyticsCollectionEnabled(analytics, enabled);
20
+ }
21
+ }, [analytics]);
22
+ };
@@ -0,0 +1,13 @@
1
+ export * from "./mutation-keys";
2
+ export * from "./useAuth";
3
+ export * from "./useCreateUserWitEmailAndPasswordMutation";
4
+ export * from "./useSendEmailVerificationMutation";
5
+ export * from "./useSignInWitEmailAndPasswordMutation";
6
+ export * from "./useCurrentUser";
7
+ export * from "./useAuthStateReady";
8
+ export * from "./useSignInWitRedirectMutation";
9
+ export * from "./useUpdateProfileMutation";
10
+ export * from "./useSignOutMutation";
11
+ export * from "./useIdToken";
12
+ export * from "./useReauthenticateWitCredentialMutation";
13
+ export * from "./useReauthenticateWitRedirectMutation";
@@ -0,0 +1,13 @@
1
+ export * from "./mutation-keys";
2
+ export * from "./useAuth";
3
+ export * from "./useCreateUserWitEmailAndPasswordMutation";
4
+ export * from "./useSendEmailVerificationMutation";
5
+ export * from "./useSignInWitEmailAndPasswordMutation";
6
+ export * from "./useCurrentUser";
7
+ export * from "./useAuthStateReady";
8
+ export * from "./useSignInWitRedirectMutation";
9
+ export * from "./useUpdateProfileMutation";
10
+ export * from "./useSignOutMutation";
11
+ export * from "./useIdToken";
12
+ export * from "./useReauthenticateWitCredentialMutation";
13
+ export * from "./useReauthenticateWitRedirectMutation";
@@ -0,0 +1,13 @@
1
+ export * from "./mutation-keys";
2
+ export * from "./useAuth";
3
+ export * from "./useCreateUserWitEmailAndPasswordMutation";
4
+ export * from "./useSendEmailVerificationMutation";
5
+ export * from "./useSignInWitEmailAndPasswordMutation";
6
+ export * from "./useCurrentUser";
7
+ export * from "./useAuthStateReady";
8
+ export * from "./useSignInWitRedirectMutation";
9
+ export * from "./useUpdateProfileMutation";
10
+ export * from "./useSignOutMutation";
11
+ export * from "./useIdToken";
12
+ export * from "./useReauthenticateWitCredentialMutation";
13
+ export * from "./useReauthenticateWitRedirectMutation";
@@ -0,0 +1,7 @@
1
+ export declare const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"];
2
+ export declare const SEND_EMAIL_VERIFICATION_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
3
+ export declare const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"];
4
+ export declare const SIGN_IN_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
5
+ export declare const SIGN_OUT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "SIGN_OUT"];
6
+ export declare const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
7
+ export declare const REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY: readonly ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_CREDENTIAL"];
@@ -0,0 +1,19 @@
1
+ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
2
+ "FIREBASE",
3
+ "AUTH",
4
+ "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
+ ];
6
+ export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"];
7
+ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
+ "FIREBASE",
9
+ "AUTH",
10
+ "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
11
+ ];
12
+ export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"];
13
+ export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"];
14
+ export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"];
15
+ export const REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY = [
16
+ "FIREBASE",
17
+ "AUTH",
18
+ "REAUTHENTICATE_WITH_CREDENTIAL"
19
+ ];
@@ -0,0 +1,19 @@
1
+ export const CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
2
+ "FIREBASE",
3
+ "AUTH",
4
+ "CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION"
5
+ ] as const;
6
+ export const SEND_EMAIL_VERIFICATION_MUTATION_KEY = ["FIREBASE", "AUTH", "SEND_EMAIL_VERIFICATION_MUTATION"] as const;
7
+ export const SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY = [
8
+ "FIREBASE",
9
+ "AUTH",
10
+ "SIGN_IN_WITH_EMAIL_AND_PASSWORD_MUTATION"
11
+ ] as const;
12
+ export const SIGN_IN_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_IN_WITH_REDIRECT_MUTATION"] as const;
13
+ export const SIGN_OUT_MUTATION_KEY = ["FIREBASE", "AUTH", "SIGN_OUT"] as const;
14
+ export const REAUTHENTICATE_WITH_REDIRECT_MUTATION_KEY = ["FIREBASE", "AUTH", "REAUTHENTICATE_WITH_REDIRECT"] as const;
15
+ export const REAUTHENTICATE_WITH_CREDENTIAL_MUTATION_KEY = [
16
+ "FIREBASE",
17
+ "AUTH",
18
+ "REAUTHENTICATE_WITH_CREDENTIAL"
19
+ ] as const;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Custom hook to retrieve the authentication object from the Firebase context.
3
+ * @returns {Auth} The authentication object from the Firebase context.
4
+ */
5
+ export declare const useAuth: () => import("@firebase/auth").Auth;
@@ -0,0 +1,10 @@
1
+ import { useContext } from "react";
2
+ import { FirebaseContext } from "../context/FirebaseContext";
3
+ /**
4
+ * Custom hook to retrieve the authentication object from the Firebase context.
5
+ * @returns {Auth} The authentication object from the Firebase context.
6
+ */
7
+ export const useAuth = () => {
8
+ const { auth } = useContext(FirebaseContext);
9
+ return auth;
10
+ };
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+
3
+ import { FirebaseContext } from "../context/FirebaseContext";
4
+
5
+ /**
6
+ * Custom hook to retrieve the authentication object from the Firebase context.
7
+ * @returns {Auth} The authentication object from the Firebase context.
8
+ */
9
+ export const useAuth = () => {
10
+ const { auth } = useContext(FirebaseContext);
11
+ return auth;
12
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A custom hook that determines if the Firebase authentication state is ready.
3
+ * It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
4
+ * @returns {boolean} Indicates whether the authentication state is ready.
5
+ */
6
+ export declare const useAuthStateReady: () => boolean;
@@ -0,0 +1,19 @@
1
+ import { useAuth } from "./useAuth";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ /**
4
+ * A custom hook that determines if the Firebase authentication state is ready.
5
+ * It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
6
+ * @returns {boolean} Indicates whether the authentication state is ready.
7
+ */
8
+ export const useAuthStateReady = () => {
9
+ const firebaseAuth = useAuth();
10
+ const [isAuthStateReady, setIsAuthStateReady] = useState(false);
11
+ const callback = useCallback(async () => {
12
+ await firebaseAuth.authStateReady();
13
+ setIsAuthStateReady(true);
14
+ }, [isAuthStateReady]);
15
+ useEffect(() => {
16
+ callback();
17
+ }, [callback]);
18
+ return isAuthStateReady;
19
+ };
@@ -0,0 +1,24 @@
1
+ import { useAuth } from "./useAuth";
2
+ import { useCallback, useEffect, useState } from "react";
3
+
4
+ /**
5
+ * A custom hook that determines if the Firebase authentication state is ready.
6
+ * It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
7
+ * @returns {boolean} Indicates whether the authentication state is ready.
8
+ */
9
+ export const useAuthStateReady = () => {
10
+ const firebaseAuth = useAuth();
11
+
12
+ const [isAuthStateReady, setIsAuthStateReady] = useState(false);
13
+
14
+ const callback = useCallback(async () => {
15
+ await firebaseAuth.authStateReady();
16
+ setIsAuthStateReady(true);
17
+ }, [isAuthStateReady]);
18
+
19
+ useEffect(() => {
20
+ callback();
21
+ }, [callback]);
22
+
23
+ return isAuthStateReady;
24
+ };
@@ -0,0 +1,15 @@
1
+ import { UseMutationOptions } from "@tanstack/react-query";
2
+ import { UserCredential } from "firebase/auth";
3
+ import { FirebaseError } from "firebase/app";
4
+ export type UseCreateUserWitEmailAndPasswordMutationVariables = {
5
+ email: string;
6
+ password: string;
7
+ };
8
+ /**
9
+ * Custom hook to initiate a user creation process using email and password with Firebase authentication.
10
+ * This hook utilizes the `useMutation` functionality to support creating new user credentials asynchronously.
11
+ *
12
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional settings to customize the mutation behavior, excluding `mutationKey` and `mutationFn`.
13
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>} The result of the mutation which includes status, user credentials, and error information if any.
14
+ */
15
+ export declare const useCreateUserWitEmailAndPasswordMutation: <TContext = unknown>(options?: Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">) => import("@tanstack/react-query").UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>;
@@ -0,0 +1,19 @@
1
+ import { useMutation } from "@tanstack/react-query";
2
+ import { createUserWithEmailAndPassword } from "firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
5
+ /**
6
+ * Custom hook to initiate a user creation process using email and password with Firebase authentication.
7
+ * This hook utilizes the `useMutation` functionality to support creating new user credentials asynchronously.
8
+ *
9
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional settings to customize the mutation behavior, excluding `mutationKey` and `mutationFn`.
10
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>} The result of the mutation which includes status, user credentials, and error information if any.
11
+ */
12
+ export const useCreateUserWitEmailAndPasswordMutation = (options = {}) => {
13
+ const firebaseAuth = useAuth();
14
+ return useMutation({
15
+ ...options,
16
+ mutationFn: async ({ email, password }) => await createUserWithEmailAndPassword(firebaseAuth, email, password),
17
+ mutationKey: CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
18
+ });
19
+ };
@@ -0,0 +1,33 @@
1
+ import { useMutation, UseMutationOptions } from "@tanstack/react-query";
2
+ import { createUserWithEmailAndPassword, UserCredential } from "firebase/auth";
3
+ import { useAuth } from "./useAuth";
4
+ import { FirebaseError } from "firebase/app";
5
+ import { CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY } from "./mutation-keys";
6
+
7
+ export type UseCreateUserWitEmailAndPasswordMutationVariables = {
8
+ email: string;
9
+ password: string;
10
+ };
11
+
12
+ /**
13
+ * Custom hook to initiate a user creation process using email and password with Firebase authentication.
14
+ * This hook utilizes the `useMutation` functionality to support creating new user credentials asynchronously.
15
+ *
16
+ * @param {Omit<UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>, "mutationKey" | "mutationFn">} options - Optional settings to customize the mutation behavior, excluding `mutationKey` and `mutationFn`.
17
+ * @returns {UseMutationResult<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>} The result of the mutation which includes status, user credentials, and error information if any.
18
+ */
19
+ export const useCreateUserWitEmailAndPasswordMutation = <TContext = unknown>(
20
+ options: Omit<
21
+ UseMutationOptions<UserCredential, FirebaseError, UseCreateUserWitEmailAndPasswordMutationVariables, TContext>,
22
+ "mutationKey" | "mutationFn"
23
+ > = {}
24
+ ) => {
25
+ const firebaseAuth = useAuth();
26
+
27
+ return useMutation({
28
+ ...options,
29
+ mutationFn: async ({ email, password }: UseCreateUserWitEmailAndPasswordMutationVariables) =>
30
+ await createUserWithEmailAndPassword(firebaseAuth, email, password),
31
+ mutationKey: CREATE_USER_WITH_EMAIL_AND_PASSWORD_MUTATION_KEY
32
+ });
33
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Hook that provides the current authenticated user from Firebase Auth.
3
+ * It listens for changes in the authentication state and updates the user accordingly.
4
+ * @returns {Object|null} The current authenticated user object or null if no user is authenticated.
5
+ */
6
+ export declare const useCurrentUser: () => import("@firebase/auth").User | null;
@@ -0,0 +1,20 @@
1
+ import { useAuth } from "./useAuth";
2
+ import { useEffect, useState } from "react";
3
+ /**
4
+ * Hook that provides the current authenticated user from Firebase Auth.
5
+ * It listens for changes in the authentication state and updates the user accordingly.
6
+ * @returns {Object|null} The current authenticated user object or null if no user is authenticated.
7
+ */
8
+ export const useCurrentUser = () => {
9
+ const firebaseAuth = useAuth();
10
+ const [currentUser, setCurrentUser] = useState(firebaseAuth.currentUser);
11
+ useEffect(() => {
12
+ const unsubscribe = firebaseAuth.onAuthStateChanged((user) => {
13
+ setCurrentUser(user);
14
+ });
15
+ return () => {
16
+ unsubscribe();
17
+ };
18
+ }, [currentUser?.uid ?? ""]);
19
+ return currentUser;
20
+ };