Hacker News new | ask | show | jobs
by LegionMammal978 718 days ago
I think I get what GP means. Without very judicious use of useMemo, you can't move a piece of state into an outer component without causing the rest of its children to also be re-rendered when the state is changed. I recall having to fiddle around with useRef at least a few times due to this, to avoid lots and lots of useMemo churn.
2 comments

But that's the whole point of react compiler, which is the whole point of the post we're talking under
Have you tried wrapping component exports with memo? That basically solved everything for me. It’s the equivalent of functional components from before hooks.

> export default memo(ExampleComponent)