{"record":{"id":"262ed1f07548d3d8","repo":"reflex-dev/reflex","slug":"compiled-app-root-must-be-a-component","errorCode":null,"errorMessage":"Compiled app root must be a Component.","messagePattern":"Compiled app root must be a Component\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"reflex/compiler/compiler.py","lineNumber":1111,"sourceCode":"            definitions are registered on ``auto_memo_components``.\n\n    Returns:\n        The app root with stateful wraps replaced by memo wrappers.\n    \"\"\"\n    hooks = CompilerHooks(plugins=(MemoizeStatefulPlugin(),))\n    page_context = PageContext(\n        name=\"app_root\",\n        route=constants.PageNames.APP_ROOT,\n        root_component=app_root,\n    )\n    compiled_root = hooks.compile_component(\n        app_root,\n        page_context=page_context,\n        compile_context=compile_context,\n    )\n    if not isinstance(compiled_root, Component):\n        msg = \"Compiled app root must be a Component.\"\n        raise TypeError(msg)\n    return compiled_root\n\n\ndef _resolve_radix_themes_plugin(\n    app: App,\n    plugins: Sequence[Plugin],\n) -> tuple[tuple[Plugin, ...], RadixThemesPlugin]:\n    \"\"\"Resolve the effective Radix Themes plugin for the active compile.\n\n    Returns:\n        The compiler plugin chain and the effective Radix Themes plugin.\n    \"\"\"\n    explicit_plugin = next(\n        (plugin for plugin in plugins if isinstance(plugin, RadixThemesPlugin)),\n        None,\n    )\n    if explicit_plugin is not None:\n        radix_plugin = explicit_plugin","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/compiler/compiler.py#L1093-L1129","documentation":"Internal compile-time invariant in _memoize_stateful_app_wraps: after compiling the app root from app wraps and page context, the result must be a Component instance. It signals that app-level wrappers (AppShell, plugins, app_wrap components) produced something that is not a Component, which would break all downstream code generation.","triggerScenarios":"An app_wrap component or plugin-registered wrapper returns a non-Component (e.g. a function or string) from its rendering hook, or custom App subclasses override _app_root in a way that returns a non-Component. Rarely hit by normal application code.","commonSituations":"Custom plugins adding app wraps incorrectly, monkeypatched or subclassed App internals after a Reflex version upgrade changed the app-wrap pipeline, or third-party libraries returning invalid wrappers.","solutions":["Audit custom app_wrap/plugin code and ensure wrappers resolve to Component instances","Wrap the wrapper's output with rx.fragment() or use into_component-compatible values","Update Reflex — internal API changes across versions commonly cause this in plugins","Report/check the plugin's compatibility with your Reflex version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin plugin versions compatible with your Reflex version","Test custom app wraps render to Component instances in unit tests","Avoid subclassing/monkeypatching App internals"],"tags":["reflex","compiler","app-wrap","internal-invariant"],"backgroundTag":"compiler-internal-invariant","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}