Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Migrating to RN-Firebase v22 #8419

Unanswered
Rakshitg600 asked this question in Q&A
Discussion options

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 (<></>);
};

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.