TL;DR: Five checks, measured with React 19.3.1 and jsdom. Inline props cost a memoized child 10 renders in 10 updates (stable props: 0). A context value built in render woke 3 consumers 30 times (useMemo: 0). Syncing derived state in an effect doubled renders (20 vs 10). Index keys re-rendered 99 of 100 rows and moved an open state to the wrong item. A whole-library import cost 26,878 bytes gzipped against 1,440.
I'm not going to tell you what assistants "usually" write. I've got no rate for that, and a claim without a rate is just an opinion wearing a lab coat. What I can do is count. These five patterns turn up in any code written to work first, by people or by tools, and each one is cheap to spot in review once you know the shape.
So I built the smallest component that shows each problem, ran it in React 19.3.1, and wrote down what happened.
How Were These Numbers Measured?
Every render count comes from a counter in the component body, read after each update inside act(). The setup was react and react-dom 19.3.1, jsdom 31.0.1 and Node v22.23.5, using the development build, with no StrictMode and no React Compiler. Bundle sizes are esbuild 0.28.2 with minify on, platform browser, ESM output, then gzipped, against lodash 4.18.1 and lodash-es 4.18.1.
That's a deliberately small rig. It counts renders, not milliseconds, and the components are toys. I'll say what that does and doesn't prove at the end.
| Check | Before | After |
|---|---|---|
| Inline props into a memoized child (10 parent updates) | 10 renders | 0 |
| Context value built in render (3 consumers, 10 updates) | 30 renders | 0 |
| Derived state copied in an effect (10 prop changes) | 20 renders | 10 |
key={index} after removing the first of 100 rows | 99 row renders | 0 |
Whole-library lodash import, gzipped | 26,878 B | 1,440 B |
Check 1: Are Objects and Functions Created Inline Passed to a Memoized Child?
This is the one that survives a code review because it reads as perfectly normal React:
const Child = memo(function Child({ style, onPick }: Props) {
return <button style={style} onClick={onPick}>x</button>;
});
function Parent() {
const [tick, setTick] = useState(0);
// A new object and a new function on every render
return <Child style={{ color: 'red' }} onPick={() => {}} />;
}
memo compares props with reference equality, and { color: 'red' } is a new reference every time Parent renders. I updated the parent 10 times. The memoized child rendered 10 more times. With a module-level style object and a useCallback handler, it rendered 0 more times.
Is that a bug? Only if the child is memoized and the parent renders often. Without memo the child re-renders either way and the inline props cost nothing extra. The failure is the combination: someone added memo to be careful, then defeated it two lines later. If your project uses the React Compiler, it may handle this for you. I didn't measure that, and our React Compiler practical guide covers what it does and doesn't memoize.
Check 2: Is the Context Value Built During Render?
function Parent() {
const [tick, setTick] = useState(0);
const user = 'ada';
return (
<Ctx.Provider value={{ user }}>
<A /><B /><C />
</Ctx.Provider>
);
}
Three consumers, ten updates to Parent that had nothing to do with the user. Result: 30 consumer renders. Wrapping the value in useMemo(() => ({ user }), [user]) took it to 0.
The React docs describe this exactly: an object passed as a context value is a new reference on every render of the provider, so every component that calls useContext re-renders, even when the data hasn't changed. The docs also say it's an optimization that's unnecessary in smaller apps. My opinion, and you're free to disagree: put the useMemo in anyway when the provider sits near the root. It costs one line and the failure is invisible until the tree is big.
Check 3: Is Derived State Copied Into State With an Effect?
const [visible, setVisible] = useState(() => items.filter(isEven));
useEffect(() => {
setVisible(items.filter(isEven));
}, [items]);
I changed items 10 times. The effect version rendered 20 times, twice per change. Computing the list during render rendered 10 times, once per change.
The extra render isn't only wasted work. On 5 of the 10 changes, the first of the two renders showed a list of the wrong length before the effect caught up. I detect staleness by length only, so 5 is a lower bound. The React docs call this out under "You Might Not Need an Effect": storing a value derived from props or state in separate state, then syncing it with an effect, causes an extra render with a stale value and then another with the updated one. Their fix is the boring one. Calculate it while rendering.
Check 4: Do List Rows Use the Array Index as the Key?
{items.map((item, i) => <Row key={i} item={item} />)}
I rendered 100 memoized rows and removed the first item. With key={i}, 99 rows re-rendered, because every row's item prop shifted by one position. With key={item.id}, 0 re-rendered; React simply dropped the first row.
Counting renders undersells the real damage, which is state. In a three-row version, I opened the first row, then removed the first item. With index keys the list became item-1:open, item-2:closed. The open state had moved onto the wrong item. With id keys it was item-1:closed, item-2:closed, which is what you'd expect.
Index keys aren't always wrong. The React docs say they're safe for lists that never reorder, insert or delete, like the lines of a poem. But a list that comes from an API and gets filtered, sorted or edited is exactly the list that does. If you're reviewing generated code, search for key={i} and key={index} first. It's the fastest grep in this article.
Check 5: Does One Import Pull in the Whole Library?
import _ from 'lodash';
const onSearch = _.debounce(run, 300);
I bundled four ways of getting debounce and gzipped the result.
| Import | Minified | Gzipped |
|---|---|---|
import _ from 'lodash' then _.debounce | 73,818 B | 26,878 B |
import debounce from 'lodash/debounce' | 3,492 B | 1,641 B |
import { debounce } from 'lodash-es' | 2,900 B | 1,440 B |
import * as _ from 'lodash-es' then _.debounce | 2,900 B | 1,440 B |
The default import of CommonJS lodash shipped about 19 times the gzipped bytes of the named lodash-es import for the same function. The namespace import of lodash-es cost the same as the named one, because esbuild tree-shakes ES modules. That's one bundler, so check yours before quoting me; I didn't test Vite, webpack or Rollup.
Nothing here is specific to lodash. Any large CommonJS utility library imported as a default does the same thing. In review, the question is whether the import line names what the file uses.
What Didn't I Measure?
Plenty. These are counts in a development build, not time, and a re-render of a cheap component is cheap. Whether 30 renders matters depends on what's inside them. I ran without StrictMode, which would double the development renders. I didn't enable the React Compiler. I didn't test production builds, concurrent rendering or a real browser DOM. And the components are four-line toys, so treat the numbers as a demonstration of the mechanism, not a prediction for your app.
To reproduce, install react@19.3.1, react-dom@19.3.1 and jsdom, mount each component inside act() from react, and bump a counter in the component body. For bundles, call esbuild's build with bundle, minify and write: false, then gzip the output.
A Review Checklist You Can Paste Into a Prompt
When a generated component lands in your pull request, five questions cover this whole article:
- Is anything passed to a
memochild created inline, as an object, array or function? - Is a context provider's
valuean object literal? - Is there a
useEffectwhose only job is to callsetStatewith something computable from props or state? - Does any
.map()use the index as the key on a list that can change? - Does any import line pull in a whole library for one function?
None of those checks needs a profiler. They need a reviewer who knows the shape. If you want the same approach for testing instead of rendering, see our guide to testing AI-generated React components, and for restructuring a component that already exists, refactoring large React components.