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.
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
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
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
when discussing features can you add the pitfalls to avoid, for example unnecessary rerenders?
Thanks for the suggestion
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.
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
It is not recommend to add a function in context provider?
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
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