{
  "id": "react/context-value-undefined-in-provider",
  "signature": "TypeError: Cannot read properties of undefined (reading 'value') when accessing context",
  "signature_zh": "类型错误：无法读取 undefined 的属性（读取 'value'）在访问 context 时",
  "regex": "TypeError: Cannot read properties of undefined \\(reading 'value'\\)",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A component consumes a context using useContext but the corresponding Provider is missing, or the Provider does not supply a 'value' prop, resulting in undefined context value.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个组件使用 useContext 消费 context，但相应的 Provider 缺失，或者 Provider 没有提供 'value' prop，导致 context 值为 undefined。",
  "versions": [
    {
      "version": "React 18.2.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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the consumer tries to access nested properties that aren't in the default value, it still throws undefined errors.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Even if the Provider is present, importing a different context instance means the consumer doesn't see the provided value.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the component consuming the context is wrapped in the corresponding Provider component with a 'value' prop.",
      "success_rate": 0.95,
      "how": "Ensure the component consuming the context is wrapped in the corresponding Provider component with a 'value' prop.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a null/undefined check before accessing properties on the context value to provide a fallback UI or default value.",
      "success_rate": 0.85,
      "how": "Add a null/undefined check before accessing properties on the context value to provide a fallback UI or default value.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure the component consuming the context is wrapped in the corresponding Provider component with a 'value' prop.",
    "Add a null/undefined check before accessing properties on the context value to provide a fallback UI or default value."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/reference/react/useContext#providing-context",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.94,
  "resolvable": "true",
  "first_seen": "2023-05-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}