Introduction
Firebase Authentication provides an easy way to log in users using their already existing social accounts. In this tutorial...
For further actions, you may consider blocking this person and/or reporting abuse
Very well written, thanks! I'm pretty new at React, so learning about useContext was an added bonus.
You're welcome 😊
Hi Mary,
I am trying to use your code for a few days. Keep getting the following message:
Unhandled Rejection (TypeError): Cannot destructure property 'displayName' of 'user' as it is null.
Getting pretty frustrated trying to solve it.
Can you please... help me?
You can use a condition to check IF user is there. Something like this:
Hello, Mary, I've been looking for a tuto like this for two days. Have found several pro devs guides and none of them managed to put things in such a clean way.
To be honest, I'm a newbie with React, have little experience with ES6 and some years as a Java developer. So, I was looking for something that I could not only copy/paste. I was looking for a guide in which I could understand the logic of hooks and Context Providers applied to Firebase authentication.
Your write up is awesome, because I can debug it, if needed. And it is short. And it is clean :)
Thank you very much and keep up with the good job.
If you got this error:
Attempted import error: 'auth' is not exported from 'firebase/app'
try this import:
import firebase from "firebase/app";
require("firebase/auth");
more info here
github.com/firebase/firebaseui-web...
I you're using "firebase": "^9.0.2", read this firebase.google.com/docs/web/modul...
Believe me! This is the best react context tutorial I've found. Thanks for sharing. 🙏🏼
What if I want a user to redirect to login page on doing logout?
Is this a good idea?
import { Redirect } from "react-router-dom";
export const logOut = () => {
auth
.signOut()
.then(() => {
console.log("logged out..");
return ;
})
.catch((error) => {
console.warn(error.message);
});
};
Its not Redirecting after logging in, can anybody tell
I think you have missed two things in the article one is while declaring the UserProvider.js "export default (props)"-props inside the brackets and secondly adding a return statement before redirect. Overall your article was pretty insightful .Keep up the good work buddy
I'll look into it and make changes. Thanks for pointing that out
Thanks for this. I am an upcoming Kenyan developer too and am glad to see we are well represented.
Perfect, thanks !
This is exactly what I was looking for, thank you.
I think:
should be:
Brilliantly written, well done!
Thank you so much Mary, this is exactly what I needed :)
Really helpful!
This is the first article I came across where actually every step end-to-end is well "articulated". Thanks for this!
Hey @Mary Gathoni if you look at Userprovider.js file there will be an error when the user gets logged out because when the user logged out, doesn't have properties like displayName and email.