{
  "id": "react/useeffect-cleanup-return-non-function",
  "signature": "Warning: useEffect must not return anything besides a function, which is used for clean-up. You returned: undefined",
  "signature_zh": "警告：useEffect 不能返回除函数以外的任何内容，该函数用于清理。您返回了：undefined",
  "regex": "Warning: useEffect must not return anything besides a function",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The useEffect callback returns a non-function value (e.g., undefined from an async function, a Promise, or a number) instead of a cleanup function or nothing.",
  "root_cause_type": "generic",
  "root_cause_zh": "useEffect 回调返回了一个非函数值（例如来自异步函数的 undefined、Promise 或数字），而不是清理函数或什么都不返回。",
  "versions": [
    {
      "version": "react@18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "react@16.14.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Making the useEffect callback async directly (async () => { ... })",
      "why_fails": "An async function always returns a Promise, which is not a cleanup function, triggering the warning.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding a return statement that returns a string or boolean to suppress the warning",
      "why_fails": "Only a function (or nothing) is allowed; any other type will still cause the warning.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the entire useEffect in a try-catch block",
      "why_fails": "The warning is about the return type of the callback, not about errors inside it; try-catch doesn't change the return value.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define an async function inside the useEffect and call it without returning it. The useEffect callback itself should not be async.",
      "success_rate": 0.95,
      "how": "Define an async function inside the useEffect and call it without returning it. The useEffect callback itself should not be async.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If a cleanup is needed, return a function that performs the cleanup. If not, omit the return statement entirely.",
      "success_rate": 0.9,
      "how": "If a cleanup is needed, return a function that performs the cleanup. If not, omit the return statement entirely.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Define an async function inside the useEffect and call it without returning it. The useEffect callback itself should not be async.",
    "If a cleanup is needed, return a function that performs the cleanup. If not, omit the return statement entirely."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/reference/react/useEffect",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}