Comment

Comment by rtpg

People say "don't just blindly use React.memo, fix slow renders first." But like... with referential identity being so cheap, blindly applying React.memo should be a huge win?

CostPostCache = CostOfCache + CacheHitPercentage * CostWhenHittingCache + CacheMissPercentage * CostPreCache

CostOfCache is pretty cheap compared to the CostPreCache IMO... CostWhenHittingCache is very low... and CacheMissPercentage is also probably pretty low in your typical React component that has more than 2 children node involved. Mathematically it feels like a no-brainer!

"Fix your slow renders first" just feels off. Yes you want to fix slow first renders! You also want to avoid wasting render cycles. These are distinct issues from my view. What am I missing? Why shouldn't React "just" do useMemo by default?

parent rtpg 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton