reflex-dev/reflex · error · TypeError

`@rx.memo` only supports one `rx.RestProp` in `{fn.__name__}

Error message

`@rx.memo` only supports one `rx.RestProp` in `{fn.__name__}`.

What it means

An `@rx.memo` function declared more than one `rx.RestProp` parameter. The rest-props placeholder captures all remaining props as a single catch-all, so a second one is ambiguous and impossible to compile. Reflex raises this TypeError at decoration time in `_analyze_params` when `rest_count` exceeds 1.

Source

Thrown at packages/reflex-base/src/reflex_base/components/memo.py:1323

            parameter.name == "children"
            and not _children_annotation_is_valid(annotation)
            and not _is_event_handler_annotation(annotation)[0]
        ):
            msg = (
                f"`children` in `{fn.__name__}` must be annotated as "
                "`rx.Var[rx.Component]`."
            )
            raise TypeError(msg)

        kind, kind_data = _classify_parameter(annotation, parameter.name, fn.__name__)
        spec = _SPECS[kind]
        spec.validate(parameter, fn.__name__, for_component)

        if kind is MemoParamKind.REST:
            rest_count += 1
            if rest_count > 1:
                msg = f"`@rx.memo` only supports one `rx.RestProp` in `{fn.__name__}`."
                raise TypeError(msg)

        js_prop_name = format.to_camel_case(parameter.name)
        placeholder_name = spec.placeholder_name(
            parameter.name, js_prop_name, for_component
        )

        params.append(
            MemoParam(
                name=parameter.name,
                kind=kind,
                kind_data=kind_data,
                annotation=annotation,
                parameter_kind=parameter.kind,
                default=parameter.default,
                js_prop_name=js_prop_name,
                placeholder_name=placeholder_name,
            )
        )

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Keep exactly one `rx.RestProp` parameter and delete the duplicates
  2. If you need distinct groups of props, give each parameter an explicit `rx.Var[...]` annotation instead of extra rest placeholders

Example fix

# before
@rx.memo
def panel(children: rx.Var[rx.Component], left: rx.RestProp, right: rx.RestProp) -> rx.Component:
    ...

# after
@rx.memo
def panel(children: rx.Var[rx.Component], rest: rx.RestProp) -> rx.Component:
    ...
Defensive patterns

Strategy: validation

Validate before calling

import inspect, reflex as rx

def check_single_rest_prop(fn) -> None:
    rests = [p for p in inspect.signature(fn).parameters.values() if p.annotation is rx.RestProp]
    if len(rests) > 1:
        raise TypeError("only one rx.RestProp parameter is allowed per @rx.memo")

Type guard

import inspect, reflex as rx

def has_single_rest_prop(fn) -> bool:
    return sum(
        1 for p in inspect.signature(fn).parameters.values() if p.annotation is rx.RestProp
    ) <= 1

Prevention

When it happens

Trigger: Declaring two parameters annotated `rx.RestProp` (or `...`), e.g. `def my_memo(a: rx.RestProp, b: rx.RestProp) -> rx.Component`, so `rest_count` increments past 1.

Common situations: Copy-pasting a rest-props parameter and forgetting to delete the original; assuming multiple rest props partition props by name; auto-generating signatures that emit a rest placeholder per section.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/f685ea5cfb3072e4. Report an issue: GitHub.