reflex-dev/reflex · error · TypeError
`children` in `{fn_name}` cannot be `rx.RestProp`.
Error message
`children` in `{fn_name}` cannot be `rx.RestProp`. What it means
An `@rx.memo` function declared a parameter named `children` annotated as `rx.RestProp` (the `...` rest-props placeholder). The `children` slot is special — it maps to React's children — and cannot double as the catch-all rest-props bag. Reflex raises this TypeError during parameter validation at decoration time.
Source
Thrown at packages/reflex-base/src/reflex_base/components/memo.py:944
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}`."
)
raise TypeError(msg)
if parameter.name == "children":
msg = (
f"`children` in `{fn_name}` cannot be an `rx.EventHandler`; "
"use `rx.Var[rx.Component]`."
)
raise TypeError(msg)
if parameter.default is not inspect.Parameter.empty:View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Rename the RestProp parameter to something else (e.g. `rest: rx.RestProp` or use bare `...` on an unnamed slot) so `children` stays free
- Declare `children: rx.Var[rx.Component]` separately if you need the children slot, and use a differently-named `rx.RestProp` for extra props
Example fix
// before
@rx.memo
def panel(children: rx.RestProp) -> rx.Component:
...
// after
@rx.memo
def panel(children: rx.Var[rx.Component], rest: rx.RestProp) -> rx.Component:
... Defensive patterns
Strategy: type-guard
Validate before calling
import inspect, reflex as rx
def check_no_rest_children(fn) -> None:
for p in inspect.signature(fn).parameters.values():
if p.name == "children" and p.annotation is rx.RestProp:
raise TypeError("children cannot be rx.RestProp; rename the rest param") Type guard
import inspect, reflex as rx
def is_valid_rest_usage(fn) -> bool:
return all(
not (p.name == "children" and p.annotation is rx.RestProp)
for p in inspect.signature(fn).parameters.values()
) Prevention
- Never name a RestProp parameter `children`
- Use conventional names like `rest` or `props` for rest-props placeholders
- Keep `children: rx.Var[rx.Component]` as a separate explicit parameter when both are needed
When it happens
Trigger: Writing `def my_memo(children: rx.RestProp)` (or `children: ...` where RestProp is the annotation) so `_validate_rest` sees `parameter.name == "children"` and raises.
Common situations: Trying to forward all props including children with a single rest parameter and naming it `children`; auto-generating memo signatures from `**kwargs` and accidentally colliding with the reserved name.
Related errors
- `rx.Var[rx.Component]` parameters in `{fn_name}` must be nam
- `children` in `{fn_name}` cannot be an `rx.EventHandler`; us
- `children` in `{fn.__name__}` must be annotated as `rx.Var[r
- `@rx.memo` only supports one `rx.RestProp` in `{fn.__name__}
- Var-returning `@rx.memo` `{func_name}` cannot depend on embe
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/b7caf0275c6dc41e.
Report an issue: GitHub.