{"record":{"id":"a433d125056bf059","repo":"reflex-dev/reflex","slug":"rx-var-rx-component-parameters-in-fn-name-m","errorCode":null,"errorMessage":"`rx.Var[rx.Component]` parameters in `{fn_name}` must be named `children`.","messagePattern":"`rx\\.Var\\[rx\\.Component\\]` parameters in `(.+?)` must be named `children`\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/memo.py","lineNumber":936,"sourceCode":"def _classify_event_trigger(annotation: Any, name: str) -> tuple[bool, Any]:\n    return _is_event_handler_annotation(annotation)\n\n\ndef _validate_noop(\n    parameter: inspect.Parameter, fn_name: str, for_component: bool\n) -> None:\n    pass\n\n\ndef _validate_children(\n    parameter: inspect.Parameter, fn_name: str, for_component: bool\n) -> None:\n    if parameter.name != \"children\":\n        msg = (\n            f\"`rx.Var[rx.Component]` parameters in `{fn_name}` must be named \"\n            \"`children`.\"\n        )\n        raise TypeError(msg)\n\n\ndef _validate_rest(\n    parameter: inspect.Parameter, fn_name: str, for_component: bool\n) -> None:\n    if parameter.name == \"children\":\n        msg = f\"`children` in `{fn_name}` cannot be `rx.RestProp`.\"\n        raise TypeError(msg)\n\n\ndef _validate_event_trigger(\n    parameter: inspect.Parameter, fn_name: str, for_component: bool\n) -> None:\n    if not for_component:\n        msg = (\n            f\"`rx.EventHandler` parameters are only supported on component-\"\n            f\"returning memos. Got `{parameter.name}` in `{fn_name}`.\"\n        )","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/memo.py#L918-L954","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["Rename the `rx.Var[rx.Component]` parameter to `children`","If you genuinely need multiple component slots, use `rx.Var[list[rx.Component]]` with descriptive names or pass values through state instead"],"exampleFix":"// before\n@rx.memo\ndef card(body: rx.Var[rx.Component]) -> rx.Component:\n    return rx.card(body)\n\n// after\n@rx.memo\ndef card(children: rx.Var[rx.Component]) -> rx.Component:\n    return rx.card(children)","handlingStrategy":"validation","validationCode":"import inspect, typing, reflex as rx\n\ndef validate_memo_signature(fn) -> None:\n    hints = typing.get_type_hints(fn)\n    for name, ann in hints.items():\n        if name == \"children\":\n            continue\n        if rx.Component in typing.get_args(ann):\n            raise TypeError(f\"rename param {name!r}: rx.Var[rx.Component] params must be named 'children'\")","typeGuard":"import typing, reflex as rx\n\ndef has_well_named_children(fn) -> bool:\n    hints = typing.get_type_hints(fn)\n    return all(\n        name == \"children\"\n        for name, ann in hints.items()\n        if rx.Component in typing.get_args(ann) and typing.get_origin(ann) is rx.Var\n    )","tryCatchPattern":null,"preventionTips":["Reserve the name `children` exclusively for the rx.Var[rx.Component] slot","Name auxiliary component-list params differently, e.g. `items: rx.Var[list[rx.Component]]`","Lint memo signatures in CI by importing the module once (errors raise at decoration time)"],"tags":["reflex","rx-memo","typeerror","children","naming"],"backgroundTag":"decorator-validation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}