All articles
ReactHooksJavaScriptDebugging

Fixing useEffect Infinite Loops and Stale Closures in React

Why useEffect loops forever or reads old state, with broken and fixed code for object deps, derived state, intervals, listeners and racing fetches.

Tushar Pachouri19 min read

useEffect bugs come in two flavours that look like opposites. Either the effect runs too often, re-rendering or refetching forever, or it runs too rarely and keeps reading values from a render that is long gone. Both come from the same two facts: every render creates new values, and every function remembers the values of the render that created it.

TL;DR

  • An effect re-runs when any dependency is not Object.is-equal to its value from the last render. Objects, arrays and functions created during render are new every time, so they fire the effect after every render.
  • If that effect also sets state to a new object or array, you have a loop. Depend on primitives, create the object inside the effect, or memoize it.
  • Values you can compute from props and state belong in render, not in state that an effect keeps in sync.
  • Callbacks set up once (intervals, listeners, socket handlers) see the state from the render that created them. Use functional updates, a ref holding the latest value, or useEffectEvent where your React version has it.
  • StrictMode running effects twice in development is a test of your cleanup, and exhaustive-deps warnings are bug reports. Fix the code, not the messenger.

What React actually tells you

On React 18.3, an effect that sets state on every run eventually logs this in development:

Text
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.

That is a console error, not an exception. React keeps rendering, the tab pins a CPU core, and in a production build you get no message at all. When the loop runs through synchronous updates instead (class lifecycles, or state set in a layout effect), React throws:

Text
Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

The wording shifts between versions (newer releases drop the Warning: prefix), so search your console for "Maximum update depth exceeded" rather than the full sentence. A different message, "Too many re-renders", means you are calling a state setter during render itself, usually onClick={setOpen(true)} instead of onClick={() => setOpen(true)}.

One more catch: if the state update happens after an await or inside a .then(), React doesn't see it as a nested update, so you usually get no warning at all, just an endless stream of requests. When the Network panel keeps scrolling while you sit still, go looking for an effect.

Loop 1: an effect with no dependency array

Without a dependency array, an effect runs after every render. That's fine for an effect that only touches the outside world. It becomes a loop as soon as the effect stores a fresh object in state:

TSX
import { useEffect, useRef, useState } from "react";

export function Panel() {
  const ref = useRef<HTMLDivElement>(null);
  const [size, setSize] = useState({ width: 0, height: 0 });

  // Runs after every render, and every run stores a brand-new object.
  useEffect(() => {
    if (!ref.current) return;
    setSize({ width: ref.current.offsetWidth, height: ref.current.offsetHeight });
  });

  return (
    <div ref={ref}>
      {size.width} x {size.height}
    </div>
  );
}

React skips a re-render when the new state is Object.is-equal to the old state. A fresh { width, height } never is, so each effect run schedules another render, which runs the effect again.

Each run stores a new object, Object.is never matches, and React renders again.

The fix is to decide when the effect should really run (here: on mount, then whenever the element resizes) and to hand React the previous object when nothing changed:

TSX
import { useEffect, useRef, useState } from "react";

export function Panel() {
  const ref = useRef<HTMLDivElement>(null);
  const [size, setSize] = useState({ width: 0, height: 0 });

  useEffect(() => {
    const el = ref.current;
    if (!el) return;

    const measure = () => {
      const width = el.offsetWidth;
      const height = el.offsetHeight;
      setSize((prev) =>
        prev.width === width && prev.height === height ? prev : { width, height },
      );
    };

    measure();
    const observer = new ResizeObserver(measure);
    observer.observe(el);
    return () => observer.disconnect();
  }, []);

  return (
    <div ref={ref}>
      {size.width} x {size.height}
    </div>
  );
}

Returning prev from the updater is a cheap trick worth remembering. React gets the same reference back, so its bailout kicks in.

Loop 2: dependencies that change every render

A dependency array doesn't help if one of the dependencies is recreated during render. This component sends requests forever:

TSX
import { useEffect, useState } from "react";

type Order = { id: string; total: number };

