You open a dashboard, switch to the Network tab and see three requests to /api/me. A moment later, another request appears. You haven't clicked anything.
The server responds quickly, the UI looks fine, and there are no errors in the console. Yet every visit generates work that might have been avoided.
React doesn't automatically send HTTP requests when a component renders. The requests come from your code, your framework or your data-fetching library. Understanding which of those owns a request is the first step towards fixing it.
Let's examine six common sources of unnecessary traffic, using a dashboard as our running example.
1. A re-render isn't a reason to fetch again
Consider a product list with a search field and a button that changes the layout:
function ProductList({ categoryId }) {
const [products, setProducts] = useState([]);
const [compact, setCompact] = useState(false);
useEffect(() => {
fetch(`/api/products?category=${categoryId}`)
.then(response => response.json())
.then(setProducts);
});
// Render products and layout controls...
}
The missing dependency array means the Effect runs after every committed render. Updating the layout can trigger another fetch. Updating the products can trigger yet another render, potentially creating a loop.
Adding an empty dependency array is tempting, but it would also prevent the Effect from responding to a new categoryId while the component remains mounted.
The better solution is to express the actual dependency:
import { useEffect, useState } from 'react';
function ProductList({ categoryId }) {
const [products, setProducts] = useState([]);
const [error, setError] = useState(null);
useEffect(() => {
const controller = new AbortController();
let active = true;
setProducts([]);
setError(null);
async function load() {
try {
const params = new URLSearchParams({ category: categoryId });
const response = await fetch(`/api/products?${params}`, {
signal: controller.signal
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
if (active) setProducts(data);
} catch (error) {
if (active && !controller.signal.aborted) setError(error);
}
}
void load();
return () => {
active = false;
controller.abort();
};
}, [categoryId]);
if (error) return <p>Unable to load products.</p>;
return <ul>{products.map(p => <li key={p.id}>{p.name}</li>)}</ul>;
}
This example also guards against obsolete responses and cancels the fetch when the Effect is cleaned up. Aborting a browser request does not guarantee that the server stops processing it.
The important change isn't the number of dependencies. It's that the dependency describes when the external data actually needs to change.
The object dependency trap
Even an Effect with a dependency array can run more often than expected:
const filters = { categoryId, sort: 'price' };
useEffect(() => {
// Fetch using filters...
}, [filters]);
Each render creates a new object. React compares dependencies using Object.is, so the next object is different even if its contents are identical.
If the object is only needed for the request, construct it inside the Effect and depend on its primitive inputs instead:
useEffect(() => {
const filters = { categoryId, sort: 'price' };
// Fetch using filters, with cleanup as above.
}, [categoryId]);
Don't silence the exhaustive-deps lint rule to make the network panel quieter. Change the code so the dependencies reflect the operation. See React: useEffect.
2. Strict Mode is showing you a problem, not necessarily causing one
A developer adds a fetch inside an Effect with an empty dependency array, reloads the page and sees two requests.
Why twice?
When Strict Mode is enabled at the root, React performs an additional setup and cleanup cycle for Effects in development. This checks whether the Effect behaves correctly when it is restarted. It is not an extra production-only requirement or a guarantee that Effects run exactly twice in all configurations.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 220" width="760" height="220" role="img" aria-label="Development Strict Mode: restartable Effects">
<rect width="760" height="220" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Development Strict Mode: restartable Effects</text>
<rect x="24" y="75" width="210" height="54" rx="6" fill="#e6eadd" stroke="#d9ddd2"/><text x="129.0" y="107.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">First setup</text>
<rect x="275" y="75" width="210" height="54" rx="6" fill="#fffef9" stroke="#ab4932"/><text x="380.0" y="107.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Cleanup</text>
<rect x="526" y="75" width="210" height="54" rx="6" fill="#e6eadd" stroke="#d9ddd2"/><text x="631.0" y="107.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Second setup</text>
<line x1="234" y1="102" x2="275" y2="102" stroke="#6d7268" stroke-width="1.5"/><polygon points="275.00,102.00 266.00,98.00 266.00,106.00" fill="#6d7268"/>
<line x1="485" y1="102" x2="526" y2="102" stroke="#6d7268" stroke-width="1.5"/><polygon points="526.00,102.00 517.00,98.00 517.00,106.00" fill="#6d7268"/>
<text x="129" y="153" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Start request</text>
<text x="380" y="153" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#ab4932">Abort or ignore result</text>
<text x="631" y="153" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Start or share request</text>
<text x="380" y="197" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Production does not include this additional development check.</text>
</svg>Removing Strict Mode can hide the symptom without addressing the underlying issue. Real users can still navigate away, return to a page, switch accounts or remount a component.
A particularly risky workaround is a ref that prevents subsequent executions:
const alreadyFetched = useRef(false);
useEffect(() => {
if (alreadyFetched.current) return;
alreadyFetched.current = true;
// Fetch data...
}, []);
This suppresses a setup rather than making it safe to restart. It can even leave the second setup without data if the first request was cancelled during cleanup.
For read operations, use proper cleanup and consider a shared request cache. For actions such as creating an order, send the request from the user event that actually initiates the purchase. An Effect that submits a purchase just because a component appeared is a poor fit for the operation. Server-side idempotency is still needed when submissions may be repeated.
When diagnosing Strict Mode, compare a development build with a production build. A cancelled row in the Network panel and a completed row are not proof of two completed server operations.
See React: Synchronizing with Effects and StrictMode.
3. Three components can share one request
A dashboard often has several independent consumers of the current user's data:
function Navigation() {
const user = useCurrentUser();
return <span>{user?.name}</span>;
}
function AccountMenu() {
const user = useCurrentUser();
return <span>{user?.email}</span>;
}
Moving a fetch into a custom hook improves reuse of code. It doesn't automatically share state or network requests. If useCurrentUser owns an ordinary Effect and local state, each mounted consumer can start its own fetch.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 374" width="760" height="374" role="img" aria-label="Three consumers, one shared query">
<rect width="760" height="374" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Three consumers, one shared query</text>
<text x="24" y="62" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="start" fill="#242b25">Independent hook instances</text>
<text x="24" y="208" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="start" fill="#242b25">Shared query cache</text>
<rect x="24" y="76" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="96.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 1</text>
<line x1="184" y1="91" x2="540" y2="91" stroke="#ab4932" stroke-width="1.5"/><polygon points="540.00,91.00 531.00,87.00 531.00,95.00" fill="#ab4932"/>
<rect x="24" y="112" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="132.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 2</text>
<line x1="184" y1="127" x2="540" y2="127" stroke="#ab4932" stroke-width="1.5"/><polygon points="540.00,127.00 531.00,123.00 531.00,131.00" fill="#ab4932"/>
<rect x="24" y="148" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="168.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 3</text>
<line x1="184" y1="163" x2="540" y2="163" stroke="#ab4932" stroke-width="1.5"/><polygon points="540.00,163.00 531.00,159.00 531.00,167.00" fill="#ab4932"/>
<rect x="540" y="76" width="196" height="102" rx="6" fill="#fffef9" stroke="#ab4932"/><text x="638.0" y="132.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">3 fetches</text>
<line x1="24" y1="190" x2="736" y2="190" stroke="#d9ddd2" stroke-width="1.5"/>
<rect x="24" y="222" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="242.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 1</text>
<path d="M184 237 H218 V273 H270" fill="none" stroke="#6d7268" stroke-width="1.5"/>
<rect x="24" y="258" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="278.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 2</text>
<path d="M184 273 H218 V273 H270" fill="none" stroke="#6d7268" stroke-width="1.5"/>
<rect x="24" y="294" width="160" height="30" rx="6" fill="#fffef9" stroke="#d9ddd2"/><text x="104.0" y="314.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Component 3</text>
<path d="M184 309 H218 V273 H270" fill="none" stroke="#6d7268" stroke-width="1.5"/>
<rect x="270" y="248" width="200" height="50" rx="6" fill="#e6eadd" stroke="#242b25"/><text x="370.0" y="278.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">Shared query</text>
<line x1="470" y1="273" x2="540" y2="273" stroke="#6d7268" stroke-width="1.5"/><polygon points="540.00,273.00 531.00,269.00 531.00,277.00" fill="#6d7268"/>
<rect x="540" y="248" width="196" height="50" rx="6" fill="#e6eadd" stroke="#242b25"/><text x="638.0" y="278.0" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="middle" fill="#242b25">1 fetch</text>
<text x="380" y="352" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="middle" fill="#6d7268">Illustrative cold-cache requests with identical keys.</text>
</svg>One way to address this is to fetch at a common parent and pass the result down. Another is a shared query cache, especially when consumers are scattered across routes.
Here's an example using TanStack Query v5:
npm install @tanstack/react-query
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
import { useState } from 'react';
export function QueryProvider({ children }) {
const [client] = useState(() => new QueryClient());
return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
}
export function useCurrentUser(accountId) {
return useQuery({
queryKey: ['current-user', accountId],
enabled: Boolean(accountId),
staleTime: 60_000,
queryFn: async ({ signal }) => {
const response = await fetch('/api/me', { signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
});
}
Consumers under the same provider and with the same key can share query data and an outstanding fetch. The account identifier scopes the cache; the server must independently authenticate the request. Clear or replace the session's cache when authentication changes, and ensure old requests cannot populate the new session's data. For server rendering, isolate query clients per request rather than sharing private data globally.
Notice that the query client isn't created on every render. Recreating it would discard the shared cache that makes this approach useful.
Request sharing does not imply exactly one HTTP request forever. Invalidations, cancellations, retries and freshness rules can all cause subsequent requests.
4. Your data-fetching library might be refetching intentionally
You open a page, switch to your editor, then return to the browser. Suddenly, another GET request appears.
This can be normal. TanStack Query considers cached data stale by default and can refresh stale queries on mount, window focus or network reconnection. Failed client-side queries also have a default retry policy.
These behaviours help keep applications up to date. They can nevertheless surprise developers who assume caching means no more requests until a record is deleted.
Consider a product category list that changes infrequently:
const categories = useQuery({
queryKey: ['categories'],
queryFn: async ({ signal }) => {
const response = await fetch('/api/categories', { signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
},
staleTime: 5 * 60_000,
gcTime: 15 * 60_000
});
staleTime determines how long the data is considered fresh. gcTime governs how long inactive query data can remain in the cache. It isn't a freshness setting or a periodic polling interval.
A five-minute freshness window can be sensible for slowly changing categories. It might be inappropriate for available inventory or a live trading quote. Choose it based on the consequences of stale data.
After a successful category mutation, invalidate the relevant query rather than disabling freshness checks everywhere:
await queryClient.invalidateQueries({ queryKey: ['categories'] });
Also inspect retry, refetchInterval, refetchOnMount and refetchOnWindowFocus before blaming React itself. Avoid retrying permanent failures indiscriminately. These policies should match the resource rather than a global desire to eliminate every request.
See TanStack Query: Important Defaults and Query Invalidation.
5. A search box can turn typing into a burst of traffic
Searching for keyboard can produce eight input changes. If an Effect fetches on each change, the application can issue eight requests even though the user only cares about the final result.
One option is to debounce the input:
function useDebouncedValue(value, delay = 300) {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
const timer = setTimeout(() => setDebounced(value), delay);
return () => clearTimeout(timer);
}, [value, delay]);
return debounced;
}
function useProductSearch(input) {
const term = useDebouncedValue(input.trim());
return useQuery({
queryKey: ['product-search', term],
enabled: term.length >= 2,
queryFn: async ({ signal }) => {
const params = new URLSearchParams({ q: term });
const response = await fetch(`/api/search?${params}`, { signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
},
staleTime: 30_000,
retry: false
});
}
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 278" width="760" height="278" role="img" aria-label="Debouncing search input">
<rect width="760" height="278" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Debouncing search input</text>
<text x="24" y="65" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="start" fill="#242b25">Keystrokes: k e y b o a r d</text>
<text x="24" y="99" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="start" fill="#242b25">Immediate fetch</text>
<text x="24" y="175" font-family="Arial, sans-serif" font-size="14" font-weight="400" text-anchor="start" fill="#242b25">Debounced fetch</text>
<line x1="190" y1="110" x2="720" y2="110" stroke="#d9ddd2" stroke-width="1.5"/>
<line x1="190" y1="186" x2="720" y2="186" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="210" cy="110" r="6" fill="#ab4932"/>
<line x1="210" y1="178" x2="210" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="255" cy="110" r="6" fill="#ab4932"/>
<line x1="255" y1="178" x2="255" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="300" cy="110" r="6" fill="#ab4932"/>
<line x1="300" y1="178" x2="300" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="345" cy="110" r="6" fill="#ab4932"/>
<line x1="345" y1="178" x2="345" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="390" cy="110" r="6" fill="#ab4932"/>
<line x1="390" y1="178" x2="390" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="435" cy="110" r="6" fill="#ab4932"/>
<line x1="435" y1="178" x2="435" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="480" cy="110" r="6" fill="#ab4932"/>
<line x1="480" y1="178" x2="480" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<circle cx="525" cy="110" r="6" fill="#ab4932"/>
<line x1="525" y1="178" x2="525" y2="194" stroke="#d9ddd2" stroke-width="1.5"/>
<line x1="525" y1="209" x2="660" y2="209" stroke="#6d7268" stroke-width="1.5"/><polygon points="660.00,209.00 651.00,205.00 651.00,213.00" fill="#6d7268"/>
<text x="592" y="230" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">300 ms pause</text>
<circle cx="660" cy="186" r="7" fill="#242b25"/>
<text x="720" y="93" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="end" fill="#ab4932">8 starts</text>
<text x="720" y="168" font-family="Arial, sans-serif" font-size="13" font-weight="400" text-anchor="end" fill="#242b25">1 start</text>
<text x="24" y="256" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Assumes each keystroke is less than 300 ms apart and a cold cache.</text>
</svg>If the eight characters arrive less than 300 milliseconds apart, the debounced example can initiate just one query after the final keystroke, assuming a cold cache. Pauses can still cause intermediate searches, which is often desirable.
Debouncing reduces how frequently new searches begin. Cancellation helps stop obsolete operations. Query keys ensure each search term has its own result. These are complementary mechanisms, not interchangeable fixes.
While the input is ahead of the debounced term, the UI may still show results for the previous term. Label those results appropriately or hide them until the debounced term catches up. Avoid presenting an old result as if it belonged to the newest input.
React's useDeferredValue can help render expensive results responsively, but it is not a fixed-delay debounce or a guarantee of fewer network requests.
6. Some requests aren't duplicated — they're just arriving too late
Consider a dashboard that loads a profile, then mounts an orders component, then mounts a notifications component.
If each component waits until its parent has loaded before fetching, the requests form a network waterfall.
Suppose each request takes 300 milliseconds. Three independent requests started sequentially take roughly 900 milliseconds. Started together, they could finish in roughly 300 milliseconds, ignoring rendering, scheduling and network contention.
SVG source
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 332" width="760" height="332" role="img" aria-label="Sequential versus parallel fetching">
<rect width="760" height="332" rx="8" fill="#f6f4ee"/>
<text x="24" y="34" font-family="Arial, sans-serif" font-size="20" font-weight="600" text-anchor="start" fill="#242b25">Sequential versus parallel fetching</text>
<text x="24" y="65" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="start" fill="#242b25">Sequential requests</text>
<text x="24" y="185" font-family="Arial, sans-serif" font-size="14" font-weight="600" text-anchor="start" fill="#242b25">Parallel independent requests</text>
<text x="24" y="92" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Profile</text>
<rect x="150" y="77" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="24" y="212" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Profile</text>
<rect x="150" y="197" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="24" y="120" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Orders</text>
<rect x="340" y="105" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="24" y="240" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Orders</text>
<rect x="150" y="225" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="24" y="148" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Notifications</text>
<rect x="530" y="133" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="24" y="268" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="start" fill="#6d7268">Notifications</text>
<rect x="150" y="253" width="190" height="20" rx="6" fill="#e6eadd" stroke="#242b25"/>
<text x="150" y="166" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">0 ms</text>
<text x="150" y="286" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">0 ms</text>
<text x="340" y="166" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">300 ms</text>
<text x="340" y="286" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">300 ms</text>
<text x="530" y="166" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">600 ms</text>
<text x="530" y="286" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">600 ms</text>
<text x="720" y="166" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">900 ms</text>
<text x="720" y="286" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="middle" fill="#6d7268">900 ms</text>
<text x="720" y="310" font-family="Arial, sans-serif" font-size="12" font-weight="400" text-anchor="end" fill="#6d7268">Illustrative timing, not a benchmark.</text>
</svg>When the data is truly independent, start it together at a route loader or another appropriate data-loading boundary:
async function getJSON(url, signal) {
const response = await fetch(url, { signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
async function loadDashboard(signal) {
const [profile, orders, notifications] = await Promise.all([
getJSON('/api/me', signal),
getJSON('/api/orders', signal),
getJSON('/api/notifications', signal)
]);
return { profile, orders, notifications };
}
Here, every endpoint derives the current user from the authenticated session, so the orders request doesn't need to wait for the profile response.
If an endpoint genuinely needs a value returned by an earlier request, the dependency is real. Don't parallelise it blindly. And if one dashboard section can fail independently, consider separate queries or explicit partial-error handling rather than treating the entire dashboard as one all-or-nothing operation. Promise.all rejects on the first rejection and does not cancel other fetches automatically.
Server-side rendering and route-level preloading can also reduce waterfalls. When using a hydrated query cache, ensure the server and client use matching keys and compatible freshness settings; otherwise, a client may immediately refetch data already retrieved on the server.
Bonus: Measure requests, not just renders
The React Profiler can tell you how often a component renders. It cannot, on its own, tell you how many HTTP requests reach your backend.
Open the browser Network panel, enable Preserve log, filter to Fetch/XHR, and reproduce one action at a time. Inspect the method, URL, query parameters, Initiator, status, timing and whether a response came from cache. An OPTIONS preflight is not a duplicate GET. A redirect, a retry or a background refresh can also explain an apparent extra request.
Compare development and production builds, and record whether HTTP caching is enabled. Use backend access logs and request IDs to confirm how many requests actually arrived and completed.
| Symptom | First thing to investigate |
|---|---|
| Two requests on initial development mount | Strict Mode and cleanup |
| Request after unrelated UI change | Effect dependencies |
| Same request from several widgets | Independent hook instances and shared query keys |
| Request after switching tabs | Refetch-on-focus and freshness settings |
| Request for every character typed | Debouncing and cancellation |
| Long chain of different requests | Network waterfall |
| Server and browser both fetch on first load | Hydration and query-cache configuration |
A small measurement is more useful than a speculative optimisation. For example, if three components each initiate an identical fetch, combining them into one shared operation reduces initiations from three to one in that scenario. That is an illustrative count, not a measured latency improvement.
Final thoughts
A React application can be responsive and still generate unnecessary traffic. The problem often isn't that React renders too much. It's that the application's data-fetching strategy is tied too closely to rendering, mounting or transient UI state.
Before adding another memoization helper, identify who owns the request, what makes its data stale and which consumers can safely share it.
The goal isn't to make the Network tab empty. It's to make every request have a reason to exist.
THE CONVERSATION
Comments
Questions, useful examples and different approaches are welcome. Keep the discussion thoughtful and on topic.
Loading comments…