ReferenceError: Can’t find variable: auth
please help
const handleLogin = () => {
auth
.signInWithEmailAndPassword(email, password)
.then(userCredentials => {
const user = userCredentials.user;
console.log('Logged in with:', user.email);
})
.catch(error => alert(error.message))
}
3
Answers
Where do you expect
auth
to come from?If you’re following the Firebase documentation, the getting started page initialized an
auth
variable as:Install
@react-native-firebase/auth
fromnpm install @react-native-firebase/auth
and import
import auth from '@react-native-firebase/auth'
Install firebase/auth package
and import auth package in the component where it used
for details, refer to this link https://rnfirebase.io/auth/usage
and it should be like this
auth().signInWithEmailAndPassword(email, password)