export function Orders({ userId }: { userId: string }) {
  const [orders, setOrders] = useState<Order[]>([]);
  const query = { userId, status: "open" }; // a new object on every render

  useEffect(() => {
    const params = new URLSearchParams(query);
    fetch(`/api/orders?${params}`)
      .then((res) => res.json())
      .then(setOrders);
  }, [query]);

  return <p>{orders.length} open orders</p>;
}

The fetch resolves, setOrders stores a new array, the component re-renders, query is a new object, and the effect fires again. Here is the comparison React makes, in plain Node:

JavaScript
const makeQuery = (userId) => ({ userId, status: "open" });

const first = makeQuery("u_42");
const second = makeQuery("u_42");

console.log(Object.is(first, second));
console.log(Object.is(first.userId, second.userId));
console.log(Object.is(() => {}, () => {}));
Text
false
true
false

Same contents, different object. Functions behave the same way, which is why a loadData helper declared in the component body and listed as a dependency loops just like an object does.

The query object is new on every render, while the userId string stays equal.

Depend on primitives

Usually the object exists only for the effect, so build it inside the effect and depend on the primitive it comes from:

TSX
import { useEffect, useState } from "react";

type Order = { id: string; total: number };

export function Orders({ userId }: { userId: string }) {
  const [orders, setOrders] = useState<Order[]>([]);

  useEffect(() => {
    const params = new URLSearchParams({ userId, status: "open" });
    fetch(`/api/orders?${params}`)
      .then((res) => res.json())
      .then(setOrders);
  }, [userId]);

  return <p>{orders.length} open orders</p>;
}

Strings, numbers and booleans compare by value, so the effect only re-runs when userId actually changes. When a parent passes an object prop, destructure it and list the fields (const { userId, status } = filters; and then [userId, status]), so the child doesn't depend on whether the parent memoized anything.

Memoize when the value is shared

If the effect and an event handler both need the same function, memoize it with useCallback (or an object with useMemo) so its identity changes only when its inputs do:

TSX
import { useCallback, useEffect, useState } from "react";

type Order = { id: string; total: number };

export function Orders({ userId }: { userId: string }) {
  const [orders, setOrders] = useState<Order[]>([]);

  const loadOrders = useCallback(async () => {
    const params = new URLSearchParams({ userId, status: "open" });
    const res = await fetch(`/api/orders?${params}`);
    setOrders(await res.json());
  }, [userId]);

  useEffect(() => {
    void loadOrders();
  }, [loadOrders]);

  return (
    <div>
      <p>{orders.length} open orders</p>
      <button onClick={() => void loadOrders()}>Refresh</button>
    </div>
  );
}

For the object from the broken example, use useMemo. Now query keeps its identity until userId changes, so [query] is safe:

TSX
import { useEffect, useMemo, useState } from "react";

type Order = { id: string; total: number };

export function Orders({ userId }: { userId: string }) {
  const [orders, setOrders] = useState<Order[]>([]);
  const query = useMemo(() => ({ userId, status: "open" }), [userId]);

  useEffect(() => {
    const params = new URLSearchParams(query);
    fetch(`/api/orders?${params}`)
      .then((res) => res.json())
      .then(setOrders);
  }, [query]);

  return <p>{orders.length} open orders</p>;
}

React treats memoization as a performance optimization, not a guarantee, so an effect that depends on a memoized value should still be safe to run one extra time.

Note: The Orders examples skip race handling to stay short. The stale closures section below shows how to add it.

Loop 3: fetched data that is also a dependency

This loop is one that exhaustive-deps seems to push you into. You append fetched items to existing state, the linter says items is missing, you add it, and now:

TSX
import { useEffect, useState } from "react";

type Item = { id: string; title: string };

export function Feed({ page }: { page: number }) {
  const [items, setItems] = useState<Item[]>([]);

  useEffect(() => {
    fetch(`/api/items?page=${page}`)
      .then((res) => res.json())
      .then((next: Item[]) => setItems([...items, ...next]));
  }, [page, items]); // items added to keep the linter quiet

  return <p>{items.length} items</p>;
}

Every response changes items, which re-runs the effect, which fetches the same page and appends it again. You get duplicates and endless requests. The linter's own message, quoted later in this post, already points at the fix: a functional update. React passes the latest state into the updater, so the effect no longer reads items at all:

TSX
import { useEffect, useState } from "react";

type Item = { id: string; title: string };

