React Hooks Tutorial - 26 - useCallback Hook

preview_player
Показать описание

📱 Follow Codevolution

useCallback Hook in React
Рекомендации по теме
Комментарии
Автор

The way you break down complex concepts into clear and concise explanations that are very easy to understand is just amazing. Keep up the good work

lukemuga
Автор

anybody noticed? that his voice ends with " c " note..😀

be_real_truth_matters
Автор

By the way, can we stop with the useless comments saying how good the series is? Sorry to sound mean, but when I'm trying to get help, these comments really aren't helping. They are good, but please just stop and think if your comment would really help other people.

Jason-uvtm
Автор

This way will prevent the re-rendering of buttons too.

const incrementAge = useCallback(() => {
setAge((prevAge) => prevAge + 1);
}, []);

asananddevsingh
Автор

Dude, this one is super cool. The way you explain the stuff is far better. I wish you could have written the React docs.

coder_monkey
Автор

Great videos. Please do a component test series after hooks!

ionitaa
Автор

The dependencies list, according to codesandbox is not needed. If for example, I make the dependency list an empty array ([]), then only the salary is rendering, and everything is fine. Using age or salary inside the dependency list is bad because the button will still be redefined every single time. Why is this?

Jason-uvtm
Автор

“The question you might have is …” satisfies me every time. Very thoughtful videos.

quanhglam
Автор

You can optimize it more by passing the updater function as the dependency
const incrementAge = useCallback(() => {
setAge(age=> age + 1)
}, [setAge])
Result: Rendering Age
PS: it also work without dependency

drewstifler
Автор

Thanks! I really appreciate your work!

classicaltv
Автор

I am having one concern with this solution, why even my button component render?
We can overcome with this issue by setState(state=> state+1) and no dependency

So at the end only state will be updated value so value print component will render

jain.sachin
Автор

I've been starting learning react just this week and this video helps me understand one of the fundamentals of React in a clear and understandable way. Kudos to the author of this tutorial, keep up the good work!

jsnjocsin
Автор

The best explanation I've seen so far. Thank you

pannihto
Автор

Thank you! This was very informative and well explained.

pashapear
Автор

Not going to lie, this one may took me a few times to rewatch to get my head wrapped around.

shortyz
Автор

we can avoid button re-renders too! remove age as dependency!

pareshmaniyar
Автор

I was seeking an extensive explanation for useCallBack hook. I found it today! You are amazing bro 💙

kaveenhyacinth
Автор

Hi, thanks for your awesome explanation. For React.memo, I still didn't get why when I click the age button, then the increment salary button renders, anyone can help?

Nana-xidj
Автор

why we need dependency at all, if variable name is same I mean cached function will be same as before and even if I increment increment function will be same so no need to return new function? can anybody help why we need dependency there

sushantgarudkar
Автор

Very informative & well explained in detail, Your way of teaching is amazing, thank you.

Mohamed-M-M