Comments (8)
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 theUserAuthContextProvider
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.
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.
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.
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.
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.
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 theUserAuthContextProvider
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.
Got it. Tried and its working now.
Appreciate your help on this.
Thanks
from react18-firebasev9-auth.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react18-firebasev9-auth.