You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Help me with this error please.
Property 'credential' does not exist on type 'FirebaseModuleWithStaticsAndApp<Module, Statics>'.ts(2339)
Error Snippet:
import GoogleAuthProvider,{ getAuth, signOut, onAuthStateChanged } from '@react-native-firebase/auth';
const auth = getAuth();
const googleCredential = GoogleAuthProvider.credential(idToken);
const userCredential = await getAuth().signInWithCredential(googleCredential);
Whole Code:
import { GoogleSignin } from '@react-native-google-signin/google-signin';
import GoogleAuthProvider,{ getAuth, signOut, onAuthStateChanged } from '@react-native-firebase/auth';
GoogleSignin.configure({
webClientId: WEB_CLIENT_ID,
});
const auth = getAuth();
const App = () => {
const [user, setUser] = useState(null);
useEffect(() => {
const subscriber = onAuthStateChanged(auth, (usr: any) => {
setUser(usr);
});
return subscriber;
}, []);
const handleSignOut = async () => {
try {
await GoogleSignin.signOut();
await signOut(auth);
setUser(null);
} catch (error) {
console.error('Sign out error:', error);
}
};
const handleSignIn = async () => {
try {
await GoogleSignin.hasPlayServices();
await GoogleSignin.signIn();
const { idToken } = await GoogleSignin.getTokens();
if (!idToken) {
throw new Error("Google Sign-In failed: No ID Token received.");
}
const googleCredential = GoogleAuthProvider.credential(idToken);
const userCredential = await getAuth().signInWithCredential(googleCredential);
const currentUser = userCredential.user;
setUser(currentUser);
} catch (error) {
console.error('Google Sign-In error:', error);
}
};
return (<></>);
};
Beta Was this translation helpful? Give feedback.
All reactions