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.
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.
Why does it rerender the entire page? Is it because it’s in the same component?
yes that's correct
Got it. Thank you so much! :)
Pleasure :)