react-query-firebase 2.1.4 → 2.2.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.
- package/package.json +1 -1
- package/react-native/auth/index.d.ts +1 -0
- package/react-native/auth/index.js +1 -0
- package/react-native/auth/index.ts +1 -0
- package/react-native/auth/useAuthStateReady.d.ts +17 -0
- package/react-native/auth/useAuthStateReady.js +33 -0
- package/react-native/auth/useAuthStateReady.ts +38 -0
- package/web/auth/useAuthStateReady.d.ts +12 -1
- package/web/auth/useAuthStateReady.js +12 -1
- package/web/auth/useAuthStateReady.ts +12 -1
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
*
|
|
5
|
+
* @group Hook
|
|
6
|
+
*
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```jsx
|
|
11
|
+
* export const MyComponent = () => {
|
|
12
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
13
|
+
* console.log(isAuthStateReady);
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const useAuthStateReady: () => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useAuth } from "./useAuth";
|
|
2
|
+
import { 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
|
+
*
|
|
7
|
+
* @group Hook
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
* export const MyComponent = () => {
|
|
14
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
15
|
+
* console.log(isAuthStateReady);
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const useAuthStateReady = () => {
|
|
20
|
+
const firebaseAuth = useAuth();
|
|
21
|
+
const [isAuthStateReady, setIsAuthStateReady] = useState(false);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const subscription = firebaseAuth.onAuthStateChanged(() => {
|
|
24
|
+
if (!isAuthStateReady) {
|
|
25
|
+
setIsAuthStateReady(true);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
subscription();
|
|
30
|
+
};
|
|
31
|
+
}, [firebaseAuth, isAuthStateReady]);
|
|
32
|
+
return isAuthStateReady;
|
|
33
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useAuth } from "./useAuth";
|
|
2
|
+
import { 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
|
+
*
|
|
8
|
+
* @group Hook
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* export const MyComponent = () => {
|
|
15
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
16
|
+
* console.log(isAuthStateReady);
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const useAuthStateReady = () => {
|
|
21
|
+
const firebaseAuth = useAuth();
|
|
22
|
+
|
|
23
|
+
const [isAuthStateReady, setIsAuthStateReady] = useState(false);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const subscription = firebaseAuth.onAuthStateChanged(() => {
|
|
27
|
+
if (!isAuthStateReady) {
|
|
28
|
+
setIsAuthStateReady(true);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
subscription();
|
|
34
|
+
};
|
|
35
|
+
}, [firebaseAuth, isAuthStateReady]);
|
|
36
|
+
|
|
37
|
+
return isAuthStateReady;
|
|
38
|
+
};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A custom hook that determines if the Firebase authentication state is ready.
|
|
3
3
|
* It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* @group Hook
|
|
6
|
+
*
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```jsx
|
|
11
|
+
* export const MyComponent = () => {
|
|
12
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
13
|
+
* console.log(isAuthStateReady);
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
17
|
export declare const useAuthStateReady: () => boolean;
|
|
@@ -3,7 +3,18 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
3
3
|
/**
|
|
4
4
|
* A custom hook that determines if the Firebase authentication state is ready.
|
|
5
5
|
* It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* @group Hook
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
* export const MyComponent = () => {
|
|
14
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
15
|
+
* console.log(isAuthStateReady);
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
7
18
|
*/
|
|
8
19
|
export const useAuthStateReady = () => {
|
|
9
20
|
const firebaseAuth = useAuth();
|
|
@@ -4,7 +4,18 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
4
4
|
/**
|
|
5
5
|
* A custom hook that determines if the Firebase authentication state is ready.
|
|
6
6
|
* It uses Firebase authentication to check if the auth state is ready and updates the state accordingly.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* @group Hook
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* export const MyComponent = () => {
|
|
15
|
+
* const isAuthStateReady = useAuthStateReady();
|
|
16
|
+
* console.log(isAuthStateReady);
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
8
19
|
*/
|
|
9
20
|
export const useAuthStateReady = () => {
|
|
10
21
|
const firebaseAuth = useAuth();
|