the-road-to-react-with-firebase / react-redux-firebase-authentication

🔥Boilerplate Project for Authentication with Firebase in React and Redux
https://www.robinwieruch.de
285 stars 85 forks source link

onAuthStateChanged #1

Open Gallevy opened 6 years ago

Gallevy commented 6 years ago

First of all, very good sample, But why do you register to onAuthStateChanged on every component that needs permission(withAuthorization), Shouldn't that be handled differently since you already listen to it in the withAuthentication component

rwieruch commented 6 years ago

Hey. Thank you for reaching out. I would say it is semi optimal. It's not that you should wire every component to withAuthorization. My feeling is that it should happen on the top layer and thus you would listen two times on firebase changes for the auth user: withAuthentication & withAuthorization. Since the authUser shouldn't change often, only for sign up, sign in and sign out, I would say it is a minor performance problem. But I get your point here!

Would you want to propose a different solution in a PR in https://github.com/rwieruch/react-firebase-authentication/ (plain React Firebase) just to showcase how it could be done differently? Perhaps it would be a great opportunity for me to adjust the material :) Thanks again for reaching out.