Frontend interview question is another trouble maker, they asked a lot of code cases (terrible object reassignment patterns and abuse variable scope) that you should never use them in code, and then ask you what happen if you use them, some ignorant devs even are pretentious about knowing those non-sense. It cause many Devs to hard memorize them. In fact, you should never know them, they will pollute your knowledge database.
I've been writing React for a few years now and though I know how state works for the most past, you filled in some gaps for me in this single video. Well said. This was helpful! I love your videos and tune in as often as I can.
this is the explanation that I've wanted for a long time. Most of the tutorials explain how hooks work and how not to use them, but those never explain this much. Thanx.
That was really useful! I'm refactoring code from other people that is really full of states and variables, so this will help me decide what to keep and what to change.
Absolutely fantastic video which is absolutely necessary for anyone looking to get into react to watch. Understanding the concepts here really saves so much debugging time. I know because I suffered debugging these kinds of issues for so long lol😅
Great video to remember the concepts behind React ! I've been so immersed in the framework that i was going with the 'everything needs to be a state' mindset. But when a re-render is not needed it is true that you can use generic JS which i forgot ! I might have to update my linters to allow it from time to time ^_^
Jesus christ, I finally understood how useState works haha thanks! Please, do an example like this with all the other standard hooks, this would be so fricken awesome. You are so talented in explaning things!
in your example to put the count var (min 5:18) outside the component and you can mutate it, is there a different with useRef? like a countRef.current and change it from there?
useRef will not tell React to re-render. But yes, you could use a ref and increment it, but you'd still need a useState somewhere to let react know it's time to render again.
@@WebDevCody thanks for the answer i didnt know is there has a difference on useRef, cause i had some issues using it, wanna save some var on a useRef cause i know that var is not gonna show on screen, but for some reason the value on the useRef change, when a use the debugger it just go to that line of useRef and the value change just like that, i end up doing the other way that a forgot was a old sprint that i have had and there was no answer on stack overflow or google. it i encounter the same problem i will sure let you know.
I think one of the important issue with React is that many newbies expect React works as JavaScript. It's apparently not. This is actually a common Frontend issue nowadays, many jump into the Frontend world with one framework like react, svelte, or vue and etc. without knowing the fundamental of JavaScript, even the JavaScript itself has a lot of clucky behavior, so they will make a lot of mistakes at the beginning. The worse case, they want to apply framework philosophy everywhere even back to language itself. if you have something in your code like a dependency state update as a learner, there might be something wrong in your code most likely ``` setAState(newA); // waiting A update, something happen in between, setBState(A); ``` Just a common trouble pattern I see in React, Svelte and Vue also have their own issues to deal with.
Solid js tries to avoid this problem by always requiring a function for getting the current value of state. But yes to truly understand these react state bugs you need to know js pretty well
Pretty sure closures have more to do with functions “closing” over inner state with an inner function doing something with that state. Would definitely say that’s much more global state as it’ll be available on window object as scoped.
I think that if you we're to make your count vanriable const, then js wouldnt hoist it anymore, but you would have to do some hacky stuff to change it. Great video! Love your didactics
i love using Vue, and I think it's far superior to React, but it just doesn't have the same quality libraries like React does. Even component libraries aren't as good as the ones in React-land, the most popular 2, Vuetify and Quasar, are styled with Material UI, which is soooooooo ugly in 2022. I COULD use Tailwind, but I don't want to design all my components from scratch. Lemme know if you know any beautiful Vue 3 component libraries!
idk why I kept saying "because of how closures work". there are no closures here, just scoping. "because of how scoping works". cheers!
phew, I was already doubting myself 😛
Frontend interview question is another trouble maker, they asked a lot of code cases (terrible object reassignment patterns and abuse variable scope) that you should never use them in code, and then ask you what happen if you use them, some ignorant devs even are pretentious about knowing those non-sense. It cause many Devs to hard memorize them. In fact, you should never know them, they will pollute your knowledge database.
I've been writing React for a few years now and though I know how state works for the most past, you filled in some gaps for me in this single video. Well said. This was helpful!
I love your videos and tune in as often as I can.
the audio quality of this video is amazingly done, delight for my speakers!
Great video. Thanks.
Thanks!
this is the explanation that I've wanted for a long time. Most of the tutorials explain how hooks work and how not to use them, but those never explain this much. Thanx.
That was really useful! I'm refactoring code from other people that is really full of states and variables, so this will help me decide what to keep and what to change.
Absolutely fantastic video which is absolutely necessary for anyone looking to get into react to watch. Understanding the concepts here really saves so much debugging time. I know because I suffered debugging these kinds of issues for so long lol😅
Great video to remember the concepts behind React ! I've been so immersed in the framework that i was going with the 'everything needs to be a state' mindset. But when a re-render is not needed it is true that you can use generic JS which i forgot ! I might have to update my linters to allow it from time to time ^_^
Jesus christ, I finally understood how useState works haha thanks! Please, do an example like this with all the other standard hooks, this would be so fricken awesome. You are so talented in explaning things!
Thanks man I appreciate that. Yeah maybe useEffect next
@@WebDevCody This would be awesome, thanks 😊
thank you, you're very good at explaining
thank you you made it really clear and simple
awesome video and really unique way of demonstrating it
Thank you explaining it 😀
Really good job, short and extremely helpful 💪💪💪
The last 5 minutes of this video was too intense for my brain. I was keeping up until then, time to save this in my watch later.😅
Just wonderful!
Amazing video, subbed 🥂
This guy is literally Broken!
I’ve lost my mind
thanks much needed explanation
A very useful video for us beginners!
Thank you so much !!
Loved the tutorial man this thing is legit 100% !! althogh i wish if theres a way you can do it on computer
Do it on a computer? What do you mean
I got this question for a senior dev interview. The interview wants a detailed explanation why react renders
Great! Thanks
17:02 state setters are fully synchronous
This is really usefull, Thank you
great video!
thanks for the video
lol 'Shadow DOM', that sounds badass. React should've called it that instead of Virtual DOM
There is a shadow dom concept, I just confused the terms 😔 google shadow dom vs virtual dom
in your example to put the count var (min 5:18) outside the component and you can mutate it, is there a different with useRef? like a countRef.current and change it from there?
useRef will not tell React to re-render. But yes, you could use a ref and increment it, but you'd still need a useState somewhere to let react know it's time to render again.
@@WebDevCody thanks for the answer i didnt know is there has a difference on useRef, cause i had some issues using it, wanna save some var on a useRef cause i know that var is not gonna show on screen, but for some reason the value on the useRef change, when a use the debugger it just go to that line of useRef and the value change just like that, i end up doing the other way that a forgot was a old sprint that i have had and there was no answer on stack overflow or google. it i encounter the same problem i will sure let you know.
All ❤
I think one of the important issue with React is that many newbies expect React works as JavaScript. It's apparently not.
This is actually a common Frontend issue nowadays, many jump into the Frontend world with one framework like react, svelte, or vue and etc. without knowing the fundamental of JavaScript, even the JavaScript itself has a lot of clucky behavior, so they will make a lot of mistakes at the beginning. The worse case, they want to apply framework philosophy everywhere even back to language itself.
if you have something in your code like a dependency state update as a learner, there might be something wrong in your code most likely
```
setAState(newA);
// waiting A update, something happen in between,
setBState(A);
```
Just a common trouble pattern I see in React, Svelte and Vue also have their own issues to deal with.
Solid js tries to avoid this problem by always requiring a function for getting the current value of state. But yes to truly understand these react state bugs you need to know js pretty well
Good job love ❤️
Pretty sure closures have more to do with functions “closing” over inner state with an inner function doing something with that state.
Would definitely say that’s much more global state as it’ll be available on window object as scoped.
Yeah true bad word choice, it’s more of how scoping works, no retakes. Record once and publish 😂
Respect for you doing it tho!
I have a question about useEffect. Why should fetch data from an API inside useEffect and not just inside the component function?
Because the component function will rerun over and over again
nice :)
Did you mean to useMemo in 14:31 ?
Yes, typed the wrong thing. React.memo is for components
I think that if you we're to make your count vanriable const, then js wouldnt hoist it anymore, but you would have to do some hacky stuff to change it. Great video! Love your didactics
Amazing to know what happens under the hood
4:33
13:54
i love using Vue, and I think it's far superior to React, but it just doesn't have the same quality libraries like React does. Even component libraries aren't as good as the ones in React-land, the most popular 2, Vuetify and Quasar, are styled with Material UI, which is soooooooo ugly in 2022. I COULD use Tailwind, but I don't want to design all my components from scratch. Lemme know if you know any beautiful Vue 3 component libraries!