Learn React Hooks: useContext - Simply Explained!

  Рет қаралды 112,858

Cosden Solutions

Cosden Solutions

11 ай бұрын

Join The Discord! → discord.cosdensolutions.io
Source Code → github.com/cosdensolutions/co...
In this video we will learn about React hooks, starting with useContext. This powerful React hook will allow you to manage your state efficiently without having to pass an enormous amount of props around (prop drilling). You will learn how to identify when to use the React Context API, how to use createContext to create the context, create a custom hook to handle undefined values, and finally use the context in any component to get access to the data.
In this new React world, hooks are here to stay, so it's best to learn them! In this tutorial I demonstrate the useContext React hook, and I explain it very simply and in a way that is easy to understand. Enjoy!

Пікірлер: 230
@cosdensolutions
@cosdensolutions Ай бұрын
Hey everyone! I just launched 🚀 Project React, which is a course that teaches you React by building a real-world project. It goes way beyond what you see in these videos and walks you through step-by-step on how to build a big and complex application with React! You can check it out here: cosden.solutions/project-react
@GeraldPajulas
@GeraldPajulas 4 ай бұрын
Thank you. I've been learning React for about 4 days and I was confused about the useContext and createContext, but your video explains it well. Thank you.
@HR-pz7ts
@HR-pz7ts 2 ай бұрын
It's amazing you also taught how to deal with problems and showed proper way to code and handle potential errors.
@shubhankarvalimbe5286
@shubhankarvalimbe5286 7 ай бұрын
Great tutorial! I was so confused about how Context works, every other creator complicates it too much. Thank you for simplifying it. Just subbed!
@cosdensolutions
@cosdensolutions 7 ай бұрын
makes me happy to hear!
@mikoajkulczynski5213
@mikoajkulczynski5213 6 ай бұрын
Thank you for the content. You have the gift to talk about coding in a simple way.
@cosdensolutions
@cosdensolutions 6 ай бұрын
thank you for the kind words!
@marshallfungai3033
@marshallfungai3033 4 ай бұрын
Thanks man, been watching your videos for the last 7 days. Practicing for mid-senior dev job... Now I feel like a junior dev 😁, because of all the content I learnt. I "was" a "I can do it, but I can not explain it" person. But the upside is now I "REALLY" know what to do. Just subscribed. And we need more videos on testing.
@osmankain1508
@osmankain1508 Ай бұрын
Wow you're a perfect teacher and programmer thanks for the time that you spent for this amazing content
@camilotorresf1
@camilotorresf1 11 ай бұрын
This was a really good explanation. I took notes and later was able to replicate a similar example. I now understand the useContext hook a lot better. I'm just starting with React and this is really my first application, although I work with a team in a project that already have a lot of react. I expect to become more proficient in React to really be able to work on that project. Keep the good work, I hope you get a lot of subscribers soon.
@cosdensolutions
@cosdensolutions 11 ай бұрын
Really happy to hear that dude! You're going to do great ☺️ thank you for the kind words!
@lordkonadukweku6965
@lordkonadukweku6965 5 ай бұрын
@@cosdensolutions please when are going to do a video on HOC
@jijocleetus
@jijocleetus 4 ай бұрын
Great one with context, i like the way you handled the undefined scenario. Thanks for the tutorial.
@AntNZ
@AntNZ 11 ай бұрын
Wow! Such a excellent explanation and with examples too. Well done 👏👏👏👏
@cosdensolutions
@cosdensolutions 11 ай бұрын
Glad you enjoyed it! 🤙
@Chris-by8tg
@Chris-by8tg 3 ай бұрын
This was the clearest explanation I've seen. Thank you!
@jay-kv6wn
@jay-kv6wn 11 ай бұрын
I hope your videos go viral soon like they should. You are doing a great work with your explanations
@cosdensolutions
@cosdensolutions 11 ай бұрын
Haha imagine going viral for React 😅 would love it!
@user-sy5fd7kn8w
@user-sy5fd7kn8w Ай бұрын
Hands down best explanation of the topic on the tube. Thank you!
@garudaphoenix5479
@garudaphoenix5479 10 ай бұрын
Thanks for this great and clear explanation with a lot more edges. Hope you will get 1 million subs soon. Tbh, You deserve it.
@cosdensolutions
@cosdensolutions 10 ай бұрын
Thanks a lot 🤙
@user-gm3lg8gp3m
@user-gm3lg8gp3m 9 ай бұрын
I subscribed!! This is a great way to explain the concept + thanks for adding the error handling part 👍
@cosdensolutions
@cosdensolutions 9 ай бұрын
🤙
@wekesirken6961
@wekesirken6961 4 ай бұрын
That was some good explanation, you made contexts seem obvious...Appreciated
@franbrankovic3617
@franbrankovic3617 7 ай бұрын
After this video you really don't need to watch another video about react useContext. This was excellent video.
@vampirekabir
@vampirekabir 10 ай бұрын
trying to get a grasp of it,nobody taught like u did,i finally get it now ❤❤
@cosdensolutions
@cosdensolutions 10 ай бұрын
🤙
@YisneySoto
@YisneySoto 7 ай бұрын
Great, thanks. It's my first Context video and I think I got it at the first time because it's so well explained, of course having used Redux before makes this easier to understand.
@cosdensolutions
@cosdensolutions 7 ай бұрын
glad to hear it!
@sub_in01
@sub_in01 8 ай бұрын
Bro I really love your content and I learn a lot from you, don't worry about subscribers, they will ultimately come to you as your way of explaining is so very good. Keep uploading contents.
@cosdensolutions
@cosdensolutions 8 ай бұрын
thanks for the kind words! 🤙
@shawn.builds
@shawn.builds 17 күн бұрын
been loving the react tutorials man! dont think anyones ever explained context so simply :)
@XXlikeabauss
@XXlikeabauss 9 ай бұрын
Really helpful video, thank you so much!
@kwasiezor1630
@kwasiezor1630 11 ай бұрын
Thanks for the video bro. Simplified explanation always makes understanding better 😊
@cosdensolutions
@cosdensolutions 11 ай бұрын
Glad you found it useful!
@kwasiezor1630
@kwasiezor1630 11 ай бұрын
Yes Indeed. Keep it up 👏
@rmc1579
@rmc1579 4 ай бұрын
great explanation. I was a little bit confuse when using context and how to implement them.
@ThomasKanzig
@ThomasKanzig 7 ай бұрын
Amazing tutorial. Thanks a lot.
@mchisolm0
@mchisolm0 26 күн бұрын
Definitely appreciate your attention to detail and have earned my sub. You helped me understand how I was having trouble with a boilerplate I use that has a useState inside a useEffect. I understand *what* the problem is now (thank you for that video), but I can't figure out what I need to learn to solve it. Thanks for at least helping me get closer.
@ooorayooonyoooo
@ooorayooonyoooo 10 ай бұрын
A really underrated channel, well done bro! ⚡❤
@Shaheer-xs5os
@Shaheer-xs5os 9 ай бұрын
That was such an awesome explanation 👍
@cosdensolutions
@cosdensolutions 9 ай бұрын
Thanks 🤙
@AhmedHuzain
@AhmedHuzain 4 ай бұрын
"If you watch this hook video, you'll probably never need to watch another" This is so true! You explain it so well. Thank you!
@syedayanata9765
@syedayanata9765 7 ай бұрын
I watched many videos and still did not understand context but this video helped me a lot.
@cosdensolutions
@cosdensolutions 7 ай бұрын
you got this
@simplebutcorrect6176
@simplebutcorrect6176 7 ай бұрын
Bro I love the way that you explain keep it up. Subscribed❤
@joshuaagudelo29
@joshuaagudelo29 8 ай бұрын
Well explained!
@lordkonadukweku6965
@lordkonadukweku6965 5 ай бұрын
Top-notch explanation. Manifesting 100k subscribers by end of this year
@leonardmbibi8013
@leonardmbibi8013 7 ай бұрын
Top notch! You're the man
@theppiwatkomolwat4429
@theppiwatkomolwat4429 5 ай бұрын
1:31 This part of the code worked; I have now subscribed!
@cosdensolutions
@cosdensolutions 5 ай бұрын
☺️
@mgx49
@mgx49 2 ай бұрын
No doubt I won't need to watch another React Context API video! [Subscribed]
@glenmccallum7051
@glenmccallum7051 7 ай бұрын
Thanks a lot, this was really helpful. Really great video and great channel
@cosdensolutions
@cosdensolutions 7 ай бұрын
glad it helped!
@sup_nim
@sup_nim 8 ай бұрын
great explaination thank you bro!
@myothiha1168
@myothiha1168 9 ай бұрын
best explanation ever!🤩
@omkarjagtap2212
@omkarjagtap2212 2 ай бұрын
man, awosome video crystel clear concepts and learned how to write a more safe code(in the pov for debugging)
@HerlonCosta
@HerlonCosta 5 ай бұрын
I reall like this explanation. You're very good, god bless you!
@sudiptobose8296
@sudiptobose8296 2 ай бұрын
Fantastic tutorial. I really appreciate it. 😊
@thebeastsclips
@thebeastsclips 5 ай бұрын
useContext is a great alternative for a bunch of prop drilling with a bunch of useStates as well in the child component as well.
@antimrevapati8992
@antimrevapati8992 3 ай бұрын
Great Explanation, Thank you!
@tokaqarcivadze5825
@tokaqarcivadze5825 6 ай бұрын
the way you explain react is the best!
@cypherop2608
@cypherop2608 4 ай бұрын
you made it soooooo easy to understand
@Teddyrobinson
@Teddyrobinson 3 ай бұрын
Another great tutorial thanks so much!
@brNoMundo123
@brNoMundo123 2 ай бұрын
Sou desenvolvedora Júnior e seus vídeos estão me ajudando muito a me desenvolver 🚀
@Fleischmann773
@Fleischmann773 7 ай бұрын
Great example!!!
@user-dm3sf9mk2o
@user-dm3sf9mk2o 7 ай бұрын
This was a really good explanation. Would you consider doing a video about useContext in regards to forms?
@cosdensolutions
@cosdensolutions 7 ай бұрын
sure!
@user-dm3sf9mk2o
@user-dm3sf9mk2o 6 ай бұрын
@@cosdensolutionsI get stuck on passing input content to the page. Trying different ways without too much success.
@UnfinishedYara
@UnfinishedYara 3 ай бұрын
Thanks man! Crystal clear now!
@ihebbenaicha1353
@ihebbenaicha1353 11 ай бұрын
please keep it up with more hooks and thank you !
@cosdensolutions
@cosdensolutions 11 ай бұрын
Will do!
@samahgad241
@samahgad241 4 ай бұрын
Realy great explanation,thank you
@user-el9ui5jk5m
@user-el9ui5jk5m Ай бұрын
I literally subscribed after seeing your message in the Video
@Martin-xf8be
@Martin-xf8be 5 ай бұрын
That subscribe intro you did made me subscribe. Genius.
@user-wq9xz9yc7c
@user-wq9xz9yc7c 5 ай бұрын
I speak another language, but I'm happy to find this video. Thanks!
@cosdensolutions
@cosdensolutions 5 ай бұрын
Working on adding translated captions to all videos soon!
@vivekkumar-pc1xy
@vivekkumar-pc1xy 5 ай бұрын
Crystal Clear... Thanks
@safareesamuels4674
@safareesamuels4674 5 ай бұрын
Home of React well explained Tutorials
@shekhtausif2811
@shekhtausif2811 11 ай бұрын
Just make more videos like this on react plz you explain really well
@cosdensolutions
@cosdensolutions 11 ай бұрын
Will do!
@Pareshbpatel
@Pareshbpatel 6 ай бұрын
Context API with a custom hook, so well explained. Thank you. {2023-10-16}
@Vishal360
@Vishal360 7 ай бұрын
loved ur react tuts.... 🔥🔥🔥🔥🔥🔥🔥🔥
@deshannawarathna6283
@deshannawarathna6283 4 ай бұрын
Thank you man. That is good explanation
@sathirabandara7981
@sathirabandara7981 3 ай бұрын
Great job man. its very helpful !!
@marceloleoncaceres6826
@marceloleoncaceres6826 4 ай бұрын
Great video, thanks for sharing your time and knowledge,
@theGameThrough
@theGameThrough 10 ай бұрын
It would be suggested to put some console log and also the UI just to make it more clear would be a lot helpful too thanks
@poornasaipilla1620
@poornasaipilla1620 2 ай бұрын
Really use full video thanks for doing ... extending my great full and encouragement .... keep doing well..
@israelkayaba6002
@israelkayaba6002 5 ай бұрын
Thanks bro, much appreciated !
@codehustler8582
@codehustler8582 2 ай бұрын
Amazing Channel for Learning React
@MarksmanVallecillo
@MarksmanVallecillo 7 ай бұрын
Thanks, man very good video. 10 Stars ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
@RyS29
@RyS29 5 ай бұрын
Great content, thank you!
@PravinsPhotos
@PravinsPhotos 3 ай бұрын
I really did subscribe at 1:57...good one there😂
@dobindahoria4633
@dobindahoria4633 8 ай бұрын
this is gold
@awasum
@awasum 3 ай бұрын
Thank you very much. Good content
@user-ms4cs3cb4w
@user-ms4cs3cb4w 4 ай бұрын
Thanks it was very helpful
@suvakshaacharya6900
@suvakshaacharya6900 2 ай бұрын
thanks . helped a lot
@rasikakshirsagar5563
@rasikakshirsagar5563 3 ай бұрын
Thank you bro!
@nogafouz2174
@nogafouz2174 4 ай бұрын
realy thank you but i have a question please which better using context api or redux tookit
@Bilo_7
@Bilo_7 9 ай бұрын
I made an instant subscription 👍
@cosdensolutions
@cosdensolutions 9 ай бұрын
🤙
@mark-broomfield
@mark-broomfield 5 ай бұрын
Great tutorial thanks. My subwoofer got a serious workout every time you banged the mic though :-)
@cosdensolutions
@cosdensolutions 5 ай бұрын
LOL 😂 it gets better in later videos I promise!!!
@juststudying1019
@juststudying1019 3 ай бұрын
Amazing channel, thanks.
@admasterefe4340
@admasterefe4340 Ай бұрын
GOD level explanation. I want everyone to subscribe to this channel. Too bad one can't give two likes.
@antoninosartori
@antoninosartori 6 ай бұрын
And what if User comes from a fetch? Do you put in on the custom hook? How would you handle errors? Thanks for the video
@hanguyenmanh2459
@hanguyenmanh2459 5 ай бұрын
If user come from server state, don't throw error in custom hook, just return user.
@qweqw1359
@qweqw1359 9 ай бұрын
Nice 👍
@mahdighasemi9518
@mahdighasemi9518 8 ай бұрын
Thanks a lot.
@thesnowqueen98
@thesnowqueen98 8 ай бұрын
Could you tell the name of the VS Code Theme you are using?
@mai.krishnahoon
@mai.krishnahoon 3 ай бұрын
Thanks from india..
@user-lg2xl1ik9k
@user-lg2xl1ik9k 2 ай бұрын
The best video about useContext! Your explanation is super clear and easy to follow, thank you so much! And, I found your import seems to have an alias like @page/../../../dashboard.tsx. Can you make a video to share how to set it up? I've been looking for how to setup path alias in React for a long time.
@cosdensolutions
@cosdensolutions 2 ай бұрын
I have a short on it actually!
@nabilachehlafekir8577
@nabilachehlafekir8577 7 ай бұрын
thank you
@fun2rideadventure
@fun2rideadventure 9 ай бұрын
... done ... subscribed :) !!!
@shubhamshekhar23
@shubhamshekhar23 4 ай бұрын
Hi Cosden, Can you please also explain how does changing variable in a Context can cause rendering of the whole tree inside. I had created a global conttext and provided in the root of the App. Now, A deeply nested component changes the var in this context but I can see that the whole app is getting rendered (but that deeply nested component consuming that context should rerender right?) Any help and clarification is much appreciated. Thanks 🥸
@brunopagno
@brunopagno 6 ай бұрын
Nice video!
@abdulbasir8740
@abdulbasir8740 4 ай бұрын
Hey, thank you! are you using VIM?
@Atomatiz
@Atomatiz 4 ай бұрын
Cosden. I love you bros 😉
@satadhi
@satadhi 5 ай бұрын
Great explaination ! If I may ask can I get the github link or the code used for the example. Thanks a lot
@cosdensolutions
@cosdensolutions 5 ай бұрын
it's in the description!
@abdoseadaa
@abdoseadaa 3 ай бұрын
i put like b4 watching your videos :) legend
@niconel7659
@niconel7659 6 ай бұрын
Thanks for the reminder to subscribe. Guilty as charged, but subscribed now.
@Atul_25
@Atul_25 Ай бұрын
Thanks for making in ts
@jouebien
@jouebien 5 күн бұрын
grouse wrapping the context in a hook. You can build up the provider with state & mutators and pass that to the value of the provider. There's no need to wrap the context with hook jank to extend the context -> with a wrapped hook A) you're not enforce access & mutations B) you also have an extra shit tonne of renders as the hook runs through state changes in every component C) you remove the useContext which hides the fact the component is consuming global/shared state.
@felippenvieira
@felippenvieira 4 ай бұрын
Cosden, for example, if we are using JWT authentication, could this approach be replaced by Server Action? I mean, I have a middleware checking if some route is being used. If it's being used, it will check if the user is logged in by reading the authentication cookie. If the answer is no, the middleware will redirect the user to the login page, otherwise it will allow the user to access the route. Also, the server action will do the job of caching the authentication, and we can have access to the user action. With this approach, can we get ride of the useContext?
@cosdensolutions
@cosdensolutions 4 ай бұрын
yeah in that case you could!
@user-sm3rx2uw7r
@user-sm3rx2uw7r 8 ай бұрын
Please make a zustand tutorial as well
@cosdensolutions
@cosdensolutions 8 ай бұрын
It's on the list!
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 70 М.
Context API in react | get the concept
29:00
Hitesh Choudhary
Рет қаралды 35 М.
ВИРУСНЫЕ ВИДЕО / Мусорка 😂
00:34
Светлый Voice
Рет қаралды 11 МЛН
Каха с волосами
01:00
К-Media
Рет қаралды 5 МЛН
Her Birthday Was Ruined 😰😩 He Created A Trap For Her🙀
00:40
Giggle Jiggle
Рет қаралды 4,7 МЛН
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 314 М.
How To Type Children In React? JSX.Element vs ReactNode
3:30
Oskar Puchalski
Рет қаралды 1,4 М.
React useContext() hook introduction 🧗‍♂️
11:37
Bro Code
Рет қаралды 12 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
You might not need useEffect() ...
21:45
Academind
Рет қаралды 131 М.
ВИРУСНЫЕ ВИДЕО / Мусорка 😂
00:34
Светлый Voice
Рет қаралды 11 МЛН