Mastering React Context 2023: The Complete Guide!

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • React Context is a critical concept to master once your projects get to a certain size. Context can drastically improve your code readability, help you avoid prop-drilling (passing props down through lots of components), and increase code maintainability.
    0:00 Why learn React Context?
    0:20 Overview: When and how to use context
    5:56 Example project: Properly implementing context
    ⭐ My GitHub: github.com/joschan21
    ⭐ Our startup: wordful.ai
  • НаукаНаука

Комментарии • 32

  • @Douwab
    @Douwab Год назад +4

    Really cool video! I use context a lot of times in my apps. If I could add a little something: I usually like to add a hook that goes with my Context Provider. An example here would be to export a useTheme method that returns useContext(ThemeProvider). It is not game changing but it adds a little bit of simplicity in the consumer code. 😊

    • @joshtriedcoding
      @joshtriedcoding  Год назад +1

      Cheers man, with increasing complexity that sounds very reasonable

  • @lionroot_tv
    @lionroot_tv Год назад

    Great stuff, thanks Josh!

  • @belkocik
    @belkocik Год назад

    Good explanation! :)

  • @codewithguillaume
    @codewithguillaume Год назад +1

    I was wrong about Context. Thanks Josh !

  • @techworld3043
    @techworld3043 Год назад +1

    great explanation.

  • @MultiReylords
    @MultiReylords Год назад +1

    Hey Josh, It’s been a blessing to discover your youtube channel, I have learned so much from your recent videos.
    You mentioned that you do/did freelance, do you have any tips for how to get into that sort of work as a beginner? (I am based in Germany if that helps)

    • @joshtriedcoding
      @joshtriedcoding  Год назад +5

      Cheers man. I'm based in Germany too, I think if you have no connections in the field or work to take on, making free stuff for yourself and your portfolio would be the first step. Get good at whatever you're coding and don't get lost in tutorial hell. After coding some projects, reach out to see if someone is willing to let you work for free (ideally someone well-known or with a good reputation). After all, you are providing real value to them for free.
      Then I'd take the next step to reach out to clients with that work experience under your belt and really give them value in your proposal. Analyze their website - what can be improved? Page speed? Design? Automating certain functionalities? Let them know (ideally, in a personal video you record for them, or just via email if you don't like that approach).
      Make sure to sound very respectful in that email, if you're working with smaller companies chances are someone they know personally did that website and you don't want to offend them. That was my approach :) Hope that text wasn't too long haha

    • @MultiReylords
      @MultiReylords Год назад

      @@joshtriedcoding Thank you for taking the time to write out such a detailed reply! This actually helps a ton and confirms that I am on the right path. 👍

    • @DiogoLScarmagnani
      @DiogoLScarmagnani 2 месяца назад

      @@joshtriedcoding it was a very good text, I loved those tips. Thank you.

  • @oncoding4520
    @oncoding4520 Год назад

    nice video, very informative and at the same time very helpful :)) What app do you use also to draw?

  • @angladephil
    @angladephil Год назад

    Context is ultimately a complicated (sophisticated ?) way to use global variables or objects ...
    Thanks for the good teaching.

    • @airixxxx
      @airixxxx Год назад

      Global variables don't alter state.

  • @rafaelmelo7665
    @rafaelmelo7665 4 месяца назад

    👏👏👏👏👏👏👏👏👏👏👏

  • @sewerynwozniak3417
    @sewerynwozniak3417 11 месяцев назад

    Why setThemeValue in ThemeContext is empty and you add logic inside PageContent?
    Is it typical approach?

  • @0xPanda1
    @0xPanda1 Год назад +1

    niiiice

  • @0xPanda1
    @0xPanda1 Год назад +1

    keep it up

  • @blazi_0
    @blazi_0 Год назад

    Hi man a quick question that i really need to know, are providers exposed to a child that didn't export it?
    Let's say i passed password context to the root component
    Will user will be able to see password from the footer using some kind of trick from the browser? Though i didn't import the password from footer

  • @samoniumuziejus
    @samoniumuziejus 10 месяцев назад

    I used context-selector-api because useContext had rerendering problems

  • @faiquejatu8649
    @faiquejatu8649 Год назад

    What is the root component for next 13 applications?

  • @emigrek
    @emigrek Год назад

    Why doing this classic way since we have things like Redux, Recoil, etc...? Whats the pros?

    • @joshtriedcoding
      @joshtriedcoding  Год назад

      The first one is that you don't have to set aside days (at least for me it was days) to learn redux. Second, in most well-thought-out architectures you are fine with context and don't even need "heavier" state management solutions

  • @sewerynwozniak3417
    @sewerynwozniak3417 11 месяцев назад +2

    Good example of how typescript can make things much more complicated
    Really it was introduced to make coding easier and for me it's most time-consuming part of coding in react

    • @zombizombi
      @zombizombi 9 месяцев назад +1

      I'm only half way through the video butwhat do you mean its making things more difficult? He's only added type information which means more type inference and better completion... how is that a bad thing?

  • @crispasmakanani6617
    @crispasmakanani6617 Год назад

    hi can we talk inbox 😊

  • @2gbeh
    @2gbeh 9 месяцев назад

    In "2023"??? It's literally the same thing as it has always been years prior.