September 10, 2026 · By Dhurka Manchukan, Software Engineer · Engineering · 4 min read
Building scalable React applications
Most React projects don't fail because of the framework. They fail because state and API logic slowly leak into every component that touches them, until changing one screen means touching six files and hoping nothing else breaks. The good news is that a small number of habits, applied early, keep a codebase healthy well past its first six months.
Keep data and business logic out of presentation components
The single highest-leverage habit is separating what a component shows from where its data comes from. A component that fetches, transforms, caches and renders is hard to test and hard to reuse. Move fetching into a thin layer (a set of functions or hooks) and let components receive plain props. When the API changes shape, you fix one adapter instead of every screen.
In practice this means a folder for API clients, a folder for hooks that wrap them, and components that only know about the hook's return value. Components should not know whether data came from REST, GraphQL or a local cache.
Prefer small components with a narrow job
A component that renders a card, decides what happens on click and also formats a date is three components pretending to be one. Splitting it up is not about hitting a line count. It is about making each piece easy to name. If you can't describe a component in one short sentence, it is probably doing too much.
- Presentational components take props and render markup, nothing else.
- Container or hook layers own fetching, mutation and derived state.
- Formatting helpers (dates, currency, slugs) live in plain functions with their own tests.
Be deliberate about state
Not all state is equal. Server state (data that lives on a backend) has different needs from UI state (is this menu open) and from URL state (which tab is selected). Keeping each kind in the right place removes a huge class of bugs. Put UI state as close to the component that uses it as possible, put shareable state in the URL when users might want to link to it, and treat server data as a cache that can be refetched instead of a source of truth you must hand-synchronise.
Reach for global state last. Most apps that adopt a global store on day one end up storing things there that never needed to be shared.
Type the boundaries, not everything
TypeScript pays off most at the edges: API responses, form values, route params and component props. Define types where data enters your app and let inference carry them inward. Over-annotating internal variables adds noise without adding safety. When an API response is unreliable, validate it at the boundary so the rest of the code can trust its types.
Make the folder structure follow features
Grouping by technical role (all components in one folder, all hooks in another) works for small apps and becomes painful as they grow. Grouping by feature keeps everything related to one part of the product together: its components, hooks, types and tests. A new teammate can open one folder and understand a whole slice of the app.
Test behaviour, not implementation
Tests that assert on internal state break every time you refactor and catch very few real bugs. Tests that render a component, interact with it like a user would and check what appears on screen survive refactors and fail when something users care about breaks. A modest set of these, plus unit tests for pure helper functions, gives more confidence than a large pile of brittle tests.
Measure before you optimise
Memoisation, lazy loading and virtualisation are useful, but applying them everywhere adds complexity for no benefit. Use the browser's performance tools to find a real bottleneck first. Usually the biggest wins are shipping less JavaScript, avoiding unnecessary re-renders of large lists and loading images at the right size.
A short checklist
- Can this component be described in one sentence?
- Does it need to know where its data comes from?
- Is this state global because it must be, or because it was easy?
- Is the API response validated at the boundary?
- Would this test still pass after a harmless refactor?
None of these habits is glamorous, but together they are the difference between a codebase that speeds you up over time and one that slowly grinds every change to a halt.
Written by
Dhurka Manchukan
Software Engineer · Sri Lanka
Dhurka Manchukan is a software engineer based in Sri Lanka and the person behind MDXTORA. Dhurka designs, builds and runs QRinst, Faviqo and Wayvert, and writes the articles in the Journal from what comes up while building them.
About the author →Keep reading
- EngineeringHow I built a production QR platformNotes on building QRinst — a QR code platform for creating, managing and tracking codes.
- ProductBuilding a travel toolkit that works without an accountNotes on building Wayvert, a free travel toolkit for currency, units, time zones and trip budgets, and the decisions behind keeping it fast, honest and light on data.
- GuidesHow to estimate a trip budget before you bookA practical way to estimate what a trip will cost: the four daily categories, how to handle flights and currency, and how much buffer to add.
