{
  "id": "react/typeerror-cannot-read-properties-of-undefined-reading-params",
  "signature": "TypeError: Cannot read properties of undefined (reading 'params')",
  "signature_zh": "类型错误：无法读取 undefined 的属性（读取 'params'）",
  "regex": "TypeError: Cannot read properties of undefined \\(reading 'params'\\)",
  "domain": "react",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Code attempts to access route parameters (e.g., `useParams()` or `match.params`) but the component is not rendered within a Route context, or the route path does not define the expected parameter.",
  "root_cause_type": "generic",
  "root_cause_zh": "代码尝试访问路由参数（例如 `useParams()` 或 `match.params`），但组件未在 Route 上下文内渲染，或路由路径未定义预期的参数。",
  "versions": [
    {
      "version": "React Router 6.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "React Router 5.3.4",
      "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": "The underlying issue (component outside Router) remains, leading to other bugs.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Both exports exist, but the context provider difference is the real issue.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the component is wrapped in a Route: `<Route path=\"/user/:id\" element={<UserComponent />} />` and access params via `useParams()` hook inside UserComponent.",
      "success_rate": 0.9,
      "how": "Ensure the component is wrapped in a Route: `<Route path=\"/user/:id\" element={<UserComponent />} />` and access params via `useParams()` hook inside UserComponent.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using class component, use `withRouter` HOC (React Router v5) or wrap with `useParams` in a function component and pass as props.",
      "success_rate": 0.85,
      "how": "If using class component, use `withRouter` HOC (React Router v5) or wrap with `useParams` in a function component and pass as props.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check that the route path includes the parameter (e.g., `/user/:id`) and the URL actually matches.",
      "success_rate": 0.8,
      "how": "Check that the route path includes the parameter (e.g., `/user/:id`) and the URL actually matches.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure the component is wrapped in a Route: `<Route path=\"/user/:id\" element={<UserComponent />} />` and access params via `useParams()` hook inside UserComponent.",
    "If using class component, use `withRouter` HOC (React Router v5) or wrap with `useParams` in a function component and pass as props.",
    "Check that the route path includes the parameter (e.g., `/user/:id`) and the URL actually matches."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://reactrouter.com/en/main/hooks/use-params",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-12-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}