Hi everyone! My name is Itay and I’m a fullstack developer who specializes in back-of-the-frontend React.js code.
In this shot, I’ll show you the ...
For further actions, you may consider blocking this person and/or reporting abuse
How is the last example more optimized and why? In what ways is it different than not using useCallback? What benefits would this give me?
Much information missing for such a big title.
I mentioned it in the article. The last example is more optimized because we don't recreate the click handle function on every rerender.
I still don't understand, isn't this just re-creating the callback on each re-render as well?
How is this more efficient? I mean, you are still "re-creating" the callback on each render.
Correct me if I'm wrong, but as I understand, the only thing that useCallback does is memoize the function for the passed dependencies, so it seems in this particular case it is not optimizing anything as it does not know the about any dependency.
Just read the hook documentation. I'm sure you have better things to do other than commenting discouraging comments on random posts.
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.
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.
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.
Great