reflex-dev/reflex · error · TypeError

`rx.Var[rx.Component]` parameters in `{fn_name}` must be nam

Error message

`rx.Var[rx.Component]` parameters in `{fn_name}` must be named `children`.

What it means

In an `@rx.memo` function, a parameter annotated as `rx.Var[rx.Component]` (the special pass-through slot for child components) must be named `children`. Reflex reserves that exact name so the compiler can map the prop to the React children slot. Any other name triggers this TypeError at decoration time.

Source

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

def _classify_event_trigger(annotation: Any, name: str) -> tuple[bool, Any]:
    return _is_event_handler_annotation(annotation)


def _validate_noop(
    parameter: inspect.Parameter, fn_name: str, for_component: bool
) -> None:
    pass


def _validate_children(
    parameter: inspect.Parameter, fn_name: str, for_component: bool
) -> None:
    if parameter.name != "children":
        msg = (
            f"`rx.Var[rx.Component]` parameters in `{fn_name}` must be named "
            "`children`."
        )
        raise TypeError(msg)


def _validate_rest(
    parameter: inspect.Parameter, fn_name: str, for_component: bool
) -> None:
    if parameter.name == "children":
        msg = f"`children` in `{fn_name}` cannot be `rx.RestProp`."
        raise TypeError(msg)


def _validate_event_trigger(
    parameter: inspect.Parameter, fn_name: str, for_component: bool
) -> None:
    if not for_component:
        msg = (
            f"`rx.EventHandler` parameters are only supported on component-"
            f"returning memos. Got `{parameter.name}` in `{fn_name}`."
        )

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Rename the `rx.Var[rx.Component]` parameter to `children`
  2. If you genuinely need multiple component slots, use `rx.Var[list[rx.Component]]` with descriptive names or pass values through state instead

Example fix

// before
@rx.memo
def card(body: rx.Var[rx.Component]) -> rx.Component:
    return rx.card(body)

// after
@rx.memo
def card(children: rx.Var[rx.Component]) -> rx.Component:
    return rx.card(children)
Defensive patterns

Strategy: validation

Validate before calling

import inspect, typing, reflex as rx

def validate_memo_signature(fn) -> None:
    hints = typing.get_type_hints(fn)
    for name, ann in hints.items():
        if name == "children":
            continue
        if rx.Component in typing.get_args(ann):
            raise TypeError(f"rename param {name!r}: rx.Var[rx.Component] params must be named 'children'")

Type guard

import typing, reflex as rx

def has_well_named_children(fn) -> bool:
    hints = typing.get_type_hints(fn)
    return all(
        name == "children"
        for name, ann in hints.items()
        if rx.Component in typing.get_args(ann) and typing.get_origin(ann) is rx.Var
    )

Prevention

When it happens

Trigger: Declaring a memo like `def my_memo(stuff: rx.Var[rx.Component])` — i.e. a parameter annotated `rx.Var[rx.Component]` whose name is not `children` — while `@rx.memo` validates parameters via `_validate_children`.

Common situations: Developers naming the child slot `content`, `items`, or `slot` out of habit; refactoring a wrapper component and renaming the children parameter; copy-pasting a component signature into a memo.

Related errors


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