Missing useEffect Cleanup

useEffect with timers, listeners or subscriptions and no cleanup, in client components

warningReliabilitymissing-useeffect-cleanup

Why this matters

Without cleanup, subscriptions and timers keep running after the component unmounts. This causes memory leaks, stale state updates, and 'can't update unmounted component' errors.

Example

Flaggedcomponents/notifications.tsx
"use client";

import { useEffect } from "react";

export function Notifications() {
  useEffect(() => {
    const interval = setInterval(() => {
      fetchNotifications();
    }, 5000);
    // No cleanup: the interval outlives the component
  }, []);

  return null;
}
Fixedcomponents/notifications.tsx
"use client";

import { useEffect } from "react";

export function Notifications() {
  useEffect(() => {
    const interval = setInterval(() => {
      fetchNotifications();
    }, 5000);

    return () => clearInterval(interval);
  }, []);

  return null;
}

How to fix

Return a cleanup function from every useEffect that creates subscriptions, timers, event listeners, or WebSocket connections.

Reference

In the output
Findings carry "ruleId": "missing-useeffect-cleanup" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line missing-useeffect-cleanup
Silence a whole file
// prodlint-disable missing-useeffect-cleanup at the top of the file
How it works
Matches text patterns. Source on GitHub