Learn React Hooks: useContext - Simply Explained!

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!

Пікірлер: 244

  • @cosdensolutions
    @cosdensolutions2 ай бұрын

    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

  • @mikoajkulczynski5213
    @mikoajkulczynski52137 ай бұрын

    Thank you for the content. You have the gift to talk about coding in a simple way.

  • @cosdensolutions

    @cosdensolutions

    7 ай бұрын

    thank you for the kind words!

  • @GeraldPajulas
    @GeraldPajulas5 ай бұрын

    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.

  • @osmankain1508
    @osmankain15082 ай бұрын

    Wow you're a perfect teacher and programmer thanks for the time that you spent for this amazing content

  • @shubhankarvalimbe5286
    @shubhankarvalimbe52868 ай бұрын

    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

    8 ай бұрын

    makes me happy to hear!

  • @HR-pz7ts
    @HR-pz7ts3 ай бұрын

    It's amazing you also taught how to deal with problems and showed proper way to code and handle potential errors.

  • @Chris-by8tg
    @Chris-by8tg4 ай бұрын

    This was the clearest explanation I've seen. Thank you!

  • @user-sy5fd7kn8w
    @user-sy5fd7kn8w2 ай бұрын

    Hands down best explanation of the topic on the tube. Thank you!

  • @AntNZ
    @AntNZ Жыл бұрын

    Wow! Such a excellent explanation and with examples too. Well done 👏👏👏👏

  • @cosdensolutions

    @cosdensolutions

    Жыл бұрын

    Glad you enjoyed it! 🤙

  • @shawn.builds
    @shawn.buildsАй бұрын

    been loving the react tutorials man! dont think anyones ever explained context so simply :)

  • @jay-kv6wn
    @jay-kv6wn Жыл бұрын

    I hope your videos go viral soon like they should. You are doing a great work with your explanations

  • @cosdensolutions

    @cosdensolutions

    Жыл бұрын

    Haha imagine going viral for React 😅 would love it!

  • @camilotorresf1
    @camilotorresf1 Жыл бұрын

    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

    Жыл бұрын

    Really happy to hear that dude! You're going to do great ☺️ thank you for the kind words!

  • @lordkonadukweku6965

    @lordkonadukweku6965

    6 ай бұрын

    @@cosdensolutions please when are going to do a video on HOC

  • @marshallfungai3033
    @marshallfungai30335 ай бұрын

    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.

  • @user-gm3lg8gp3m
    @user-gm3lg8gp3m10 ай бұрын

    I subscribed!! This is a great way to explain the concept + thanks for adding the error handling part 👍

  • @cosdensolutions

    @cosdensolutions

    10 ай бұрын

    🤙

  • @jijocleetus
    @jijocleetus5 ай бұрын

    Great one with context, i like the way you handled the undefined scenario. Thanks for the tutorial.

  • @garudaphoenix5479
    @garudaphoenix547911 ай бұрын

    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

    11 ай бұрын

    Thanks a lot 🤙

  • @soduno596
    @soduno59620 күн бұрын

    you where one of the only youtubers who actually got me to subscribe to your channel. Nice way of implementing the idea 😃. And fantastic tutorials, crystal clear.

  • @_romeopeter
    @_romeopeter24 күн бұрын

    This was straight forward. Thank you for throwing in the extra error handling method as well 🔥

  • @wekesirken6961
    @wekesirken69615 ай бұрын

    That was some good explanation, you made contexts seem obvious...Appreciated

  • @ThomasKanzig
    @ThomasKanzig8 ай бұрын

    Amazing tutorial. Thanks a lot.

  • @XXlikeabauss
    @XXlikeabauss10 ай бұрын

    Really helpful video, thank you so much!

  • @sudiptobose8296
    @sudiptobose82963 ай бұрын

    Fantastic tutorial. I really appreciate it. 😊

  • @antimrevapati8992
    @antimrevapati89924 ай бұрын

    Great Explanation, Thank you!

  • @santiagovelezsaffon
    @santiagovelezsaffon2 ай бұрын

    Very well explained !!

  • @deshannawarathna6283
    @deshannawarathna62835 ай бұрын

    Thank you man. That is good explanation

  • @user-ms4cs3cb4w
    @user-ms4cs3cb4w5 ай бұрын

    Thanks it was very helpful

  • @franbrankovic3617
    @franbrankovic36178 ай бұрын

    After this video you really don't need to watch another video about react useContext. This was excellent video.

  • @sub_in01
    @sub_in019 ай бұрын

    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

    9 ай бұрын

    thanks for the kind words! 🤙

  • @sathirabandara7981
    @sathirabandara79814 ай бұрын

    Great job man. its very helpful !!

  • @mchisolm0
    @mchisolm0Ай бұрын

    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.

  • @israelkayaba6002
    @israelkayaba60026 ай бұрын

    Thanks bro, much appreciated !

  • @Teddyrobinson
    @Teddyrobinson4 ай бұрын

    Another great tutorial thanks so much!

  • @samahgad241
    @samahgad2415 ай бұрын

    Realy great explanation,thank you

  • @tokaqarcivadze5825
    @tokaqarcivadze58257 ай бұрын

    the way you explain react is the best!

  • @kwasiezor1630
    @kwasiezor1630 Жыл бұрын

    Thanks for the video bro. Simplified explanation always makes understanding better 😊

  • @cosdensolutions

    @cosdensolutions

    Жыл бұрын

    Glad you found it useful!

  • @kwasiezor1630

    @kwasiezor1630

    Жыл бұрын

    Yes Indeed. Keep it up 👏

  • @vivekkumar-pc1xy
    @vivekkumar-pc1xy6 ай бұрын

    Crystal Clear... Thanks

  • @ooorayooonyoooo
    @ooorayooonyoooo11 ай бұрын

    A really underrated channel, well done bro! ⚡❤

  • @myothiha1168
    @myothiha116810 ай бұрын

    best explanation ever!🤩

  • @user-bk2ts2zc3r
    @user-bk2ts2zc3rКүн бұрын

    thanks man I really understood it. Subscribed already

  • @rmc1579
    @rmc15795 ай бұрын

    great explanation. I was a little bit confuse when using context and how to implement them.

  • @codehustler8582
    @codehustler85823 ай бұрын

    Amazing Channel for Learning React

  • @cypherop2608
    @cypherop26085 ай бұрын

    you made it soooooo easy to understand

  • @simplebutcorrect6176
    @simplebutcorrect61768 ай бұрын

    Bro I love the way that you explain keep it up. Subscribed❤

  • @YisneySoto
    @YisneySoto8 ай бұрын

    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

    8 ай бұрын

    glad to hear it!

  • @juststudying1019
    @juststudying10194 ай бұрын

    Amazing channel, thanks.

  • @RyS29
    @RyS296 ай бұрын

    Great content, thank you!

  • @AhmedHuzain
    @AhmedHuzain5 ай бұрын

    "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!

  • @UnfinishedYara
    @UnfinishedYara4 ай бұрын

    Thanks man! Crystal clear now!

  • @vampirekabir
    @vampirekabir11 ай бұрын

    trying to get a grasp of it,nobody taught like u did,i finally get it now ❤❤

  • @cosdensolutions

    @cosdensolutions

    11 ай бұрын

    🤙

  • @HerlonCosta
    @HerlonCosta6 ай бұрын

    I reall like this explanation. You're very good, god bless you!

  • @lordkonadukweku6965
    @lordkonadukweku69656 ай бұрын

    Top-notch explanation. Manifesting 100k subscribers by end of this year

  • @awasum
    @awasum4 ай бұрын

    Thank you very much. Good content

  • @shivasai7707
    @shivasai770714 күн бұрын

    great explaination on useContext

  • @sup_nim
    @sup_nim9 ай бұрын

    great explaination thank you bro!

  • @Shaheer-xs5os
    @Shaheer-xs5os10 ай бұрын

    That was such an awesome explanation 👍

  • @cosdensolutions

    @cosdensolutions

    10 ай бұрын

    Thanks 🤙

  • @poornasaipilla1620
    @poornasaipilla16203 ай бұрын

    Really use full video thanks for doing ... extending my great full and encouragement .... keep doing well..

  • @Pareshbpatel
    @Pareshbpatel7 ай бұрын

    Context API with a custom hook, so well explained. Thank you. {2023-10-16}

  • @glenmccallum7051
    @glenmccallum70518 ай бұрын

    Thanks a lot, this was really helpful. Really great video and great channel

  • @cosdensolutions

    @cosdensolutions

    8 ай бұрын

    glad it helped!

  • @marceloleoncaceres6826
    @marceloleoncaceres68265 ай бұрын

    Great video, thanks for sharing your time and knowledge,

  • @user-el9ui5jk5m
    @user-el9ui5jk5m2 ай бұрын

    I literally subscribed after seeing your message in the Video

  • @thebeastsclips
    @thebeastsclips6 ай бұрын

    useContext is a great alternative for a bunch of prop drilling with a bunch of useStates as well in the child component as well.

  • @theppiwatkomolwat4429
    @theppiwatkomolwat44296 ай бұрын

    1:31 This part of the code worked; I have now subscribed!

  • @cosdensolutions

    @cosdensolutions

    6 ай бұрын

    ☺️

  • @mgx49
    @mgx492 ай бұрын

    No doubt I won't need to watch another React Context API video! [Subscribed]

  • @leonardmbibi8013
    @leonardmbibi80138 ай бұрын

    Top notch! You're the man

  • @yusha790
    @yusha79026 күн бұрын

    You're the best man

  • @Atomatiz
    @Atomatiz5 ай бұрын

    Cosden. I love you bros 😉

  • @omkarjagtap2212
    @omkarjagtap22123 ай бұрын

    man, awosome video crystel clear concepts and learned how to write a more safe code(in the pov for debugging)

  • @safareesamuels4674
    @safareesamuels46746 ай бұрын

    Home of React well explained Tutorials

  • @suvakshaacharya6900
    @suvakshaacharya69003 ай бұрын

    thanks . helped a lot

  • @Martin-xf8be
    @Martin-xf8be6 ай бұрын

    That subscribe intro you did made me subscribe. Genius.

  • @abdoseadaa
    @abdoseadaa4 ай бұрын

    i put like b4 watching your videos :) legend

  • @rasikakshirsagar5563
    @rasikakshirsagar55634 ай бұрын

    Thank you bro!

  • @ihebbenaicha1353
    @ihebbenaicha1353 Жыл бұрын

    please keep it up with more hooks and thank you !

  • @cosdensolutions

    @cosdensolutions

    Жыл бұрын

    Will do!

  • @user-wq9xz9yc7c
    @user-wq9xz9yc7c6 ай бұрын

    I speak another language, but I'm happy to find this video. Thanks!

  • @cosdensolutions

    @cosdensolutions

    6 ай бұрын

    Working on adding translated captions to all videos soon!

  • @Vishal360
    @Vishal3608 ай бұрын

    loved ur react tuts.... 🔥🔥🔥🔥🔥🔥🔥🔥

  • @syedayanata9765
    @syedayanata97658 ай бұрын

    I watched many videos and still did not understand context but this video helped me a lot.

  • @cosdensolutions

    @cosdensolutions

    8 ай бұрын

    you got this

  • @PravinsPhotos
    @PravinsPhotos4 ай бұрын

    I really did subscribe at 1:57...good one there😂

  • @brNoMundo123
    @brNoMundo1233 ай бұрын

    Sou desenvolvedora Júnior e seus vídeos estão me ajudando muito a me desenvolver 🚀

  • @MarksmanVallecillo
    @MarksmanVallecillo8 ай бұрын

    Thanks, man very good video. 10 Stars ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐

  • @brunopagno
    @brunopagno7 ай бұрын

    Nice video!

  • @MRNani-rw6td
    @MRNani-rw6td27 күн бұрын

    Thank for this

  • @Bilo_7
    @Bilo_710 ай бұрын

    I made an instant subscription 👍

  • @cosdensolutions

    @cosdensolutions

    10 ай бұрын

    🤙

  • @mahdighasemi9518
    @mahdighasemi95189 ай бұрын

    Thanks a lot.

  • @Fleischmann773
    @Fleischmann7738 ай бұрын

    Great example!!!

  • @theGameThrough
    @theGameThrough11 ай бұрын

    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

  • @admasterefe4340
    @admasterefe43402 ай бұрын

    GOD level explanation. I want everyone to subscribe to this channel. Too bad one can't give two likes.

  • @mai.krishnahoon
    @mai.krishnahoon4 ай бұрын

    Thanks from india..

  • @shekhtausif2811
    @shekhtausif2811 Жыл бұрын

    Just make more videos like this on react plz you explain really well

  • @cosdensolutions

    @cosdensolutions

    Жыл бұрын

    Will do!

  • @antoninosartori
    @antoninosartori7 ай бұрын

    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

    6 ай бұрын

    If user come from server state, don't throw error in custom hook, just return user.

  • @jouebien
    @jouebienАй бұрын

    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.

  • @nogafouz2174
    @nogafouz21745 ай бұрын

    realy thank you but i have a question please which better using context api or redux tookit

  • @mark-broomfield
    @mark-broomfield6 ай бұрын

    Great tutorial thanks. My subwoofer got a serious workout every time you banged the mic though :-)

  • @cosdensolutions

    @cosdensolutions

    6 ай бұрын

    LOL 😂 it gets better in later videos I promise!!!

  • @tinashejamanda6747
    @tinashejamanda67473 ай бұрын

    Thank you

  • @mDHARYL
    @mDHARYL3 ай бұрын

    Thanks 🙏😊

  • @Atul_25
    @Atul_252 ай бұрын

    Thanks for making in ts

  • @niconel7659
    @niconel76597 ай бұрын

    Thanks for the reminder to subscribe. Guilty as charged, but subscribed now.

  • @nabilachehlafekir8577
    @nabilachehlafekir85778 ай бұрын

    thank you

  • @muhammadrehan5722
    @muhammadrehan57227 ай бұрын

    now i subscribed ;)

  • @user-dm3sf9mk2o
    @user-dm3sf9mk2o8 ай бұрын

    This was a really good explanation. Would you consider doing a video about useContext in regards to forms?

  • @cosdensolutions

    @cosdensolutions

    8 ай бұрын

    sure!

  • @user-dm3sf9mk2o

    @user-dm3sf9mk2o

    7 ай бұрын

    @@cosdensolutionsI get stuck on passing input content to the page. Trying different ways without too much success.

  • @abhinaygupta4052
    @abhinaygupta40526 ай бұрын

    Cant subscribe but here is my thumbs up 👍