reflex-dev/reflex · error · TypeError

`{definition.python_name}` captures rest props from extra ke

Error message

`{definition.python_name}` captures rest props from extra keyword arguments. Do not pass `{rest_param.name}=` directly.

What it means

A memo that declares an `rx.RestProp` parameter automatically collects all extra keyword arguments as rest props. Passing that rest-prop parameter by its own name (e.g. `extra=...`) is rejected because it would be ambiguous with the collected rest props.

Source

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

        The ordered arguments for the imported FunctionVar.

    Raises:
        TypeError: If the provided arguments are invalid.
    """
    children_param = _get_children_param(definition.params)
    rest_param = _get_rest_param(definition.params)

    # Validate positional children usage and reserved keywords.
    if "children" in kwargs:
        msg = f"`{definition.python_name}` only accepts children positionally."
        raise TypeError(msg)

    if rest_param is not None and rest_param.name in kwargs:
        msg = (
            f"`{definition.python_name}` captures rest props from extra keyword "
            f"arguments. Do not pass `{rest_param.name}=` directly."
        )
        raise TypeError(msg)

    if args and children_param is None:
        msg = f"`{definition.python_name}` only accepts keyword props."
        raise TypeError(msg)

    if any(not _is_component_child(child) for child in args):
        msg = (
            f"`{definition.python_name}` only accepts positional children that are "
            "`rx.Component` or `rx.Var[rx.Component]`."
        )
        raise TypeError(msg)

    # Bind declared props before collecting any rest props.
    explicit_params = [
        param
        for param in definition.params
        if param.kind not in (MemoParamKind.REST, MemoParamKind.CHILDREN)
    ]

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Pass the extra props as individual keyword arguments and let the RestProp collect them: `card(title="x", a=1)`.
  2. Rename the rest parameter to something you won't accidentally pass, by convention something like `rest_props: rx.RestProp`.

Example fix

# before
@rx.memo
def card(title: rx.Var[str], extra: rx.RestProp): ...

card(title="x", extra={"a": 1})

# after
card(title="x", a=1)
Defensive patterns

Strategy: validation

Validate before calling

def without_rest_key(props: dict, rest_name: str) -> dict:
    return {k: v for k, v in props.items() if k != rest_name}

Prevention

When it happens

Trigger: Calling `@rx.memo def card(title: rx.Var[str], extra: rx.RestProp)` as `card(title="x", extra={"a": 1})` — passing the parameter named `extra` directly by keyword raises the error.

Common situations: Naming a RestProp parameter something natural like `props` or `extra` and then instinctively passing `props=...` at the call site; treating the rest prop like an ordinary declared prop; IDE autocompletion inserting the parameter name.

Related errors


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