{"record":{"id":"81656c36f469bd4a","repo":"reflex-dev/reflex","slug":"rx-memo-only-supports-wrapper-on-component-r","errorCode":null,"errorMessage":"`@rx.memo` only supports `wrapper=` on component-returning memos; `{fn.__name__}` returns `rx.Var[...]`, which compiles to a plain function.","messagePattern":"`@rx\\.memo` only supports `wrapper=` on component-returning memos; `(.+?)` returns `rx\\.Var\\[\\.\\.\\.\\]`, which compiles to a plain function\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/memo.py","lineNumber":2065,"sourceCode":"    missing_return = return_annotation is inspect.Signature.empty\n    if missing_return:\n        return_annotation = Component\n        hints[\"return\"] = Component\n\n    is_component = _is_component_annotation(return_annotation)\n    if not is_component and not _is_var_annotation(return_annotation):\n        msg = (\n            f\"`@rx.memo` on `{fn.__name__}` must return `rx.Component` or \"\n            f\"`rx.Var[...]`, got `{return_annotation}`.\"\n        )\n        raise TypeError(msg)\n    if not is_component and wrapper is not DEFAULT_MEMO_WRAPPER:\n        msg = (\n            \"`@rx.memo` only supports `wrapper=` on component-returning memos; \"\n            f\"`{fn.__name__}` returns `rx.Var[...]`, which compiles to a plain \"\n            \"function.\"\n        )\n        raise TypeError(msg)\n\n    defaulted_params: list[str] = []\n    missing_params: list[str] = []\n    params = _analyze_params(\n        fn,\n        for_component=is_component,\n        hints=hints,\n        defaulted_params=defaulted_params,\n        missing_params=missing_params,\n    )\n\n    source_module = memo_paths.capture_source_module(fn)\n\n    if missing_return or defaulted_params:\n        _warn_missing_annotations(fn.__name__, missing_return, defaulted_params)\n\n    # Build the definition with a deferred body: the decorated function runs on\n    # first read of ``.component`` / ``.function`` (see ``_LazyBody``), not here,","sourceCodeStart":2047,"sourceCodeEnd":2083,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/memo.py#L2047-L2083","documentation":"`@rx.memo(wrapper=...)` is only supported for memos that return `rx.Component`. Memos annotated to return `rx.Var[...]` compile to plain functions and cannot take a wrapper component.","triggerScenarios":"`@rx.memo(wrapper=SomeWrapper)` on `def total() -> rx.Var[int]:` — a value-returning memo with a wrapper argument.","commonSituations":"Copying a wrapper-using component memo pattern onto a computed-value memo.","solutions":["Drop the `wrapper=` argument for Var-returning memos","Or change the memo to return a component if you need wrapper behavior"],"exampleFix":"// before\n@rx.memo(wrapper=rx.fragment)\ndef total() -> rx.Var[int]: ...\n\n// after\n@rx.memo\ndef total() -> rx.Var[int]: ...","handlingStrategy":"type-guard","validationCode":"import typing, reflex as rx\n\ndef can_use_wrapper(fn) -> bool:\n    ret = typing.get_type_hints(fn).get(\"return\")\n    return isinstance(ret, type) and issubclass(ret, rx.Component)","typeGuard":"def is_component_memo(fn) -> bool:\n    import typing, reflex as rx\n    ret = typing.get_type_hints(fn).get(\"return\")\n    return isinstance(ret, type) and issubclass(ret, rx.Component)","tryCatchPattern":null,"preventionTips":["Only pass wrapper= to memos annotated `-> rx.Component`","Keep value memos (rx.Var[...]) wrapper-free"],"tags":["reflex","memo","wrapper","unsupported-argument"],"backgroundTag":"unsupported-argument-combination","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}