DEV Community

Discussion on: What is useMemo hook in React..

Collapse
 
nasreenkhalid profile image
NasreenKhalid

When we click 'increment' button, the whole page is re-rendered therefore it executes every function without keeping in mind that clicking 'increment' button has no effect on 'evenNum' state and to restrict this unnecessary re-render we have used useMemo hook.

Collapse
 
seankimdev profile image
Sean Kim

Why does it rerender the entire page? Is it because it’s in the same component?

Thread Thread
 
nasreenkhalid profile image
NasreenKhalid

yes that's correct

Thread Thread
 
seankimdev profile image
Sean Kim

Got it. Thank you so much! :)

Thread Thread
 
nasreenkhalid profile image
NasreenKhalid

Pleasure :)