React Authentication Crash Course With Firebase And Routing

  Рет қаралды 646,747

Web Dev Simplified

Web Dev Simplified

Күн бұрын

🚨 IMPORTANT:
Learn React Today Course: courses.webdevsimplified.com/...
Authentication is crucial for nearly every application. It can also be incredibly difficult to create a good authentication solution. This is where firebase comes in. Firebase makes it incredibly easy to create a secure authentication solution, and in this video I will be showing you how to setup firebase auth with React.
📚 Materials/References:
GitHub Code: github.com/WebDevSimplified/R...
useContext Tutorial: • Learn useContext In 13...
🧠 Concepts Covered:
- How to setup firebase auth
- How to use firebase in React
- How to setup secure Firebase in React
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:43 - Demo
01:38 - Firebase Setup
08:36 - Signup Component
16:03 - Auth Context Setup
20:20 - Signup Component Functionality
25:28 - Auth Loading State
27:11 - Routing Setup
30:11 - Login Component
32:32 - Marker 9
35:44 - Dashboard Component
39:15 - Logout Functionality
41:02 - Private Routes
43:38 - Password Reset
49:17 - Profile Update
55:46 - Outro
#FirebaseAuth #WDS #ReactJS

Пікірлер: 1 200
@shadmanrahman1905
@shadmanrahman1905 2 жыл бұрын
Due to some updates on firebase you can't import firebase like this (import firebase from 'firebase/app') anymore, rather use this ( import firebase from 'firebase/compat/app' ). Same for auth ( import 'firebase/compat/auth' )
@cerealgrapist7386
@cerealgrapist7386 2 жыл бұрын
thanks for commenting with that solution i would of prob given up lol
@joelmounts3336
@joelmounts3336 2 жыл бұрын
bro 🔥🔥🔥
@nikolaisim7863
@nikolaisim7863 2 жыл бұрын
Ty!
@drewgainey9136
@drewgainey9136 2 жыл бұрын
I'm still getting an error in the console saying "app.auth()" is not a function. Any chance you could help me with what i'm doing wrong? import { initializeApp } from "firebase/app"; import 'firebase/compat/auth'; const app = initializeApp({ apiKey: process.env.REACT_APP_FIRBASE_API_KEY, authDomain: process.env.REACT_APP_FIRBASE_AUTH_DOMAIN, projectId: process.env.REACT_APP_FIRBASE_PROJECT_ID, storageBucket: process.env.REACT_APP_FIRBASE_STORAGE_BUCKET, messagingSenderId: process.env.REACT_APP_FIRBASE_MESSAGING_SENDER_ID, appId: process.env.REACT_APP_FIRBASE_APP_ID, }); export const auth = app.auth(); export default app;
@deonvisser2480
@deonvisser2480 2 жыл бұрын
Legend
@GrayFox391
@GrayFox391 2 жыл бұрын
42:48 for anyone stuck with the private route on v6, routes and route components have since changed so this won't work. Also the "Redirect" component will not work. Instead use this for your private route: import React from "react"; import { Navigate } from "react-router-dom"; import { useAuth } from "../contexts/AuthContext"; export default function PrivateRoute({ children }) { const { currentUser } = useAuth(); return currentUser ? children : ; } Then this for the dashboard element in your app.js:
@MiikaKontio
@MiikaKontio 2 жыл бұрын
Thanks! I was getting stuck on this for sure. btw Are you sure that this is the correct way to do things now?
@GrayFox391
@GrayFox391 2 жыл бұрын
@@MiikaKontio No worries, not sure if it's the "correct" way to do things but it's how I was able to get it to work
@MiikaKontio
@MiikaKontio 2 жыл бұрын
@@GrayFox391 i mean is it safe? I dont want people to see Pages they are not supposed To see
@GrayFox391
@GrayFox391 2 жыл бұрын
@@MiikaKontio If a user isn't logged in then they won't be able to access the routes
@mdbhardwaj5005
@mdbhardwaj5005 2 жыл бұрын
Thank man. I was stuck here for hours. Tried React Router Dom documents and all, but none of them worked. Thank you so much again.
@w1ndro1d
@w1ndro1d 2 жыл бұрын
If you are getting 'Firebase: Error (auth/invalid-api-key)', this is caused by your react app not detecting your '.env.local' file. For some reason, this file needs to be placed in the root directory of your app instead of the '.src' folder. Also, in the latest version of react, 'Switch' has been replaced by 'Routes' and you can not use the 'component' prop anymore. It must replaced with 'element' as such: Also, 'useHistory()' is replaced by 'useNavigate()'. Use 'const navigate=useNavigate()' and 'navigate('/')' instead of 'const history=useHistory()' and 'history.push('/')'. 'Redirect' has been replaced by 'Navigate'.
@Kriskata33
@Kriskata33 Жыл бұрын
You are a life-saver
@harshasrisameera8164
@harshasrisameera8164 Жыл бұрын
life saver, thanks for sharing
@natalianatalia3677
@natalianatalia3677 7 ай бұрын
Thank you so much
@d.n.ctalop5560
@d.n.ctalop5560 3 жыл бұрын
Every time I need something, kyle just uploads a video about that, its crazy.
@mhh5002
@mhh5002 3 жыл бұрын
I’m so glad I found this video I was trying to build the user login feature using Firebase for a project.
@alexandruajax824
@alexandruajax824 3 жыл бұрын
ass kisser
@omkarramdasi3087
@omkarramdasi3087 Жыл бұрын
In my case it's reverse...when I watch something ...that exact thing I have to apply next day to solve issues🤣🤣
@naampondpat5769
@naampondpat5769 3 жыл бұрын
Thank you, Kyle - I was struggling with auth process and wanted to find something that's easy to implement high-quality content, nice and clean code - right on point just what I need :) love the way you implement bootstrap in react
@knaz7468
@knaz7468 3 жыл бұрын
I know I'm late to the party but this was a really good video! Can't say I understood everything perfectly but I typed every single line of code along with the video (pausing to keep up with Kyle) and it all works great! Definitely going to take your full courses. All of them. Would love to know more about react and more advanced things like how to switch from dev to prod, using this routing for sites that have a lot of pages (I hope it doesn't get too ugly!), etc.
@davidsaint8866
@davidsaint8866 3 жыл бұрын
I used to dread setting up authentication on react applications, but seeing your nice patterns has made it a lot easier.
@lowkyio
@lowkyio 3 жыл бұрын
Just ported all of this to Nextjs for a starter template. Thank you for the content and keep it up! Your calm demeanor makes it really easy keep coding
@HallOfThought
@HallOfThought 2 жыл бұрын
That was an extraordinary performance! I have rarely ever had any instructor get through so much material in such a condensed manner and still remain coherent.
@michaels393
@michaels393 Жыл бұрын
do all the functions still work? or is it outdated? thinking of coding along
@danielhayes4782
@danielhayes4782 3 жыл бұрын
Keep in mind that if you're using Material UI, you'll have to use inputRef={whateverRef} instead of ref={whateverRef} as the TextField attribute.
@victordeoliveira344
@victordeoliveira344 3 жыл бұрын
Thanks man! Killer hint!
@prabhkang226
@prabhkang226 3 жыл бұрын
After struggling and constantly adding my own style and reading docs to do even the most basic thing, I have come to the conclusion that writing css myself is far more better and under my control.
@escamillaremi3503
@escamillaremi3503 3 жыл бұрын
OH GOD THANK YOU
@namekendrick
@namekendrick 3 жыл бұрын
YES! THANK YOU!
@durgeshnandan5181
@durgeshnandan5181 2 жыл бұрын
I didn't know about inputRef so I used the e.currentTarget.elements in handleSubmit 🥲
@xyntax7019
@xyntax7019 Жыл бұрын
Just got through the intro and love the way you're straight to the point while still sharing some information.
@tevinmorake8924
@tevinmorake8924 3 жыл бұрын
Aftera few years of React experience, I thoroughly enjoyed and learned some new stuff in this video. Thanks Kyle
@PakuBaku
@PakuBaku 2 жыл бұрын
If you have a error with the Switch Module you need to rename it. In the newer react-router-dom versions it was renamed from "Switch" to "Routes" and you have to declare the Route differently now. Instead of " you have to write: "
@refeals
@refeals 2 жыл бұрын
came here to say the same thing. thanks man! react-router-dom's documentation is pretty good too, everyone should check it out for more details
@muhammadaqlan1649
@muhammadaqlan1649 2 жыл бұрын
m stuck at 24:35 saying that 'Failed to create an account' eventho the password is same and more than 6 characters. Any idea?
@hanifali2566
@hanifali2566 2 жыл бұрын
Assalamu alaykum @@muhammadaqlan1649 I had the same error and it was because i imported the signup method as { signup } instead of { signUp }
@sheldon1459
@sheldon1459 Жыл бұрын
@@muhammadaqlan1649 I had the same issue. My resolution had something to do with the env.local file. I hard-coded the values to authenticate with Firebase config and it fixed the issue.
@ianpropst-campbell6028
@ianpropst-campbell6028 Жыл бұрын
Thank you for sharing! I had this same problem too!
@Aaronmoreno
@Aaronmoreno 3 жыл бұрын
I just implemented this in a recent app, but it's really cool to see how you approach it. I may need to do some refactoring now
@yachujoshi
@yachujoshi 3 жыл бұрын
Perfect Tutorial! Loved every single minute of it. Been following you & learning so much :) Thanks Kyle!
@HarrysSecretWife
@HarrysSecretWife 3 жыл бұрын
Thank you so much! You have the clearest, most in-depth and well explained tutorials. Your channel is a blessing. Keep it up!
@erikbachryhl789
@erikbachryhl789 3 жыл бұрын
I spent way too long on error debugging at 24:35 until I found out that the error I was getting was caused by the fact that Firebase has built in password requirements (at least 6 characters long and so forth). Hope someone finds this helpful ;)
@TheLigitaksas
@TheLigitaksas 3 жыл бұрын
Yea its easy to see if inside catch you do catch(error) { console.log(error) } then google says if email already exists or if password to weak and other problems :)
@pekemsx
@pekemsx 3 жыл бұрын
Thank you! I was wondering what I was doing wrong until I read your comment!
@hafsahussein2016
@hafsahussein2016 3 жыл бұрын
@@TheLigitaksas thank you very much I was looking for this
@gnrsn9714
@gnrsn9714 3 жыл бұрын
Legend! Thanks king
@chadkennedy7246
@chadkennedy7246 3 жыл бұрын
Thanks, this is exactly what I was missing!
@aidanwalker3058
@aidanwalker3058 3 жыл бұрын
My favourite react teacher! Im a junior developer and I've struggled finding good content for firebase :)
@worldinnumbers00
@worldinnumbers00 3 жыл бұрын
I follow every tutorial on your channel without missing it. You have simplified web development. I was waiting for this video. Thank you..!!!!
@johnsmith1789
@johnsmith1789 Жыл бұрын
your short and sweet section @ 25:28 on Auth State Loading solved a major headache I was having with my app attempting to load before checking for the user (on page refresh)...the set loading onAuthStateChanged in useEffect....massive help, before it would just redirect but now it checks for the session...SOOOooOOOooOOoo many thanks, Subbed!
@stevendelpercio
@stevendelpercio 3 жыл бұрын
Perfect timing this is exactly what i needed today. Much love.
@holdengjuka1608
@holdengjuka1608 2 жыл бұрын
For anyone having troubles with getting the database url, just leave it blank if it isn't provided by firebase on setup. I'm not entirely sure how it works, but it think it's for the real-time database or something but if you don't have one setup you can just leave the field blank like this: REACT_APP_FIREBASE_DATABASE_URL= with no quotations for a string or anything. Please lmk if this doesn't work or if you have a better understanding, I would love to hear.
@ariw96
@ariw96 2 жыл бұрын
what should i do in the config?
@akashkaushik8684
@akashkaushik8684 Жыл бұрын
same problem
@pritikamishra
@pritikamishra 7 ай бұрын
just create a realtime database in firebase and after creating the database reload the page where you see the config. The link will appear. It worked for me.
@midhatahir8104
@midhatahir8104 3 жыл бұрын
Perfect timing!!!! Everytime I need something, I found perfect video about it on your channel
@tarmac5482
@tarmac5482 3 жыл бұрын
This is really a CRASH course. Just got back on Firebase for a new project, need to brush up and it is perfect all-in-one-place video. Big thanks for doing it.
@SUNYBOI
@SUNYBOI 2 жыл бұрын
This is everything about authentication and that too in just 56 minutes ,, that's amazing.
@codigodesenior3995
@codigodesenior3995 3 жыл бұрын
Hello, I'm a Brazilian programmer, I'm 14 years old and you're helping me a lot, your speech is clean and clear, this is helping me to learn English :) I just got to know your channel and I'm loving it, continue with your great work, which helps thousands of people like me. One day I intend to meet you!
@maskman4821
@maskman4821 3 жыл бұрын
If you make a fortune because of Kyle's tutorials, make sure wire part of it to Kyle's bank accout to support Kyle continuing making awesome tutorial videos !!!
@amankaushik5833
@amankaushik5833 3 жыл бұрын
sure you can support him on Patreon.... the link is in the video description
@codigodesenior3995
@codigodesenior3995 3 жыл бұрын
@@amankaushik5833 yep, but i dont have money now...
@codigodesenior3995
@codigodesenior3995 3 жыл бұрын
@@maskman4821 Its a good idea
@codigodesenior3995
@codigodesenior3995 3 жыл бұрын
@@amankaushik5833 Obs: 1 Dollar in Brazil is 5.75 Reais
@SagarThorat
@SagarThorat 3 жыл бұрын
Hi Kyle, really appreciate your videos. They are helping me learn a few things about react, and full stack dev in general. Thank you for these.
@mod_123_
@mod_123_ 3 жыл бұрын
Subscribed. I love your videos and how much work you put in to help everyone out. The real og.
@alexzimmerman3447
@alexzimmerman3447 Жыл бұрын
We need an updated version for this soooo bad
@Michael-Martell
@Michael-Martell Жыл бұрын
Best I can say is: Firebase docs, or Fireship io next Firebase course.
@zaurhuseyn4432
@zaurhuseyn4432 Жыл бұрын
yes very much wrong with context and in app.js with router-dom dont work
@zaurhuseyn4432
@zaurhuseyn4432 Жыл бұрын
yea i know i want say dont try make project with old video only 2022-23)
@wrighttechnologyinc.1544
@wrighttechnologyinc.1544 Жыл бұрын
Can we please get this updated with NextJS
@SxAde
@SxAde Жыл бұрын
It's mostly the same, the biggest change is way you create protected routes in React Router v6. Dennis Ivy made a great video about how to make it in v6: kzbin.info/www/bejne/aJybf5-be896bas
@augedoo8409
@augedoo8409 3 жыл бұрын
My God! I went through multiple resources online this morning to lookup how to set up firebase with react and now Kyle post a vid on this topic. God is amazing.
@shelbyrothman4522
@shelbyrothman4522 2 жыл бұрын
Thank you Kyle! You transform concept into context like nobody else can!
@jonatanrisaasen2581
@jonatanrisaasen2581 3 жыл бұрын
Really great video! I learned a lot about React and Firebase. You are great at explaining things in a way that makes it easy for the viewer to understand.
@bhagiradhkodamanchili5565
@bhagiradhkodamanchili5565 3 жыл бұрын
I've learned so much from you dude. More valuable than all of Udemy. Thank you
@leerenae313
@leerenae313 2 жыл бұрын
Thank you so much for this Kyle you're an amazing teacher! can you please create an updated tutorial with version 9?
@leerenae313
@leerenae313 2 жыл бұрын
For other firebase newbies you might find this video helpful for working with version 9 : kzbin.info/www/bejne/rJTUn6ynrLV7abM
@sudhamajayanthi
@sudhamajayanthi 3 жыл бұрын
Great tutorial, loved the speed in which you managed to cover the complete topic at the same time in way one can understand well....
@akshatatray556
@akshatatray556 3 жыл бұрын
The best explanation on React Firebase Authentication! Keep the good work up man!
@tom-snively
@tom-snively 3 жыл бұрын
Great so far. I struggled at 24:45 with my apiKey not being set. Please note that whenever you change any of the .env files, you have to stop and restart your "yarn start" process.
@shannon-daygrant8754
@shannon-daygrant8754 3 жыл бұрын
Upvote! This solved my problem. I had to close and npm start again. Many thanks, Tom.
@fullstackburger
@fullstackburger 2 жыл бұрын
3 months later and this solved my problem as well. Thank you!
@johnsunday3548
@johnsunday3548 2 жыл бұрын
Hmmmm! Will give it a try
@davidgurulejr8122
@davidgurulejr8122 2 жыл бұрын
I tried this but it still says that my api key is not valid. I plug in the api key directly instead of the "process.env..." and it works. Not sure what is up there.
@tom-snively
@tom-snively 2 жыл бұрын
@@davidgurulejr8122 I'd try console.logging the process.env.REACT... to see if that is working. I think the variables must start with REACT_APP_ or they will not work.
@anvarsaidov8964
@anvarsaidov8964 2 жыл бұрын
Great tutorial, just starting a new project, and wanted to make sure I'll be able to handle the backend of the auth part. Now I know I have my reference. One thing I guess I missed, since I am new to Firebase, is once I build in development mode how do I seamlessly switch to production.
@darkspark8735
@darkspark8735 2 жыл бұрын
unfortunately, you might wanna not use this video as reference anymore. The version of firebase used in this video is different and firebase v9 was released on sep 1 2021. the syntax, the functions, etc have all changed and its a waste of time trying to troubleshoot. Use the tutorial docs provided by firebase for a more up to date reference.
@FaeUtero
@FaeUtero 3 жыл бұрын
dude! This is brilliant. it is much appreciated. I must say you are rapid! All that hard work shows.
@SpooningTreesap86
@SpooningTreesap86 2 жыл бұрын
I did authentication myself years ago in React Native but you just saved me so much time, thanks!
@bahrambj
@bahrambj 3 жыл бұрын
Perfect timing, it's like you made this video just to help me! You're the best Kyle!
@maskman4821
@maskman4821 3 жыл бұрын
Kyle is everywhere, he can read your mind, and creating awesome content to help people, he is amazing !!!
@yitzchaksviridyuk932
@yitzchaksviridyuk932 3 жыл бұрын
Hi, just a small question. When using react-router-dom, you have 2 options in regards to "history". You can get access to it and use it using the "useHistory" hook like Kyle does in the video. However, you can also just pass it down as a component prop: const Signup = ({history}) => {etc ...} My question is if there's any substantial difference between the two or if it's just a matter of preference. I'd be grateful if anyone could share their knowledge/thoughts on this.
@user-ve2mp4zw7i
@user-ve2mp4zw7i 3 жыл бұрын
Hi, i'm korean, I don't know other description for me.. Your Help is very important for my entire life. I am making a website similar to a bulletin board using React and Firebase, and I needed the authentication function. Thanks to uploading the latest data, I also saved a lot of my time.
@Rafps3player
@Rafps3player 3 жыл бұрын
Your videos are always useful, even years later. Keep up the great content Kyle!!!
@endlesslearning26
@endlesslearning26 3 жыл бұрын
seriously everything went over my head right now maybe i will come back after a while and try again
@bafana_mhlamvu
@bafana_mhlamvu 3 жыл бұрын
Crash course, felt like a full one if you ask me...writing your own back-end is tiresome... Great video dude, thank you!
@jrose2082
@jrose2082 Жыл бұрын
bro. Im at Purdue in CS307 - Software Engineering. You're saving my life with this I got so much done today. bless up
@musabas5341
@musabas5341 3 жыл бұрын
I finally found a really clear and helpful tutorial about Authentication with Firebase. Thank you so much! Great tutorial.
@matthewsullivan2800
@matthewsullivan2800 3 жыл бұрын
This was extremely helpful. May I ask, what’s the best way to create different user roles with react/firebase? Like an admin should be able to see different info on their dashboard. Or if I wanted to distinguish between paid and free users? Thank you.
@lucasser21
@lucasser21 2 жыл бұрын
I would add those roles as any user extra information, in the firestore (another service firebase has). And link with a key each document with the corresponding user.
@noahhoffman5212
@noahhoffman5212 11 ай бұрын
At 6:50 If anyone is getting an error saying "export 'default' (imported as 'firebase') was not found in 'firebase/app" in your project, make sure sure you have the updated import methods for the new firebase release. New way of importing firebase: import firebase from "firebase/compat/app" import 'firebase/compat/auth'; import 'firebase/compat/firestore';
@oxpey4473
@oxpey4473 9 ай бұрын
Then i have app.getAuth is not a function T.T
@yusefturin2122
@yusefturin2122 6 ай бұрын
same thing here stuck for couple hours on this error @@oxpey4473
@nataliefinnegan5050
@nataliefinnegan5050 3 жыл бұрын
this was such a helpful tutorial and straight forward to implement. great explanations along the way. Thank you for helping me understand this!
@diogosoares1309
@diogosoares1309 3 жыл бұрын
So many cool patterns that you use Kyle! It is super fun to learn with you
@tharindumandusanka7708
@tharindumandusanka7708 Жыл бұрын
anyone stuck in 35:00 In react-router-dom v6 useHistory() is replaced by useNavigate(). use below import { useNavigate } from 'react-router-dom'; const navigate = useNavigate(); navigate('/home'); Hope help any one😁😁
@Cami555555Sheep
@Cami555555Sheep Жыл бұрын
god bless you
@jbean92
@jbean92 2 жыл бұрын
I kept getting an error when setting up my routes "Attempted import error: 'Switch' is not exported from 'react-router-dom'." In react-router-dom v6, "Switch" is replaced by "Routes" Update the Route declaration from to useHistory() is replaced by useNavigate() Great tutorial and hope this helps!
@jackhendry6292
@jackhendry6292 2 жыл бұрын
Huge help, Thank you!
@aditalware1952
@aditalware1952 3 жыл бұрын
I love the way Kyle demonstrates, got to learn so many things from him.
@rosegaban
@rosegaban 3 жыл бұрын
This has been such a thorough and easy video to follow! One thing I would have liked to see is more information on how to persist authentication on firebase and some discussion on security implications. Otherwise, this was extremely helpful!
@nidhalbaccouri1799
@nidhalbaccouri1799 3 жыл бұрын
Great crash course and intro to react with firebase integration. Is there a specific reason why you used useRef instead of useState for the email and password? I think the same can be achieved with useState and in a much cleaner way or did I miss something
@SaulLee66
@SaulLee66 3 жыл бұрын
Kyle has a video about useRef. Basically, it's very similar to useState. But when the value store in useRef, the component will not re-render if the value has changed. And it's popular to use it to reference a HTML element.
@noelcovarrubias7490
@noelcovarrubias7490 3 жыл бұрын
Thank you for the video! I tried learning it and I just can't. I don't know if it's the way you explain or if authentication is just a difficult topic for me. Everything else in react I've learn really fast but authentication is giving me problems. I'll read the firebase docs. Again, thank you for the content!
@gavingonzalez7174
@gavingonzalez7174 2 жыл бұрын
yeah, I feel your pain lol
@satindersingh9671
@satindersingh9671 3 жыл бұрын
Love the way you condense the most useful information!🤩
@abiswas97
@abiswas97 Жыл бұрын
This video and it's comments are a god send. Still wrapping my head around contexts, but your linked video was very helpful too :))
@jeremydiaz6494
@jeremydiaz6494 3 жыл бұрын
This was excellent tutorial. I had an error with my Login with the async function handleSubmit. (Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.) Particularly the setLoading(false). If I comment that out I don't receive the error. Can't really figure out why but I left a note to try to figure out why the error happens later. Thanks for the great video.
3 жыл бұрын
I think it is because in the try {} block you have "history.push('/')" that redirects you to Dashboard component and then you try to set "setLoading state" to the Login component that now is unmounted.
@kjro23
@kjro23 3 жыл бұрын
Hey Jeremy, were you able to figure out why this happens? I have the same error and commenting out the loading seems to work for me too. Would like to find out how to fix it permanently though...
@jeremydiaz6494
@jeremydiaz6494 3 жыл бұрын
@@kjro23 Hey so I was still receiving the error. I took what Lavinia stated and just moved the history push outside of the try{} and after the setloading(false). That resolved the error and the history.push still works. :D. Hope that helps setLoading(false) history.push('/profile')
@rickvian
@rickvian 3 жыл бұрын
@@jeremydiaz6494 i dont think you can put history.push(" outside the try block, if there is error on your login, the the catch block will not work properly
@elianhijmansmalessy8736
@elianhijmansmalessy8736 2 жыл бұрын
If anybody gets a memory leak from trying to set a state on an unmounted component in Signup or Login, its because of the setLoading(false) being at the bottom handleSubmit functions which is after you are pushing to a new page. Just move the setLoading(false) be before the history.push.
@Kelden-sf8gs
@Kelden-sf8gs 2 жыл бұрын
HUGE thanks for this. :)
@alanschwarzlopez
@alanschwarzlopez 3 жыл бұрын
Very clear, very simple. This channel deserves the name 👌🏻
@billyjayamunga
@billyjayamunga 2 жыл бұрын
Thank you Kyle. This is exactly what I needed. Keep up the great work!
@usmellfunny2000
@usmellfunny2000 3 жыл бұрын
Great tutorial. But we get this one error just after signing up. I think it has to do with history.push moving to a new page without updating state. "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function." Can you help suggest a fix?
@apurbusarderapu3383
@apurbusarderapu3383 3 жыл бұрын
databaseURL is absent update version of firebase. you find databaseURL in realtime database section. hope someone find this helpful
@moaningscott3930
@moaningscott3930 2 жыл бұрын
I did, thank you
@anshumangogate4806
@anshumangogate4806 2 жыл бұрын
Thank You!
@abhinavdogra3835
@abhinavdogra3835 2 жыл бұрын
THANKS MAN
@mazharimam9216
@mazharimam9216 2 жыл бұрын
yeh right ..so will it work if we continue the lecture?
@2024comingforyou
@2024comingforyou 2 жыл бұрын
Where in realtime database section? Do we have to create a new database?
@slopper
@slopper 3 жыл бұрын
Excellent course! I got stuck for an hour at the end because my password placeholder was not working. Finally realized that the code was correct; the issue was from Firefox using my saved login info.
@ArhisAlight
@ArhisAlight 3 жыл бұрын
Wow, Kyle! Thank you very much! I learnt two things in this video. 1. How to use Firebase in an app. 2. Private Route thing. This video is a poor gold!
@JohnStrandt
@JohnStrandt 3 жыл бұрын
That was really well done, but now I have a headache. lol
@seafoam7881
@seafoam7881 2 жыл бұрын
50 minutes but it actually takes 3+ hours to do because I needed to figure out how to configure everything with the latest firebase 9.
@illestoth9298
@illestoth9298 2 жыл бұрын
Not to mention React Router v6
@dh.bryson1627
@dh.bryson1627 2 жыл бұрын
You figured it out in 3? Lucky… 🥲
@jasongottfried9238
@jasongottfried9238 2 жыл бұрын
Really useful tutorial! Thank you!!! And thank you to those who added comments warning of some of the changes that have happened
@felipetrost
@felipetrost 3 жыл бұрын
Wow, that's really good timing, I just started building my first react app with auth
@goodsamaritan208
@goodsamaritan208 2 жыл бұрын
Protip: Instead of creating a separate development project, use Firebase Emulators to run firebase SDK locally in your machine. It will also save unnecessary bills if you are testing with big data and large no of users.
@ylmazcandelen3121
@ylmazcandelen3121 3 жыл бұрын
if I'm not doing something wrong: using setLoading(false) in finally gives warning on console. because we try to update state after using history.push. - after unmounting instead of doing setLoading(false) in finally (also at the end of an async function) we can do it inside .then before history.push and .catch (also for async functions int try-catch blocks in try before history.push and in catch)
@nivmonovich7976
@nivmonovich7976 3 жыл бұрын
Hi, I'm trying to understand why it happens.. I tried what you suggested and I still get this error in the console. Could you please explain again? Thank you!
@ylmazcandelen3121
@ylmazcandelen3121 3 жыл бұрын
@@nivmonovich7976 I don't know how i can explain better, not that my explanation was perceft just i don't know how to do it. if you don't know about mounting/unmounting components you should look them up, it might help you understand better. it is not exactly same but we can think like we are trying to edit something that no longer exists.
@nivmonovich7976
@nivmonovich7976 3 жыл бұрын
@@ylmazcandelen3121 Thanks! But as I understood the return unsubscribe in the end of the useEffect supposes to 'cleanup' the useEffect function...
@MiikaKontio
@MiikaKontio 2 жыл бұрын
Amazing tutorial. Just what I needed. I got my auth finally set up!
@fonncatalina6464
@fonncatalina6464 3 жыл бұрын
I tried to use react-firebase-hooks before but soooo darn hard to debug, then I tried your code, OMG it works!!! Thank you 3000!!
@maksym.pryhoda
@maksym.pryhoda Жыл бұрын
In case your react app logs out every time you refresh the page, useffect in authcontext should look like that useEffect(() => { const unsubscribe = onAuthStateChanged(auth, (user) => { if (user) { setCurrentUser(user); setLoading(false); } else { setCurrentUser(null); setLoading(false); } }); return () => { unsubscribe(); }; }, []);
@antoniojohnson7693
@antoniojohnson7693 10 ай бұрын
Hero!
@Flexo1986
@Flexo1986 3 жыл бұрын
For anyone getting the error: "Your API key is invalid, please check you have copied it correctly." You have to restart the development server if you changed any .env variables. Just run "npm start" again in the console.
@jonghyeonko3275
@jonghyeonko3275 3 жыл бұрын
Thanks for your kind comment you save my time to traveling with errors
@Flexo1986
@Flexo1986 3 жыл бұрын
@@jonghyeonko3275 happy to help!🙂
@fauxeditor6663
@fauxeditor6663 3 жыл бұрын
I keep getting the error in my console: "Your API key is invalid, please check you have copied it correctly." @Web Dev Simplified
@danielac.2485
@danielac.2485 3 жыл бұрын
@@fauxeditor6663 When I use the API key string directly in firebase file it works but not when it is used as my env variables..
@coffeymay6775
@coffeymay6775 3 жыл бұрын
Same issue here, has anyone figured this out? In development everything works fine, but when i try to deploy, it deploys as a blank page and the console says "Your API key is invalid, please check you have copied it correctly."
@adipati27ma
@adipati27ma 2 жыл бұрын
I like your explanation because it's not too slow and not too fast, but still looks very clear to understand.. Awesome🔥
@Thelandoftheartist
@Thelandoftheartist Жыл бұрын
The best quality content I've seen in this area. I wish the continuation of your success
@tod670
@tod670 3 жыл бұрын
Firebase doesn't provide the database URL anymore.. Hope that isn't a issue. Great vid friend!!!
@demetrissergides7059
@demetrissergides7059 3 жыл бұрын
did it?
@tod670
@tod670 3 жыл бұрын
@@demetrissergides7059 I ended up doing another vid sign in
@stephanieraymos4675
@stephanieraymos4675 3 жыл бұрын
Wondering how to find this too. Can't figure out where to find it Did you ever figure it out?
@tod670
@tod670 3 жыл бұрын
@@stephanieraymos4675 yes you must follow lots of videos, this one and a few more about sending the user a email Verificacion and after add Google sign in etc etc
@stephanieraymos4675
@stephanieraymos4675 3 жыл бұрын
@@tod670 I actually figured out you don’t even need the database URL anymore. It’s deprecated. My site is working fine without it.
@daanketelaars9509
@daanketelaars9509 3 жыл бұрын
I'm at 27:23 and when I enter in a email + 2 correct passwords and then press the "Sign Up" button, I get the error failed to create account. When seeing you do it in the video you get no error. Does this have to do something with database in firebase or do I need to continue a few steps for this to be fixed?
@rtcodes4618
@rtcodes4618 2 жыл бұрын
Hi! :) Have you found a solution for it? I'm also stuck at that part of the code, as I keep getting the same alert, although the passwords match
@daanketelaars9509
@daanketelaars9509 2 жыл бұрын
@@rtcodes4618 I think I did yeah, it's a pretty strange one. I figured it out today actually haha. You need at least 6 characters for your password to be successful. That's why you keep getting an error, even if the passwords match. Very strange and will see if I can add an message for this or find a solution.
@brittosmonteiro
@brittosmonteiro 3 жыл бұрын
This is simply amazing. Thank you so much for providing such a great content!
@davidgonzalez965
@davidgonzalez965 3 жыл бұрын
Man this channel is the best. Not only the content is awesome but you also find solutions to problems you might run into in the comments. Thanks a lot y'all!
@ahsantahseen6531
@ahsantahseen6531 3 жыл бұрын
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. in Signup (created by Context.Consumer) Guys even tho this works but im getting this warning
@somkl7617
@somkl7617 3 жыл бұрын
Here's the solution if anyone is still looking for it. It was provided by someone called Lavinia Ţole in this comment section: "I think it is because in the try {} block you have "history.push('/')" that redirects you to Dashboard component and then you try to set "setLoading state" to the Login component that now is unmounted. I moved setLoading(false) after the await function and before the history.push('/') and the error is now gone."
@MultiBBB3
@MultiBBB3 3 жыл бұрын
@@somkl7617 Thx! :)
@rickvian
@rickvian 3 жыл бұрын
@@somkl7617 but if the login error, that will never loading set to false! you have to put that after setError in the catch block as well!
@BookOfSaints
@BookOfSaints 3 жыл бұрын
When logging in for the first time, I get the following error in the console: (any ideas why?) Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function
@brendandefaria4495
@brendandefaria4495 3 жыл бұрын
Getting that too, is it because state is being set from the useEffect hook maybe?
@shannon-daygrant8754
@shannon-daygrant8754 2 жыл бұрын
I've read elsewhere that it might have to do with setLoading(false) in Login.js taking place AFTER the history.push('/') so I'm commenting that here for anyone in the future. Not sure though.
@Hazzahs
@Hazzahs 3 жыл бұрын
Thank you so much for this tutorial! Informative and straight to the point, thank you again!
@RahulGupta-pj1ux
@RahulGupta-pj1ux 3 жыл бұрын
Hey Kyle, great to see you making videos about Firebase. Just a request, can you make a video on Scheduling job (for ex. If a teacher want to schedule a test at 9:00 am) using firebase/fireStore. It would be a great help.
@RinatYouldashbaev
@RinatYouldashbaev 3 жыл бұрын
Thank you, great tutorial! But there's a "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function." How to fix this? I modified "AuthContext.js" file a little bit. I added in useEffect "unsubscribe" function this: return function cleanup() { AbortController.abort()} - it didn't help. This warning appears after you press Log in.
@eduardserei6859
@eduardserei6859 3 жыл бұрын
I got the same error, I cloned the repo in the description and got the same error. It happens because in Login.js there is setLoading(false) which updates the component AFTER the history.push('/'). This updates the Login component after it is unmounted. I'm guessing Kyle probably forgot to delete it :P there is no need for it as when the component mounts again, the inital loading state is set to false again.
@klhmia
@klhmia 3 жыл бұрын
Hey guys, make sure you put 'email' as a parameter of the resetPassword(email) function within the AuthContext.js since we're passing in 'emailRef.current.value' as an argument within the ForgotPassword.js component. I also had this error and that was my issue which solved it.
@rickvian
@rickvian 3 жыл бұрын
@@eduardserei6859 it is needed if the login is failed, you have to set the loading to false
@agu7432
@agu7432 2 жыл бұрын
Someone solved it? Thanks
@robertzuk7046
@robertzuk7046 2 жыл бұрын
@@eduardserei6859 the same problem exists in the UpdateProfile. Remove setLoading(false) solved it
@sabermehdi7857
@sabermehdi7857 Жыл бұрын
can't find REACT_APP_FIREBASE_DATABASE_URL
@emmanuelkofyagyapong6382
@emmanuelkofyagyapong6382 Жыл бұрын
There has been an update to Firebase so now I do not think we have it anymore...
@addictedSK
@addictedSK 2 жыл бұрын
from other youtuber tutorials i have to do x1.25 and in your tutorial i have to pause to catchup.... your tutorials are crisp and to the point
@dennissavai337
@dennissavai337 3 жыл бұрын
This what i was just looking for to build complete applications. Thanks
@intlconxun
@intlconxun 3 жыл бұрын
My Firebase configuration doesn’t show a databaseURL. What do I do?
@omarbenseddik8910
@omarbenseddik8910 3 жыл бұрын
You can find it under Realtime Database
@user-ku2fy9rx8r
@user-ku2fy9rx8r 3 жыл бұрын
Don’t worry it’s not something you need to have
@pedrovsn
@pedrovsn 3 жыл бұрын
TypeError: Cannot destructure property 'signup' of 'Object(...)(...)' as it is undefined.
@dashxanurag
@dashxanurag 3 жыл бұрын
Did you find any solution ?
@chrismacdonald2836
@chrismacdonald2836 3 жыл бұрын
Likely forgot to add the AuthProvider in App.js
@joseteran9123
@joseteran9123 2 жыл бұрын
Same error. I couldn't find the solution.
@steve2709
@steve2709 3 жыл бұрын
Thank you! Your tutorial is very easy to follow. The only part I found that is difficult to understand is the PrivateRoute component. I understand its purpose, but still struggle to understand how the PrivateRoute component was put together
@vinothkumars7421
@vinothkumars7421 3 жыл бұрын
Hi Kyle, as you said... "You do make web development simplified" Thanks a lot.
@adrianpop6521
@adrianpop6521 3 жыл бұрын
any clue why I get this "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function." when logging in? Login works but this error is in the console, even with the "unsubscribe" cleaning function in AuthContext. Thanks
@LeetCodeSimplified
@LeetCodeSimplified 3 жыл бұрын
Everything works, though I get a warning when logging in. Even when using the cloned repo. "Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function."
@perwisyogaming5445
@perwisyogaming5445 3 жыл бұрын
Same here, but I did the ubsubsrcibe thing.
@dylanroberts6217
@dylanroberts6217 3 жыл бұрын
same
@jackdaisuki502
@jackdaisuki502 2 жыл бұрын
same. how we can fix this?
@animeshdeb7017
@animeshdeb7017 7 ай бұрын
Amazing work! I followed after making some minor changes and everything worked properly!
@rajatsawarkar
@rajatsawarkar 3 жыл бұрын
everything i needed was in this video, love you buddy and many thanx SUBSCRIBED :)
How This Test Saved Kent’s Site
7:04
Web Dev Simplified
Рет қаралды 77 М.
Auth Does NOT Have To Be Hard
17:13
Web Dev Simplified
Рет қаралды 95 М.
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 6 МЛН
1 класс vs 11 класс  (игрушка)
00:30
БЕРТ
Рет қаралды 3,6 МЛН
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 70 МЛН
Firebase - Back to the Basics
25:23
Fireship
Рет қаралды 580 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 155 М.
How To Create A Navbar In React With Routing
19:16
Web Dev Simplified
Рет қаралды 366 М.
The Secrets of Arcane 2 Teaser Explained
18:37
Necrit
Рет қаралды 171 М.
If You Cannot Name All 5 JS Scopes You Need To Watch This Video
15:06
Web Dev Simplified
Рет қаралды 38 М.
10 Tailwind Classes I Wish I Knew Earlier
13:31
Web Dev Simplified
Рет қаралды 162 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 148 М.
NEW React 19 Changes Are Amazing!
8:42
Web Dev Simplified
Рет қаралды 175 М.
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 6 МЛН