export function Feed({ page }: { page: number }) {
  const [items, setItems] = useState<Item[]>([]);

  useEffect(() => {
    let ignore = false;

    fetch(`/api/items?page=${page}`)
      .then((res) => res.json())
      .then((next: Item[]) => {
        if (!ignore) setItems((prev) => [...prev, ...next]);
      });

    return () => {
      ignore = true;
    };
  }, [page]);

  return <p>{items.length} items</p>;
}

The ignore flag matters here. StrictMode runs this effect twice in development, and without the flag page 1 would be appended twice. Both topics get their own sections below. The flag also assumes page only advances after the previous page has loaded, the usual infinite-scroll guard. If page can jump from 2 to 3 before page 2 arrives, page 2 is dropped for good, so store results keyed by page number instead.

Derived state belongs in render

Some effects exist only to copy props into state:

TSX
import { useEffect, useState } from "react";

type Todo = { id: number; title: string; done: boolean };

export function TodoList({ todos, showDone }: { todos: Todo[]; showDone: boolean }) {
  const [visible, setVisible] = useState<Todo[]>([]);

  useEffect(() => {
    setVisible(showDone ? todos : todos.filter((todo) => !todo.done));
  }, [todos, showDone]);

  return (
    <ul>
      {visible.map((todo) => (
        <li key={todo.id}>{todo.title}</li>
      ))}
    </ul>
  );
}

This one doesn't loop, but it renders twice on every change, the first paint shows an empty list, and it is one deleted dependency array away from becoming Loop 1. If a value can be computed from props and state, compute it during render:

TSX
type Todo = { id: number; title: string; done: boolean };

export function TodoList({ todos, showDone }: { todos: Todo[]; showDone: boolean }) {
  const visible = showDone ? todos : todos.filter((todo) => !todo.done);

  return (
    <ul>
      {visible.map((todo) => (
        <li key={todo.id}>{todo.title}</li>
      ))}
    </ul>
  );
}

If the calculation is genuinely expensive, wrap it in useMemo with [todos, showDone] as dependencies. You still don't need state or an effect.

Stale closures

Now the opposite bug: the effect runs once, as you asked, but the callbacks it set up keep seeing old values. Each render is a function call with its own constants. A closure created during the first render holds the first render's count forever, no matter how many renders follow.

EACH RENDER IS A SNAPSHOT Render 1Render 2Render 3Render 4 count = 0count = 1count = 2count = 3 captured once interval callback closure holds count = 0 tick 1 reads 0tick 2 reads 0tick 3 reads 0 Later renders hold newer values. The callback never sees them.
A callback created in the first render keeps that render's values for good.

You can watch this happen without React. The store below plays the part of React state, and the local count is the snapshot a render would take:

JavaScript
// stale-closure.mjs: the same bug as a stale React interval, with no React.
function createStore(initial) {
  let value = initial;
  return {
    get: () => value,
    set(next) {
      value = typeof next === "function" ? next(value) : next;
    },
  };
}

function startCounter(label, increment) {
  const store = createStore(0);
  const count = store.get(); // like a render: a snapshot in a local constant

  return new Promise((resolve) => {
    let ticks = 0;
    const id = setInterval(() => {
      increment(store, count);
      ticks += 1;
      console.log(`${label} tick ${ticks}: closure sees ${count}, store holds ${store.get()}`);
      if (ticks === 3) {
        clearInterval(id);
        resolve();
      }
    }, 10);
  });
}

// Broken: computes the next value from the captured snapshot.
await startCounter("stale", (store, count) => store.set(count + 1));

// Fixed: asks the store for the latest value at call time.
await startCounter("fixed", (store) => store.set((current) => current + 1));
Terminal
node stale-closure.mjs
Text
stale tick 1: closure sees 0, store holds 1
stale tick 2: closure sees 0, store holds 1
stale tick 3: closure sees 0, store holds 1
fixed tick 1: closure sees 0, store holds 1
fixed tick 2: closure sees 0, store holds 2
fixed tick 3: closure sees 0, store holds 3

The stale version keeps writing 0 + 1. The fixed version passes an updater that receives the current value when it runs, which is exactly what React's functional updates do.

setInterval reading an old count

Here is the same bug in a component:

TSX
import { useEffect, useState } from "react";

