useCallback STOPS this React MISTAKE | useCallback React Hooks Tutorial

useCallback STOPS this React MISTAKE | useCallback React Hooks Tutorial

Dave Gray

2 года назад

51,456 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@hmzmhd6881
@hmzmhd6881 - 11.11.2023 00:59

Amazing as always

Ответить
@slowcoding
@slowcoding - 09.11.2023 15:34

Wow! The expiations open my eys to understand how the sum functions are created repeatedly. Awesome!

Ответить
@harag9
@harag9 - 09.10.2023 15:43

Thanks for that, so basically only time to use useCallback is when you put the function name within the useEffect dependency, other than that you don't need it?

In some code at work we have a use effect with [] as the dependency, and in that useEffect it sets up a onClick listener and assigns a function to the onClick, that function is within a useCallback -- this that right? (Also have the clean up for removing the onClick listen too)

Ответить
@viditgoel2909
@viditgoel2909 - 18.09.2023 06:19

I really wish I had found an instructor like you earlier!

Ответить
@farasafeds9411
@farasafeds9411 - 13.05.2023 20:46

Yoooo you better start your udemy course I ll be the first one to pay😂. Your explanation was perfect and you know how to explain the concepts perfectly with good examples.

Ответить
@upeksharanaweke3529
@upeksharanaweke3529 - 02.04.2023 11:51

Great Tutorial.Thanks a lot 😇

Ответить
@istagfarinspirations
@istagfarinspirations - 25.03.2023 19:28

This single tutorial is better than whole 250$ course

Ответить
@user-hk1ew8kk7f
@user-hk1ew8kk7f - 22.03.2023 13:54

This is the clearest explanation video I have ever watched. Thanks

Ответить
@Victoria-fo4lm
@Victoria-fo4lm - 19.02.2023 15:51

That's what I need, Thank you! the screen view is big for me easy to see Chrome dev tool. :D

Ответить
@rodanus7112
@rodanus7112 - 19.01.2023 01:26

I'm so glad I found your channel. I really appreciate the great tutorials. Thank you!

Ответить
@kakhabervk9405
@kakhabervk9405 - 11.12.2022 00:33

Fot mr this tutorial is best explaining useCallback, Thanks!

Ответить
@mohammadmahdialvansaz8001
@mohammadmahdialvansaz8001 - 10.12.2022 17:28

Great tut. Thanks

Ответить
@rajeshj4066
@rajeshj4066 - 09.12.2022 10:12

you are incredible. I am grateful that I found your channel

Ответить
@vladserhiychuk8925
@vladserhiychuk8925 - 23.11.2022 17:04

Great. Thanks.

Ответить
@LearnTechWithRatan
@LearnTechWithRatan - 03.11.2022 19:54

you earned yourself a subscriber, this is the perfect explanation

Ответить
@brilliantatosam6882
@brilliantatosam6882 - 28.10.2022 15:44

Wonderful topic treated by a wonderful teacher.
All these years I have remained a beginner until I came across your channel and I am very excited about stepping up my skill set to advanced react developer 😎

Ответить
@novanoskillz4151
@novanoskillz4151 - 17.10.2022 00:49

can somebody please explain how he's able to see the error telling him to add the function to useCallback... is it an extension or something?

Ответить
@Ranjithkumar-ll5rb
@Ranjithkumar-ll5rb - 16.10.2022 06:54

nicely explain thank you 😀

Ответить
@andisheabbasian5185
@andisheabbasian5185 - 15.10.2022 20:30

for that van helen signature guitar, I should have known from the beginning that your content is gold.

Ответить
@mariusguissou4282
@mariusguissou4282 - 14.10.2022 16:41

👍👍👍👍👍👍👍👍❤❤❤❤ thanks!

Ответить
@bertrodgers2420
@bertrodgers2420 - 11.10.2022 23:48

unrelated, but which colour scheme are you using here?

Ответить
@sinxenon3181
@sinxenon3181 - 28.09.2022 23:42

THANKS A LOT!!! Perfect explanation! 😍

Ответить
@nahidfaraji5069
@nahidfaraji5069 - 27.09.2022 21:32

Crystal clear explanation. Thank you so much sir ❤️

Ответить
@r-iliass9587
@r-iliass9587 - 26.09.2022 16:33

My favorite web dev instructor <3

Ответить
@thilakraj6225
@thilakraj6225 - 16.09.2022 11:39

Why did we had infinite rendering. Can you please explain that part and how did you avoid that?

