{
  "id": "react/too-many-re-renders-infinite-loop",
  "signature": "Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.",
  "signature_zh": "错误：重新渲染次数过多。React 限制了渲染次数以防止无限循环。",
  "regex": "Error: Too many re-renders. React limits the number of renders to prevent an infinite loop",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A component's state update triggers a re-render, which in turn triggers another state update synchronously (e.g., setState called directly in the render body or in an effect without proper dependencies), causing an infinite loop.",
  "root_cause_type": "generic",
  "root_cause_zh": "组件的状态更新触发了重新渲染，而重新渲染又同步触发了另一个状态更新（例如，在 render 函数体中直接调用 setState，或在依赖项不正确的 effect 中调用），导致无限循环。",
  "versions": [
    {
      "version": "react@16.8.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "react@17.0.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "react@18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "There is no configurable limit; React hardcodes the limit to prevent infinite loops. Increasing it would only delay the crash.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "useCallback does not prevent the infinite loop; it only prevents unnecessary re-creation of functions. The loop is caused by the call itself, not the function identity.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "While this may break the synchronous loop, it is a hack that leads to unpredictable behavior and does not address the root cause.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure state updates are not called directly in the render body. Move them to event handlers or useEffect with proper dependencies.",
      "success_rate": 0.9,
      "how": "Ensure state updates are not called directly in the render body. Move them to event handlers or useEffect with proper dependencies.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using useEffect, ensure the dependency array is correct and does not include variables that change on every render unnecessarily.",
      "success_rate": 0.85,
      "how": "If using useEffect, ensure the dependency array is correct and does not include variables that change on every render unnecessarily.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure state updates are not called directly in the render body. Move them to event handlers or useEffect with proper dependencies.",
    "If using useEffect, ensure the dependency array is correct and does not include variables that change on every render unnecessarily."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/learn/you-might-not-need-an-effect",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-09-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}