export function Timer() {
  const [seconds, setSeconds] = useState(0);

  useEffect(() => {
    const id = setInterval(() => {
      setSeconds(seconds + 1); // seconds is always 0 in here
    }, 1000);
    return () => clearInterval(id);
  }, []);

  return <p>{seconds}s</p>;
}

The interval was created during the first render, so it always computes 0 + 1 and the timer sticks at 1. Adding seconds to the dependencies works, but it tears down and recreates the interval every second. A functional update is the real fix:

TSX
import { useEffect, useState } from "react";

export function Timer() {
  const [seconds, setSeconds] = useState(0);

  useEffect(() => {
    const id = setInterval(() => {
      setSeconds((s) => s + 1);
    }, 1000);
    return () => clearInterval(id);
  }, []);

  return <p>{seconds}s</p>;
}

Event listeners reading old state

Functional updates only help when you are setting state, not when a long-lived listener needs to read the latest value. Take a save shortcut, using this small helper:

TypeScript
// drafts.ts
export async function saveDraft(text: string): Promise<void> {
  await fetch("/api/drafts", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text }),
  });
}
TSX
import { useEffect, useState } from "react";
import { saveDraft } from "./drafts";

export function Editor() {
  const [draft, setDraft] = useState("");

  useEffect(() => {
    const onKeyDown = (event: KeyboardEvent) => {
      if ((event.ctrlKey || event.metaKey) && event.key === "s") {
        event.preventDefault();
        void saveDraft(draft); // always the empty draft from the first render
      }
    };
    window.addEventListener("keydown", onKeyDown);
    return () => window.removeEventListener("keydown", onKeyDown);
  }, []);

  return <textarea value={draft} onChange={(event) => setDraft(event.target.value)} />;
}

Keep the latest value in a ref. The listener reads ref.current when it fires, not when it was created:

TSX
import { useEffect, useRef, useState } from "react";
import { saveDraft } from "./drafts";

export function Editor() {
  const [draft, setDraft] = useState("");
  const draftRef = useRef(draft);

  useEffect(() => {
    draftRef.current = draft;
  }, [draft]);

  useEffect(() => {
    const onKeyDown = (event: KeyboardEvent) => {
      if ((event.ctrlKey || event.metaKey) && event.key === "s") {
        event.preventDefault();
        void saveDraft(draftRef.current);
      }
    };
    window.addEventListener("keydown", onKeyDown);
    return () => window.removeEventListener("keydown", onKeyDown);
  }, []);

  return <textarea value={draft} onChange={(event) => setDraft(event.target.value)} />;
}

For one window listener, listing draft as a dependency and re-subscribing on every keystroke is also fine. The ref matters when the subscription is expensive: a WebSocket, a map widget, or a third-party SDK you don't want to rebuild on every change.

Async responses arriving out of order

A search box that fetches on every keystroke has a quieter stale-value bug:

TSX
import { useEffect, useState } from "react";

type Result = { id: string; title: string };

export function Search({ query }: { query: string }) {
  const [results, setResults] = useState<Result[]>([]);

  useEffect(() => {
    fetch(`/api/search?q=${encodeURIComponent(query)}`)
      .then((res) => res.json())
      .then(setResults);
  }, [query]);

  return (
    <ul>
      {results.map((result) => (
        <li key={result.id}>{result.title}</li>
      ))}
    </ul>
  );
}

Type "re" and then "react" quickly. If the "re" request is slower, its response lands last and overwrites the correct results. The fix lives in the cleanup function, which React runs before the next run of the effect and on unmount. The simplest version is an ignore flag:

TSX
import { useEffect, useState } from "react";

type Result = { id: string; title: string };

export function Search({ query }: { query: string }) {
  const [results, setResults] = useState<Result[]>([]);

  useEffect(() => {
    let ignore = false;

    fetch(`/api/search?q=${encodeURIComponent(query)}`)
      .then((res) => res.json())
      .then((data: Result[]) => {
        if (!ignore) setResults(data);
      });

    return () => {
      ignore = true;
    };
  }, [query]);

  return (
    <ul>
      {results.map((result) => (
        <li key={result.id}>{result.title}</li>
      ))}
    </ul>
  );
}

