Thank you for the awesome explanation! I’m excited to try this hook. I have a question though. Can you elaborate on why clicking the increment button rerenders the function although the count state is not changing as you stared below?
“But clicking the button 'Increment' also renders the evenNumDouble() function although the 'count' state is not changing”
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.
Thank you for the awesome explanation! I’m excited to try this hook. I have a question though. Can you elaborate on why clicking the increment button rerenders the function although the count state is not changing as you stared below?
“But clicking the button 'Increment' also renders the evenNumDouble() function although the 'count' state is not changing”
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 :)