{
  "id": "react/context-value-undefined-reducer",
  "signature": "Error: The context value for 'MyContext' is undefined. Did you forget to wrap your component in a Provider with a value?",
  "signature_zh": "错误：'MyContext' 的上下文值未定义。您是否忘记使用带有值的 Provider 包装组件？",
  "regex": "Error: The context value for '[A-Za-z]+' is undefined\\. Did you forget to wrap your component in a Provider with a value\\?",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A component tries to consume a context value that is undefined because the corresponding Provider is missing or does not provide a value prop.",
  "root_cause_type": "generic",
  "root_cause_zh": "组件尝试使用未定义的上下文值，因为对应的 Provider 缺失或未提供 value 属性。",
  "versions": [
    {
      "version": "React 18.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "React 19.0.0-beta.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The default value is used only if there is no Provider; if a Provider exists without a value, it still passes undefined.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This causes a mismatch between the context used in the Provider and the consumer.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Without a value prop, the Provider passes undefined, which is still undefined.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the component is wrapped in the correct Provider with a value prop. Example: <MyContext.Provider value={someValue}><ChildComponent /></MyContext.Provider>",
      "success_rate": 0.95,
      "how": "Ensure the component is wrapped in the correct Provider with a value prop. Example: <MyContext.Provider value={someValue}><ChildComponent /></MyContext.Provider>",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check the context creation file to ensure the context is exported and imported correctly. Use named exports to avoid confusion.",
      "success_rate": 0.85,
      "how": "Check the context creation file to ensure the context is exported and imported correctly. Use named exports to avoid confusion.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using useReducer, pass the dispatch as part of the context value: const [state, dispatch] = useReducer(reducer, initialState); <MyContext.Provider value={{ state, dispatch }}>...</MyContext.Provider>",
      "success_rate": 0.9,
      "how": "If using useReducer, pass the dispatch as part of the context value: const [state, dispatch] = useReducer(reducer, initialState); <MyContext.Provider value={{ state, dispatch }}>...</MyContext.Provider>",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure the component is wrapped in the correct Provider with a value prop. Example: <MyContext.Provider value={someValue}><ChildComponent /></MyContext.Provider>",
    "Check the context creation file to ensure the context is exported and imported correctly. Use named exports to avoid confusion.",
    "If using useReducer, pass the dispatch as part of the context value: const [state, dispatch] = useReducer(reducer, initialState); <MyContext.Provider value={{ state, dispatch }}>...</MyContext.Provider>"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://react.dev/reference/react/createContext#providing-context",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}