DEV Community

Discussion on: Why custom react hooks could destroy your app performance

Collapse
 
apatel369 profile image
Arpan Patel • Edited

Thank for the greact article. Just a quick question.
What benefit below memoization in useModal hook provides?
return useMemo(
() => ({
isOpen,
Dialog,
open,
close,
}),
[isOpen, Dialog, open, close],

I don't understand how it prevents host component from rerendering.

Collapse
 
adevnadia profile image
Nadia Makarevich

It doesn't, that is the problem. Regardless of what we do, it will re-render.

Collapse
 
apatel369 profile image
Arpan Patel

got it. thanks