{
  "id": "react/useEffect-return-not-function",
  "signature": "An effect function must not return anything besides a function, which is used for clean-up. You returned: undefined",
  "signature_zh": "effect 函数不能返回除函数之外的任何内容，该函数用于清理。你返回了：undefined",
  "regex": "An effect function must not return anything besides a function, which is used for clean-up",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The useEffect callback returns a value that is not a function or undefined, violating React's contract for effect cleanup.",
  "root_cause_type": "generic",
  "root_cause_zh": "useEffect 回调返回了一个不是函数或 undefined 的值，违反了 React 对 effect 清理的约定。",
  "versions": [
    {
      "version": "React 16.8+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "React 17.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "React 18.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Returning null or false from useEffect to suppress the warning.",
      "why_fails": "React expects either undefined (no cleanup) or a function; returning null/false triggers the same error because they are not functions.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the return statement entirely even when cleanup is needed.",
      "why_fails": "Without a cleanup function, subscriptions, timers, or event listeners may persist, causing memory leaks or duplicate effects.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the return value in an async function (e.g., useEffect(async () => { ... return someValue; })).",
      "why_fails": "Async functions always return a Promise, which is not a function for cleanup; React will throw the same error.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure useEffect callback returns either nothing (undefined) or a cleanup function. Example: useEffect(() => { const timer = setInterval(...); return () => clearInterval(timer); }, []);",
      "success_rate": 0.95,
      "how": "Ensure useEffect callback returns either nothing (undefined) or a cleanup function. Example: useEffect(() => { const timer = setInterval(...); return () => clearInterval(timer); }, []);",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need async logic, define the async function inside the effect and call it, but do not return the promise. Example: useEffect(() => { const fetchData = async () => { ... }; fetchData(); }, []);",
      "success_rate": 0.9,
      "how": "If you need async logic, define the async function inside the effect and call it, but do not return the promise. Example: useEffect(() => { const fetchData = async () => { ... }; fetchData(); }, []);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保 useEffect 回调不返回任何内容（undefined）或返回一个清理函数。示例：useEffect(() => { const timer = setInterval(...); return () => clearInterval(timer); }, []);",
    "如果需要异步逻辑，在 effect 内部定义异步函数并调用它，但不要返回 promise。示例：useEffect(() => { const fetchData = async () => { ... }; fetchData(); }, []);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/reference/react/useEffect#return",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}