For a year and a half I reviewed junior developers' React projects. Over 50 of them, across cohorts, after teaching the same people a curriculum I wrote. Different faces, same five mistakes.
The interesting part is not the list. It is that telling someone the mistake fixed almost nothing, and showing them the cost fixed it in a week.
The five, in order of frequency
1. State in the wrong place. A form's input values held at the page level, so every keystroke re-renders the whole screen. Or the opposite: two sibling components each keeping their own copy of the same list, and drifting apart.
The question that fixes this is not "should this be lifted?" It is "who else needs to know?" If the answer is nobody, it belongs where it is used.
2. Components that do everything. A 300-line component that fetches, transforms, renders a table, handles sorting, and owns the modal. It works, and nobody can change it.
The fix is not "split it up". It is "name the three things it does, and give each one a name". A component that fetches is not the same component that renders, and separating them makes both testable.
3. An effect for everything. useEffect used to derive state from props, to compute a total, to sync two pieces of state. Each one adds a render and a way to be out of sync.
Most of those effects are not effects. A value computed from props is a const in the render. A value computed from state is a const too. Effects are for the outside world: network, timers, subscriptions, the DOM.
4. No loading state, no error state, no empty state. The happy path is built and shipped. Then the API is slow and the screen is blank, or the list is empty and the layout collapses, or the request fails and nothing tells the user.
This is the mistake that costs the most in production and takes the least time to fix once someone points at it.
5. Copy-paste instead of a component, or an abstraction after two uses. Both directions, equally common. Three copies of the same button with slightly different padding, or a <GenericCard> with eight boolean props created after the second use.
The rule I gave them: copy it twice, extract on the third, and when you extract, extract the thing that is actually the same, not the thing that happens to look the same today.
Why telling them did not work
I tried. In review comments, in the workshop, with examples. The same mistake came back the next project.
What worked was making the cost visible, in their own code:
- Recording the profiler and showing them the 40 re-renders from one keystroke. Not a lecture about state colocation, their screen, their keystroke.
- Opening the network tab and showing the request firing four times because two components fetched the same thing.
- Deleting the API for ten seconds and letting them watch their own app show a white screen.
Nobody argues with their own screen. That is the whole trick, and it is not really a trick: it is the difference between a rule and a reason.
What I changed in my own reviews
Three things, and they made the reviews shorter, not longer.
- One thing per review. A review with fifteen comments gets zero fixes. A review with one named problem gets fixed, and the next review can be about the next one.
- Name the cost, not the rule. "This will re-render the list on every keystroke, and the list is 200 rows" beats "you should colocate state".
- Ask the question that leads to the answer. "Who else needs this value?" makes them decide. "Move this up" makes them obey.
What teaching 80 developers taught me about senior work
People do not need more patterns. They need the reasoning behind one pattern, applied to their own problem. The seniors I respect most are the ones who can say why a thing is wrong in this codebase, not the ones who can recite what is right in general.
I still use the same three questions in code review today, on a team of experienced engineers: who else needs to know, what does this do, and what happens when it fails.
Top comments (0)