MCPcopy Index your code
hub / github.com/CSFrequency/react-firebase-hooks / useSignInWithPopup

Function useSignInWithPopup

auth/useSignInWithPopup.ts:117–148  ·  view source on GitHub ↗
(
  auth: Auth,
  createProvider: (
    scopes?: string[],
    customOAuthParameters?: CustomParameters
  ) => AuthProvider
)

Source from the content-addressed store, hash-verified

115};
116
117const useSignInWithPopup = (
118 auth: Auth,
119 createProvider: (
120 scopes?: string[],
121 customOAuthParameters?: CustomParameters
122 ) => AuthProvider
123): SignInWithPopupHook => {
124 const [error, setError] = useState<AuthError>();
125 const [loggedInUser, setLoggedInUser] = useState<UserCredential>();
126 const [loading, setLoading] = useState<boolean>(false);
127
128 const doSignInWithPopup = useCallback(
129 async (scopes?: string[], customOAuthParameters?: CustomParameters) => {
130 setLoading(true);
131 setError(undefined);
132 try {
133 const provider = createProvider(scopes, customOAuthParameters);
134 const user = await signInWithPopup(auth, provider);
135 setLoggedInUser(user);
136
137 return user;
138 } catch (err) {
139 setError(err as AuthError);
140 } finally {
141 setLoading(false);
142 }
143 },
144 [auth, createProvider]
145 );
146
147 return [doSignInWithPopup, loggedInUser, loading, error];
148};

Callers 5

useSignInWithFacebookFunction · 0.85
useSignInWithGithubFunction · 0.85
useSignInWithGoogleFunction · 0.85
useSignInWithTwitterFunction · 0.85
useSignInWithOAuthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected