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 FragmentView on GitHub (pinned to 45b8ed5ab7)
Solutions
- Wrap raw text in a component: `card(rx.text("some title"), title="x")`.
- Unpack lists of children: `card(*children)` where each element is a component.
- 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
- Wrap strings/numbers in rx.text/rx.heading before passing positionally.
- Unpack component lists with * instead of passing the list itself.
- Pass data values as keyword rx.Var props, not as positional children.
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
- `{definition.python_name}` only accepts children positionall
- `rx.Var[rx.Component]` parameters in `{fn_name}` must be nam
- `children` in `{fn_name}` cannot be `rx.RestProp`.
- `children` in `{fn_name}` cannot be an `rx.EventHandler`; us
- `children` in `{fn.__name__}` must be annotated as `rx.Var[r
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/bf17e2afe379f0e8.
Report an issue: GitHub.