How to use the useContext Hook for a truly global state - React JS Tutorial

Поділитися
Вставка
  • Опубліковано 28 січ 2025

КОМЕНТАРІ • 7

  • @avrahampackouz3974
    @avrahampackouz3974 Рік тому +1

    when discussing features can you add the pitfalls to avoid, for example unnecessary rerenders?

  • @benchracer2171
    @benchracer2171 Рік тому +1

    Something as fundamental as a global state, in your opinion does it need to be this convoluted? Is there an understandable rationale for react's approach or is it a flaw in approach of the language/framework.

    • @kodieCode
      @kodieCode  Рік тому

      With React ultimately being a SPA, you would think there to be an easier or more straightforward way to handle global states. Considering that state was originally meant for the context of the current controller, I guess useContext is the natural evolution

  • @blackbeans3112
    @blackbeans3112 3 місяці тому

    It is not recommend to add a function in context provider?

  • @kondasomu
    @kondasomu 2 роки тому +1

    hi sir,
    I have a doubt while using const keyword
    const x = {name: "scott"};
    x.name = "john";
    console.log(x);
    here 'x' value is john, actually it should be scott. why 'x' value is changing, please clear me

    • @kodieCode
      @kodieCode  2 роки тому

      When you define a const as an object you can in fact change the value of a key but you couldn't, for example, set a new key/value of x.surname = "Scott" since you are changing the structure of the object and const structures cannot be changed. const x = "John" and then x = "Scott" would fail. const x = {name: "John"}; x.name = "Scott" will work