AbortController goes one step further and cancels the request itself, which saves bandwidth and server work:

TSX
import { useEffect, useState } from "react";

type Result = { id: string; title: string };

export function Search({ query }: { query: string }) {
  const [results, setResults] = useState<Result[]>([]);
  const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    const controller = new AbortController();

    fetch(`/api/search?q=${encodeURIComponent(query)}`, { signal: controller.signal })
      .then((res) => {
        if (!res.ok) throw new Error(`Search failed with status ${res.status}`);
        return res.json();
      })
      .then((data: Result[]) => {
        setResults(data);
        setError(null);
      })
      .catch((err: unknown) => {
        if (controller.signal.aborted) return; // superseded, not a real error
        setError(err instanceof Error ? err.message : String(err));
      });

    return () => controller.abort();
  }, [query]);

  if (error) return <p role="alert">{error}</p>;

  return (
    <ul>
      {results.map((result) => (
        <li key={result.id}>{result.title}</li>
      ))}
    </ul>
  );
}

I check controller.signal.aborted rather than the error's name, so any rejection caused by the cleanup is ignored, even if you later pass a custom reason to abort(reason), which is not an AbortError.

StrictMode runs effects twice in development

In React 18 and later, <StrictMode> mounts each component, runs the effect cleanups as if it had unmounted, then runs the effects again. It does this only in development. Take an effect that logs:

TSX
import { useEffect } from "react";

export function ChatRoom({ roomId }: { roomId: string }) {
  useEffect(() => {
    console.log("connect", roomId);
    const socket = new WebSocket(`wss://chat.example.com/rooms/${roomId}`);
    return () => {
      console.log("disconnect", roomId);
      socket.close();
    };
  }, [roomId]);

  return <h2>#{roomId}</h2>;
}

With roomId set to general, the development console shows:

Text
connect general
disconnect general
connect general

That isn't a bug. React is checking that your cleanup undoes your setup, because the same sequence happens for real when the user navigates away and back or when roomId changes. The usual "fix" makes things worse:

TSX
import { useEffect, useRef } from "react";

export function ChatRoom({ roomId }: { roomId: string }) {
  const connected = useRef(false);

  useEffect(() => {
    if (connected.current) return; // "only connect once"
    connected.current = true;
    const socket = new WebSocket(`wss://chat.example.com/rooms/${roomId}`);
    return () => socket.close();
  }, [roomId]);

  return <h2>#{roomId}</h2>;
}

Under StrictMode, the first run's cleanup closes the socket, the second run returns early, and you end up with no connection at all. It also never reconnects when roomId changes. If an effect misbehaves when it runs twice, fix the cleanup. Two requests in development for a fetching effect are expected, and the ignore flag or AbortController makes the first one harmless.

CLEANUP UNDOES SETUP RUN 1 connect CLEANUP socket.close() RUN 2 connect RESULT 1 open socket GUARDED WITH A REF RUN 1 connect CLEANUP socket.close() RUN 2 return early RESULT no socket
StrictMode's extra cleanup and rerun is harmless with real cleanup and fatal with a ref guard.

Don't silence exhaustive-deps

The exhaustive-deps rule ships in eslint-plugin-react-hooks, and eslint-config-next already enables it. If you configure ESLint yourself, flat config (eslint.config.js) is the default since ESLint 9:

JavaScript
// eslint.config.js
import reactHooks from "eslint-plugin-react-hooks";

export default [
  {
    plugins: { "react-hooks": reactHooks },
    rules: {
      "react-hooks/rules-of-hooks": "error",
      "react-hooks/exhaustive-deps": "warn",
    },
  },
];

Keep your TypeScript parser setup next to it if you lint .tsx. Recent plugin versions also export a flat recommended preset (the newest add React Compiler-based rules to it), but its export name has changed between releases, so check the README for your version. Older setups that still use .eslintrc take the same rules in JSON:

JSON
{
  "plugins": ["react-hooks"],
  "rules": {
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn"
  }
}

Once it's on, the tempting move is this:

TSX
import { useEffect, useState } from "react";

