DEV Community

Discussion on: You MUST use the useCallback hook!

 
itays123 profile image
Itay Schechner

Just read the hook documentation. I'm sure you have better things to do other than commenting discouraging comments on random posts.

Thread Thread
 
nombrekeff profile image
Keff

It was not my intention to discourage, sorry if it felt that way. But for having such a strong title, I felt the post was lacking information, that's all. No need to get angry or discouraged by this, I was hoping for a bit of a conversation about this.

Just read the hook documentation
I've checked the docs, and found not much information about why this particular example is more optimized, that's why I asked! Also, by the title I supposed this post would explain that in detail...

Again, I'm sorry if I sounded harsh or discouring. That's not my intention at all, but I hate these kinds of titles, even more if they don't offer that much value.

Thread Thread
 
itays123 profile image
Itay Schechner

I understand. There is a great explanation on why you should use it in a previous post I wrote, using websockets with React.js. I explained in detail how use Callback saved my life there.

Thread Thread
 
nombrekeff profile image
Keff

I will check it out! Cheers!

Thread Thread
 
exneval profile image
Egi Ginting • Edited

@nombrekeff

Check Kent C. Dodds article if you still not get it, (I'll just copy some part of it here below)

Q: So when should I useMemo and useCallback?
A: There are specific reasons both of these hooks are built-into React:

  1. Referential equality
  2. Computationally expensive calculations

And thanks for the article @itays123 , hope it can cover more complex cases and explanation in the future so some readers won't get the wrong idea of this hook, because premature code optimization can lead them to make thing worse

Thread Thread
 
nombrekeff profile image
Keff

Fantastic I'll check that out too, thanks for the info

Thread Thread
 
nombrekeff profile image
Keff

because premature code optimization can lead them to make thing worse

Yup, totally agree here, that was in part why I wanted to understand it better

Thread Thread
 
itays123 profile image
Itay Schechner

Already Archived and prepating a better one