Giter VIP home page Giter VIP logo

Comments (8)

wcomicho avatar wcomicho commented on July 23, 2024 1

Take my advice with some skepticism since I'm a python dev just dipping my toes into react + firebase, but this is what I had to do after the change above (in case you are stuck on the google signin):

  • In UserAuthContextProvider.js, add these imports:
    import {signInWithPopup, GoogleAuthProvider } from "firebase/auth";
    -create a new function under the UserAuthContextProvider function
    function googleSignIn() { const googleProvider = new GoogleAuthProvider(); return signInWithPopup(auth, googleProvider); }
  • add this new function to the return statement:
    <userAuthContext.Provider value={{ user, logIn, signUp, logOut, googleSignIn }} >

Nothing extra seems to be needed to "sign UP" with google, initial login through google from a new user creates a user account automatically visible in the firebase console.

these docs were helpful: [https://firebase.google.com/docs/auth/web/google-signin#before_you_begin]

Good luck :)

and thank you @wisdomekpotu for the initial post. Incredibly helpful.

I will try this one out. Just started with Firebase, so need to keep learning for my new job. Thanks again.

from react18-firebasev9-auth.

wisdomekpotu avatar wisdomekpotu commented on July 23, 2024

hi thanks for reaching out.

This error is strange because googleSignIn is Defined in src/context/userAuthContext.js

which is brought in using the method useUserAuth into the Login file

Plz at what point in the tutorial did you encounter this error......i will like more info

from react18-firebasev9-auth.

wisdomekpotu avatar wisdomekpotu commented on July 23, 2024

okay i see where the error might be coming from.

Just Bring it in. i guess i didnt state it in the tutorial
const { logIn, googleSignIn } = useUserAuth();

from react18-firebasev9-auth.

wcomicho avatar wcomicho commented on July 23, 2024

okay i see where the error might be coming from.

Just Bring it in. i guess i didnt state it in the tutorial const { logIn, googleSignIn } = useUserAuth();

Got it. Included it in the code now.

I am now getting error below:
ERROR in ./src/context/UserAuthContext.js 9:0-35
Module not found: Error: Can't resolve '../firebase'

Compiled with problems:

ERROR in ./src/context/UserAuthContext.js 9:0-35

Module not found: Error: Can't resolve '../firebase' in 'C:\playground\react18-firebasev9-auth\src\context'

from react18-firebasev9-auth.

karolkocemba avatar karolkocemba commented on July 23, 2024

Got it. Included it in the code now.

I am now getting error below: ERROR in ./src/context/UserAuthContext.js 9:0-35 Module not found: Error: Can't resolve '../firebase'

Compiled with problems:

ERROR in ./src/context/UserAuthContext.js 9:0-35

Module not found: Error: Can't resolve '../firebase' in 'C:\playground\react18-firebasev9-auth\src\context'

@wcomicho I believe there's a typo in the import. Importing auth from root is not valid in firebase v9, but I believe the author is referencing the "auth" variable defined in line 15 of firebase-config.js

Changing the UserAuthContext.js import to import { auth } from "../firebase-config"; might be what you are looking for.

from react18-firebasev9-auth.

karolkocemba avatar karolkocemba commented on July 23, 2024

Take my advice with some skepticism since I'm a python dev just dipping my toes into react + firebase, but this is what I had to do after the change above (in case you are stuck on the google signin):

  • In UserAuthContextProvider.js, add these imports:
    import {signInWithPopup, GoogleAuthProvider } from "firebase/auth";
    -create a new function under the UserAuthContextProvider function
    function googleSignIn() { const googleProvider = new GoogleAuthProvider(); return signInWithPopup(auth, googleProvider); }
  • add this new function to the return statement:
    <userAuthContext.Provider value={{ user, logIn, signUp, logOut, googleSignIn }} >

Nothing extra seems to be needed to "sign UP" with google, initial login through google from a new user creates a user account automatically visible in the firebase console.

these docs were helpful: [https://firebase.google.com/docs/auth/web/google-signin#before_you_begin]

Good luck :)

and thank you @wisdomekpotu for the initial post. Incredibly helpful.

from react18-firebasev9-auth.

wcomicho avatar wcomicho commented on July 23, 2024

@karolkocemba

Got it. Tried and its working now.

Appreciate your help on this.

Thanks

from react18-firebasev9-auth.

wisdomekpotu avatar wisdomekpotu commented on July 23, 2024

Hello thanks a lot guys for pointing out this....

I will update the article as soon as possible.

from react18-firebasev9-auth.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.