export function Timer() {
  const [seconds, setSeconds] = useState(0);

  useEffect(() => {
    const id = setInterval(() => {
      setSeconds(seconds + 1);
    }, 1000);
    return () => clearInterval(id);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  return <p>{seconds}s</p>;
}

The warning is gone and the stale closure is still there. I ran the rule over the broken components in this post. It flagged Panel, Orders, Timer, Editor, and the Feed effect from before items went into the array:

Text
React Hook useEffect contains a call to 'setSize'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [] as a second argument to the useEffect Hook.
The 'query' object makes the dependencies of useEffect Hook (at line 14) change on every render. Move it inside the useEffect callback. Alternatively, wrap the initialization of 'query' in its own useMemo() Hook.
React Hook useEffect has a missing dependency: 'seconds'. Either include it or remove the dependency array. You can also do a functional update 'setSeconds(s => ...)' if you only need 'seconds' in the 'setSeconds' call.
React Hook useEffect has a missing dependency: 'draft'. Either include it or remove the dependency array.
React Hook useEffect has a missing dependency: 'items'. Either include it or remove the dependency array. You can also do a functional update 'setItems(i => ...)' if you only need 'items' in the 'setItems' call.

The Editor warning has no functional-update hint because the listener reads draft instead of setting it. Adding draft to the array works but re-subscribes on every keystroke, so the ref or useEffectEvent is the real fix. Exact wording varies between plugin versions, but the advice is the same. If a value genuinely shouldn't re-trigger the effect, that's a sign the logic belongs in an event handler, a ref, or an effect event, not that the linter is wrong.

Newer React: useEffectEvent and the React Compiler

useEffectEvent

useEffectEvent gives you a function that always sees the latest props and state but isn't a dependency of the effect that calls it. It became a stable API in React 19.2. Before that it shipped only in experimental builds, under the name experimental_useEffectEvent, so check the installed react version in your lockfile before reaching for it. It replaces the ref from the editor example:

TSX
import { useEffect, useEffectEvent, useState } from "react";
import { saveDraft } from "./drafts";

export function Editor() {
  const [draft, setDraft] = useState("");

  const onSaveShortcut = useEffectEvent(() => {
    void saveDraft(draft); // always the latest draft
  });

  useEffect(() => {
    const onKeyDown = (event: KeyboardEvent) => {
      if ((event.ctrlKey || event.metaKey) && event.key === "s") {
        event.preventDefault();
        onSaveShortcut();
      }
    };
    window.addEventListener("keydown", onKeyDown);
    return () => window.removeEventListener("keydown", onKeyDown);
  }, []);

  return <textarea value={draft} onChange={(event) => setDraft(event.target.value)} />;
}

The rules: call effect events only from inside effects (including callbacks those effects set up), don't pass them to other components or hooks, and leave them out of dependency arrays. Recent versions of the lint plugin know about useEffectEvent. An older plugin will ask you to add onSaveShortcut to the array, which is your cue to upgrade the plugin along with React.

The React Compiler

The React Compiler memoizes components and hooks at build time. Objects and functions created during render keep their identity until their inputs change, which removes much of the "new object every render" family of loops without hand-written useMemo. Where an effect's correctness depends on a value's identity, though, keep an explicit useMemo or useCallback (check the compiler docs for current guidance) rather than relying on the compiler's memoization. It is stable now, but setup differs by framework and bundler, so follow the docs for your stack. It does not fix stale closures, derived state kept in effects or missing cleanups, and it skips code that breaks the Rules of React. Treat it as a safety net, not a reason to ignore the linter.

Checklist

  • Every effect has a dependency array, unless it really should run after every render and never sets state.
  • No object, array or function created during render sits in a dependency array. Build it inside the effect, depend on primitives, or memoize it.
  • State updates that depend on previous state use the functional form, such as setCount((c) => c + 1).
  • Values computable from props and state are computed during render (with useMemo if expensive), not synced through an effect.
  • Long-lived callbacks read fresh values through functional updates, a ref, or useEffectEvent.
  • Every fetching effect has an ignore flag or an AbortController in its cleanup.
  • Every timer, listener and subscription is removed in the cleanup, and the component behaves under StrictMode's double run.
  • No eslint-disable comments for exhaustive-deps. Each warning gets a real fix.
  • The Network panel is quiet when the page is idle.

Stuck on something like this?

I build and fix full-stack products for startups and indie founders. Tell me what's broken.

Get in touch