reflex-dev/reflex · error · TypeError

`{definition.python_name}` only accepts positional children

Error message

`{definition.python_name}` only accepts positional children that are `rx.Component` or `rx.Var[rx.Component]`.

What it means

Positional arguments to a memo are treated as children, and each child must be an `rx.Component` or `rx.Var[rx.Component]`. Passing raw strings, numbers, lists, or other non-component values positionally raises this TypeError.

Source

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

        )
        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)
    ]
    explicit_values = {}
    remaining_props = kwargs.copy()
    for param in explicit_params:
        if param.name in remaining_props:
            explicit_values[param.name] = remaining_props.pop(param.name)
        elif param.default is not inspect.Parameter.empty:
            explicit_values[param.name] = param.default
        else:
            msg = f"`{definition.python_name}` is missing required prop `{param.name}`."
            raise TypeError(msg)

    # Reject unknown props unless a rest prop is declared.
    if remaining_props and rest_param is None:
        unexpected_prop = next(iter(remaining_props))
        msg = (
            f"`{definition.python_name}` does not accept prop `{unexpected_prop}`. "
            "Only declared props may be passed when no `rx.RestProp` is present."
        )
        raise TypeError(msg)

    # Return ordered explicit args when no packed props object is needed.
    if children_param is None and rest_param is None:
        return tuple(explicit_values[param.name] for param in explicit_params)

    # Build the props object passed to the imported FunctionVar.
    children_value: Any | None = None
    if children_param is not None:
        from reflex_components_core.base.fragment import Fragment

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Wrap raw text in a component: `card(rx.text("some title"), title="x")`.
  2. Unpack lists of children: `card(*children)` where each element is a component.
  3. Pass data-like values as keyword props with `rx.Var` annotations rather than as positional children.

Example fix

# before
card("some title", title="x")

# after
card(rx.text("some title"), title="x")
Defensive patterns

Strategy: type-guard

Validate before calling

import reflex as rx

def valid_children(args) -> bool:
    return all(isinstance(c, (rx.Component, rx.Var)) for c in args)

Type guard

import reflex as rx

def is_component_child(value) -> bool:
    return isinstance(value, (rx.Component, rx.Var))

Prevention

When it happens

Trigger: Calling `card("some title", title="x")` — the positional string is not an `rx.Component`. Lists of components, plain dicts, or Python primitives passed positionally also trigger it.

Common situations: Assuming memo children work like `rx.box("text")` (which auto-wraps strings); passing a `list` of children instead of unpacking them; passing state values or computed Python objects positionally instead of as annotated `rx.Var` props.

Related errors


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