Ответить
@QuadDrums
@QuadDrums - 15.09.2022 03:43

Earned a subscriber today, great video.

Question: If you defined your function in an external file and imported it, then you wouldn't need to use useCallback in this scenario? Or am I missing something.

Ответить
@phugia963
@phugia963 - 06.08.2022 21:53

I might be a noob in React but can anyone explain why we would ever use a function as dependency in userEffect? Would we wait for anyone to change that function definition then we will run our logic inside useEffect?
Thanks.

Ответить
@ephratanebiyu5302
@ephratanebiyu5302 - 16.07.2022 08:29

About time. I actually came for a refresher after watching your other videos. Your Redux Toolik playlist is what introduced me to your channel. Thanks to that I have implemented RTK Query instead of using Axios interceptors for a project I am currently working on. keep it up

Ответить
@ivanshoshkov
@ivanshoshkov - 12.07.2022 09:42

This is what a real tutorial should be like. Not just blindly copy/pasting code but explaining the inner workings of stuff. Thanks man!

Ответить
@hosseinroosta5154
@hosseinroosta5154 - 12.07.2022 00:11

Fanstastic explanation. Thanks

Ответить
@lobsanggyatso6280
@lobsanggyatso6280 - 29.06.2022 10:59

why is if i didint call sum() in console in useEffect but have sum as dependency.
useEffect(() => {
console.log("sum is");
}, [sum]);
changing in state of setUserInput still call useEffect and console too. cause i didint call the sum() function there. i didnt understand that. my guess is that when change in state give new reference to sum(), thats why it behave in this way .
please help me

Ответить
@m4ttheweric
@m4ttheweric - 14.06.2022 16:38

why wouldn't you put either, [num1, num2] (only re-run when the numbers being summed change) or [sum()] (only re-run when the actual sum returned changed) as your dependency array? that way you aren't relying on a function ref for dependency.

also, useEffect isn't really a good place for this kind of code. it's better to place that into event handlers. useEffect should really only be for synchronization tasks.

useCallback is really only important when you are passing a function as a prop to another component. if you are doing this, then useCallback prevents re-renders of the tree caused by referential changes of the prop.

Ответить
@sonamohialdin3376
@sonamohialdin3376 - 01.06.2022 17:55

So good tutorial

Ответить
@mbmahesh9500
@mbmahesh9500 - 29.05.2022 18:45

Thanks Dave, this gave me detailed knowledge about useCallback hook.

Ответить
@farisnaufal8579
@farisnaufal8579 - 29.05.2022 06:37

Excuse me sir, so if we have a function that calls api that returns an array/object, should we put it in useCallback?

Ответить
@aleksprimetv
@aleksprimetv - 29.05.2022 00:06

Dave, can you explain to me, why you add the function as a dependence in the useEffect? I don't dever see this case, usually it is props or state items.

Ответить
@harrycohen2722
@harrycohen2722 - 28.05.2022 06:23

what vs theme are you using? looks amazing

Ответить
@haikoerinkveld4242
@haikoerinkveld4242 - 20.05.2022 10:43

I love your way of explaining things Dave. I am following a React course on Udemy, and i always end up at your channel to get a better understanding of al the React topics. Your explanation is just simple, and your not "over" explaining things. Thanks, and keep up making this valuable content!

Ответить
@shadabkhan681
@shadabkhan681 - 10.05.2022 09:45

Thanks for this Gold lesson.❤

Ответить
@mehrabkor8591
@mehrabkor8591 - 03.04.2022 23:03

Great tnx

Ответить
@ranellabjata5170
@ranellabjata5170 - 31.03.2022 14:56

Great teaching skill. Thank you Sir. 👍

Ответить
@okskaren
@okskaren - 17.03.2022 05:31

awesome video Dave,, thank you so much

Ответить
@tamlselvan9072
@tamlselvan9072 - 30.01.2022 16:59

Thanks Dave 😀

Ответить
@bishalkandel9976
@bishalkandel9976 - 29.01.2022 17:18

You are a very good teacher Dave. Appreciate your work. Kudos

Ответить
@dzentsetsu5607
@dzentsetsu5607 - 01.12.2021 15:59

Thanks for tutorial Dave! Correct me if I am wrong, if we do not pass function in dependency array, we don't need to memoize it (there is no reason) or is it still an overhead for performance to constantly recreate those function everytime? Don't feel like wrapping every function inside component is correct approach.

Ответить