{
  "id": "react/usecontext-outside-provider-null",
  "signature": "TypeError: Cannot read properties of null (reading 'Provider')",
  "signature_zh": "类型错误：无法读取 null 的属性（读取 'Provider'）",
  "regex": "Cannot read properties of null \\(reading 'Provider'\\)",
  "domain": "react",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to destructure or access a property like Provider from a context object that is null, typically because the context was not created with createContext() or was imported incorrectly.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试从 null 的 context 对象中解构或访问 Provider 属性，通常是因为 context 未使用 createContext() 创建或导入不正确。",
  "versions": [
    {
      "version": "React 16.8+",
      "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": "Adding a null check before accessing Provider",
      "why_fails": "This masks the error but the context is still null, so the Provider component will be undefined and React will throw another error.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a default value for the context",
      "why_fails": "Default value only applies when consuming context with useContext, not when accessing Provider or Consumer from the context object itself.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping everything in a try-catch",
      "why_fails": "The error occurs at render time; try-catch won't catch it unless you use an error boundary, and it doesn't solve the root cause.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure createContext is called and exported correctly. Example: export const MyContext = createContext(); then import { MyContext } from './context'; not import MyContext from './context'; if it's a named export.",
      "success_rate": 0.9,
      "how": "Ensure createContext is called and exported correctly. Example: export const MyContext = createContext(); then import { MyContext } from './context'; not import MyContext from './context'; if it's a named export.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using default export, change to: import MyContext from './context'; then use MyContext.Provider. Check that the export statement in the context file matches the import.",
      "success_rate": 0.85,
      "how": "If using default export, change to: import MyContext from './context'; then use MyContext.Provider. Check that the export statement in the context file matches the import.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure createContext is called and exported correctly. Example: export const MyContext = createContext(); then import { MyContext } from './context'; not import MyContext from './context'; if it's a named export.",
    "If using default export, change to: import MyContext from './context'; then use MyContext.Provider. Check that the export statement in the context file matches the import."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://reactjs.org/docs/context.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.8,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}