{"record":{"id":"c1404a706e15abd4","repo":"facebook/react","slug":"108","errorCode":"108","errorMessage":"${getComponentNameFromType(type) || 'Unknown'}.getChildContext(): key \"${contextKey}\" is not defined in childContextTypes.","messagePattern":"(.+?)\\.getChildContext\\(\\): key \"(.+?)\" is not defined in childContextTypes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server/src/ReactFizzLegacyContext.js","lineNumber":74,"sourceCode":"\n        if (!warnedAboutMissingGetChildContext[componentName]) {\n          warnedAboutMissingGetChildContext[componentName] = true;\n          console.error(\n            '%s.childContextTypes is specified but there is no getChildContext() method ' +\n              'on the instance. You can either define getChildContext() on %s or remove ' +\n              'childContextTypes from it.',\n            componentName,\n            componentName,\n          );\n        }\n      }\n      return parentContext;\n    }\n\n    const childContext = instance.getChildContext();\n    for (const contextKey in childContext) {\n      if (!(contextKey in childContextTypes)) {\n        throw new Error(\n          `${\n            getComponentNameFromType(type) || 'Unknown'\n          }.getChildContext(): key \"${contextKey}\" is not defined in childContextTypes.`,\n        );\n      }\n    }\n    return {...parentContext, ...childContext};\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":84,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server/src/ReactFizzLegacyContext.js#L56-L84","documentation":"Legacy (pre-16.3) class context requires every key returned by instance.getChildContext() to be declared in the component's static childContextTypes. During SSR, Fizz iterates the returned object and throws error code 108 for the first key missing from childContextTypes.","triggerScenarios":"A class component's getChildContext() returns a key that the static childContextTypes declaration does not list; adding or renaming context keys without updating the static declaration.","commonSituations":"Maintaining pre-16.3 class-based context code; partial migrations where childContextTypes was trimmed; copy-pasting legacy provider patterns.","solutions":["Declare the missing key in static childContextTypes = {key: PropTypes.string.isRequired}","Prefer the modern createContext()/useContext API over legacy child context","If the key is obsolete, stop returning it from getChildContext()"],"exampleFix":"// before\nclass Provider extends React.Component {\n  getChildContext() {\n    return {theme: 'dark', locale: 'en'}; // locale missing below -> throws\n  }\n}\nProvider.childContextTypes = {theme: PropTypes.string};\n\n// after\nProvider.childContextTypes = {\n  theme: PropTypes.string,\n  locale: PropTypes.string,\n};","handlingStrategy":"validation","validationCode":"// dev-only check around legacy providers\nconst ctx = instance.getChildContext();\nfor (const key of Object.keys(ctx)) {\n  if (!(key in Component.childContextTypes)) {\n    console.error(`getChildContext key '${key}' is missing from childContextTypes`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare every key in childContextTypes exactly as returned by getChildContext","Migrate legacy providers and consumers to createContext/useContext","Add a dev-time assertion that walks getChildContext output before shipping"],"tags":["legacy-context","child-context-types","class-components","ssr"],"backgroundTag":"legacy-childcontext-validation","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}