{"record":{"id":"2e46c6d21a76bcce","repo":"emotion-js/emotion","slug":"themeprovider-please-make-your-theme-prop-a-plai","errorCode":null,"errorMessage":"[ThemeProvider] Please make your theme prop a plain object","messagePattern":"\\[ThemeProvider\\] Please make your theme prop a plain object","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react/src/theming.tsx","lineNumber":52,"sourceCode":"  if (typeof theme === 'function') {\n    const mergedTheme = theme(outerTheme)\n    if (\n      isDevelopment &&\n      (mergedTheme == null ||\n        typeof mergedTheme !== 'object' ||\n        Array.isArray(mergedTheme))\n    ) {\n      throw new Error(\n        '[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!'\n      )\n    }\n    return mergedTheme\n  }\n  if (\n    isDevelopment &&\n    (theme == null || typeof theme !== 'object' || Array.isArray(theme))\n  ) {\n    throw new Error(\n      '[ThemeProvider] Please make your theme prop a plain object'\n    )\n  }\n\n  return { ...outerTheme, ...theme }\n}\n\nlet createCacheWithTheme = /* #__PURE__ */ weakMemoize((outerTheme: Theme) => {\n  return weakMemoize((theme: Partial<Theme> | ((theme: Theme) => Theme)) => {\n    return getTheme(outerTheme, theme)\n  })\n})\n\nexport interface ThemeProviderProps {\n  theme: Partial<Theme> | ((outerTheme: Theme) => Theme)\n  children: React.ReactNode\n}\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/emotion-js/emotion/blob/b882bcba85132554992e4bd49e94c95939bbf810/packages/react/src/theming.tsx#L34-L70","documentation":"getTheme() in @emotion/react's ThemeProvider validates the theme prop itself: it must be a non-null, non-array object (or a function returning one). Passing null, undefined, a string, a number, or an array as the theme prop triggers this development-mode error. The library needs a spreadable object to merge with the outer theme.","triggerScenarios":"<ThemeProvider theme={null}>, theme={undefined}, theme={'dark'}, theme={[...]} — any non-object, non-function value for the theme prop, evaluated when isDevelopment. Also spreading an array as theme via { ...outerTheme, ...theme } is explicitly blocked.","commonSituations":"State that holds the theme initialized to null before mounting (theme={themeState}); passing a theme string like 'dark' instead of an object; mapping an array of theme tokens directly as the theme; optional chaining yielding undefined.","solutions":["Initialize theme state to an object, e.g. useState({}) instead of useState(null)","Pass theme={theme ?? {}} to guard against null/undefined","Convert string themes to objects: theme={themes[name]} where themes is a record of objects","If representing multiple themes, merge them into one object rather than passing an array"],"exampleFix":"// before\n<ThemeProvider theme={themeLoading ? null : currentTheme}>\n// after\n<ThemeProvider theme={themeLoading ? {} : currentTheme}>","handlingStrategy":"type-guard","validationCode":"if (theme == null || typeof theme !== 'object' || Array.isArray(theme)) {\n  throw new TypeError('ThemeProvider requires a plain object theme')\n}","typeGuard":"function isThemeObject(t: unknown): t is Record<string, unknown> {\n  return typeof t === 'object' && t !== null && !Array.isArray(t)\n}","tryCatchPattern":"try {\n  render(<ThemeProvider theme={theme}>{children}</ThemeProvider>)\n} catch (e) {\n  if (String(e.message).includes('plain object')) {\n    render(<ThemeProvider theme={{}}>{children}</ThemeProvider>)\n  } else throw e\n}","preventionTips":["Initialize theme state to {} rather than null","Validate external/theme-config data before passing it to ThemeProvider","Use TypeScript types (Record<string, unknown>) on the theme prop source to catch arrays/strings at compile time"],"tags":["react","theming","typeerror","development-only"],"backgroundTag":"invalid-prop-type","analyzedSha":"b882bcba85132554992e4bd49e94c95939bbf810","analyzedAt":"2026-09-02T22:27:13.739Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}