{
  "id": "react/forwardref-params-error",
  "signature": "Warning: forwardRef render functions accept exactly two parameters: props and ref. Did you mean to use React.forwardRef?",
  "signature_zh": "警告：forwardRef 渲染函数只接受两个参数：props 和 ref。您是否打算使用 React.forwardRef？",
  "regex": "forwardRef render functions accept exactly two parameters",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A function component is defined with more than two parameters (e.g., props, ref, extraParam) while using forwardRef, but forwardRef expects exactly two parameters.",
  "root_cause_type": "generic",
  "root_cause_zh": "函数组件在使用 forwardRef 时定义了超过两个参数（例如 props、ref、extraParam），但 forwardRef 期望正好两个参数。",
  "versions": [
    {
      "version": "react@18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "react-dom@18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Ignoring the warning and passing extra parameters anyway",
      "why_fails": "React will ignore the extra parameters, and the component may not behave as expected.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a class component instead of a function component with forwardRef",
      "why_fails": "Class components handle refs differently; you may lose the benefits of forwardRef or cause other errors.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the component in another HOC that passes extra props",
      "why_fails": "This adds complexity without fixing the root cause; the extra parameter is still passed to the forwardRef function.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove the extra parameter and use props object directly: `const MyComponent = React.forwardRef((props, ref) => { const { extraParam, ...rest } = props; return <div ref={ref}>...</div>; });`",
      "success_rate": 0.95,
      "how": "Remove the extra parameter and use props object directly: `const MyComponent = React.forwardRef((props, ref) => { const { extraParam, ...rest } = props; return <div ref={ref}>...</div>; });`",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you need additional parameters, pass them via props: `<MyComponent extraParam={value} />` and access `props.extraParam` inside the forwardRef function.",
      "success_rate": 0.9,
      "how": "If you need additional parameters, pass them via props: `<MyComponent extraParam={value} />` and access `props.extraParam` inside the forwardRef function.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove the extra parameter and use props object directly: `const MyComponent = React.forwardRef((props, ref) => { const { extraParam, ...rest } = props; return <div ref={ref}>...</div>; });`",
    "If you need additional parameters, pass them via props: `<MyComponent extraParam={value} />` and access `props.extraParam` inside the forwardRef function."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://reactjs.org/docs/forwarding-refs.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-07-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}