r/reactjs • u/DependerSethi • May 21 '26
Resource Most React performance advice is stuck in 2023. Here's what actually matters now
Kept seeing the same advice everywhere: wrap things in useMemo, useCallback everything, React.memo all the things.
Then i profiled an app I'd "optimized" this way, the memoization overhead was costing more than the renders it was preventing
with the react compiler now auto-memoizing at build time, most manual useMemo/useCallback is becoming dead weight.
wrote up what actually fixes react performance in practice:
- state colocation: move state closer to where it's used. this one change beats every useMemo in your codebase. seriously.
- the children pattern: pass children from above so they don't re-render when parent state changes. zero memoization needed.
- useTransition: mark non-urgent updates as transitions. input stays responsive, heavy renders happen in background.
- useDeferredValue: same idea but for values from props you don't control. smarter than debouncing.
- code splitting: lazy() + Suspense for routes and heavy components. don't lazy-load a button though.
- profile before optimizing: react devtools profiler, chrome performance tab, core web vitals. if you haven't measured it, don't optimize it.
also covered 5 performance bugs i keep finding in production codebases:
- components defined inside other components (full remount every render, not re-render)
- useEffect chains causing cascade re-renders
- context providers sitting too high in the tree
- unstable keys (Math.random() as key is surprisingly common)
- object/array literals in JSX props breaking React.memo
the useEffect chain one is probably the most common. three effects that depend on each other = three render cycles for one user action.
https://www.sethi.io/blog/react-performance-from-sluggish-to-lightning
what's the worst react perf bug you've had to track down?
32
u/After_Medicine8859 May 21 '26
Decent write up, but I think this advice is more or less what people have been told already, I also don't agree with your premise that the compiler is counter productive, that's quite a hot take.
13
u/aragost May 21 '26
that's, very respectfully, bullcrap. The compiler memoizes everything and it's quite clear by now that the overhead is not more than the prevented renders
45
u/0xHUEHUE May 21 '26
who uses Math.random() as a key, what the fuck
26
u/yksvaan May 21 '26
Nothing has fundamentally changed for years, the key thing for performance is still the same: knowing how React works and what will happen during the app run cycle.
Compiler is kinda stupid, it doesn't perform any cost analysis or have context knowledge like the developer who can reason about it.
27
u/gorgedchops May 21 '26
was this entire thing written by ai?
20
u/azangru May 21 '26
This text has such a strong AI vibe to it.
But I am still curious what this statement means?
What was the cost measured in? Was your application getting slower because of some memoization overhead?
6
u/HQxMnbS May 21 '26
Memorization overhead costing how much exactly? Didn’t see any measurements
3
u/WanderWatterson May 21 '26
if I'm the mod right now I would just ban all AI generated engagement slop posts like this one, lowercasing all words does not make the post not detectable as AI just so you know
2
u/devuxer May 21 '26
A lot of this stuff goes away if you use Jotai or a Signals library.
2
u/Nervous-Project7107 May 21 '26
Thanks for reminding me why leaving react was a good decision
1
u/True-Environment-237 May 21 '26
I wonder how much more efficient react compiler is compared to everything wrapped with usememo,callback and memo in terms of execution speed.
1
u/Tinkuuu May 21 '26
I just wanna leave this article here, that I found somewhere around this sub a while ago I think.
1
u/TheRNGuy May 21 '26
Looking in wrong places then.
1
u/haltmich May 21 '26
Claude, rewrite my app in SolidJS. Make no mistakes
1
u/scaleable May 22 '26
1
u/hyrumwhite May 22 '26
Memoizing overhead is dramatically overblown. It’s a fancy if statement.
Give me the data on your memoization tanking perf.
But there’s been enough discourse over this that many LLMs think memoization is bad.
1
u/ElectronicCat8568 May 22 '26 edited May 23 '26
I have a pet theory that popular webdev is perpetually about 8 years behind where it could/should be. Real innovations exist in principle way before they make it into popular acceptance. It's just there is enormous inertia to overcome in the sheer mass of collective mindsets. The hivemind can't change quickly, like an individual can change their mind. It's really quite glacial.
-1
u/saito200 May 21 '26
or... just use Vue... and forget about 90% of this
-4
u/akisbis May 21 '26
If you care about performance, don’t use react 😅
60
u/[deleted] May 21 '26
[removed] — view removed comment
1
u/[deleted] May 21 '26
[removed] — view removed comment