DEV Community

Discussion on: You don't know useEffect

Collapse
 
ponikar profile image
Ponikar

Hey there, It was amazing. I am having a little doubt.
Is it worth it to memoize the component who has useEffect hook?

Every time some dependencies is going to be changed, the callback function will trigger! So what's meaning of memoization here!

Collapse
 
trunghieu99tt profile image
Trung Hieu Nguyen • Edited

It depends on the scenario, the main purpose of using Memoization here is to prevent unnecessary re-render (i.e the List only cares about fakeList, but it's re-rendered just because of changes of other stuff). Actually in real-life project, determining whether to use Memoization or not is much more complex than that.

Collapse
 
ponikar profile image
Ponikar

That's great.