{"record":{"id":"66797c761507a068","repo":"reflex-dev/reflex","slug":"children-in-fn-name-must-be-annotated-as","errorCode":null,"errorMessage":"`children` in `{fn.__name__}` must be annotated as `rx.Var[rx.Component]`.","messagePattern":"`children` in `(.+?)` must be annotated as `rx\\.Var\\[rx\\.Component\\]`\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/memo.py","lineNumber":1313,"sourceCode":"                annotation = Var[Any]\n            else:\n                annotation = Var[annotation]\n            defaulted_params.append(parameter.name)\n            if is_missing and missing_params is not None:\n                missing_params.append(parameter.name)\n\n        # Children parameters by name must match the children kind exactly —\n        # otherwise we accept a value-typed `children` and emit confusing JSX.\n        if (\n            parameter.name == \"children\"\n            and not _children_annotation_is_valid(annotation)\n            and not _is_event_handler_annotation(annotation)[0]\n        ):\n            msg = (\n                f\"`children` in `{fn.__name__}` must be annotated as \"\n                \"`rx.Var[rx.Component]`.\"\n            )\n            raise TypeError(msg)\n\n        kind, kind_data = _classify_parameter(annotation, parameter.name, fn.__name__)\n        spec = _SPECS[kind]\n        spec.validate(parameter, fn.__name__, for_component)\n\n        if kind is MemoParamKind.REST:\n            rest_count += 1\n            if rest_count > 1:\n                msg = f\"`@rx.memo` only supports one `rx.RestProp` in `{fn.__name__}`.\"\n                raise TypeError(msg)\n\n        js_prop_name = format.to_camel_case(parameter.name)\n        placeholder_name = spec.placeholder_name(\n            parameter.name, js_prop_name, for_component\n        )\n\n        params.append(\n            MemoParam(","sourceCodeStart":1295,"sourceCodeEnd":1331,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/memo.py#L1295-L1331","documentation":"The reserved `children` parameter of an `@rx.memo` function must be annotated exactly as `rx.Var[rx.Component]` (a component pass-through slot). This error fires when `children` carries some other annotation that is not an event-handler annotation — such as `rx.Var[str]` or a bare type. It is raised at decoration time by `_analyze_params`.","triggerScenarios":"Declaring `def my_memo(children: rx.Var[str]) -> rx.Component` or `children: str` — the name matches the reserved slot but the annotation is neither `Var[Component]` nor an EventHandler (which `_validate_event_trigger` rejects separately).","commonSituations":"Naming a text/content string parameter `children` out of HTML habit; refactoring a component whose content prop was a string; generated code that reuses the name for a different type.","solutions":["Annotate `children` as `rx.Var[rx.Component]`","Rename the parameter to something like `text` or `content` if it is actually a string value, keeping `children` unclaimed"],"exampleFix":"# before\n@rx.memo\ndef card(children: rx.Var[str]) -> rx.Component:\n    return rx.card(children)\n\n# after\n@rx.memo\ndef card(children: rx.Var[rx.Component]) -> rx.Component:\n    return rx.card(children)","handlingStrategy":"validation","validationCode":"import typing, reflex as rx\n\ndef check_children_is_component_var(fn) -> None:\n    ch = typing.get_type_hints(fn).get(\"children\")\n    if ch is None:\n        return\n    if typing.get_origin(ch) is rx.Var and rx.Component in typing.get_args(ch):\n        return\n    raise TypeError(\"children must be annotated rx.Var[rx.Component]\")","typeGuard":"import typing, reflex as rx\n\ndef is_component_var(ann) -> bool:\n    return typing.get_origin(ann) is rx.Var and rx.Component in typing.get_args(ann)","tryCatchPattern":null,"preventionTips":["Reserve `children` for the component slot; name string props `text`/`content`","Use a shared snippet/typing alias for memo signatures to avoid annotation drift"],"tags":["reflex","rx-memo","typeerror","children","type-annotations"],"backgroundTag":"decorator-validation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}