{"record":{"id":"4f9edbfd5ed1d294","repo":"reflex-dev/reflex","slug":"markdown-component-must-have-exactly-one-child-con","errorCode":null,"errorMessage":"Markdown component must have exactly one child containing the markdown source.","messagePattern":"Markdown component must have exactly one child containing the markdown source\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-markdown/src/reflex_components_markdown/markdown.py","lineNumber":247,"sourceCode":"        cls,\n        *children,\n        **props,\n    ) -> Component:\n        \"\"\"Create a markdown component.\n\n        Args:\n            *children: The children of the component.\n            **props: The properties of the component.\n\n        Returns:\n            The markdown component.\n\n        Raises:\n            ValueError: If the children are not valid.\n        \"\"\"\n        if len(children) != 1 or not isinstance(children[0], (str, Var)):\n            msg = \"Markdown component must have exactly one child containing the markdown source.\"\n            raise ValueError(msg)\n\n        # Update the base component map with the custom component map.\n        component_map = {**get_base_component_map(), **props.pop(\"component_map\", {})}\n\n        # Get the markdown source.\n        src = children[0]\n\n        # Dedent the source.\n        if isinstance(src, str):\n            src = textwrap.dedent(src)\n\n        # Create the component.\n        return super().create(\n            src,\n            component_map=component_map,\n            component_map_hash=cls._component_map_hash(component_map),\n            **props,\n        )","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-markdown/src/reflex_components_markdown/markdown.py#L229-L265","documentation":"rx.markdown() requires exactly one child — the markdown source — as either a Python string or a Var. Zero children, multiple children, or a non-string child (like a component) produce ValueError because the component compiles the source into react-markdown at build time.","triggerScenarios":"rx.markdown() with no args, rx.markdown('# Hi', rx.text('extra')), or rx.markdown(rx.text('# Hi')).","commonSituations":"Forgetting the source string; trying to nest components inside markdown; passing a list of blocks instead of one joined string.","solutions":["Pass exactly one string: rx.markdown('# Hello')","For dynamic content pass a single Var: rx.markdown(State.md_text)","Join multiple blocks into one string: rx.markdown('\\n\\n'.join(blocks))"],"exampleFix":"# before\nrx.markdown('# Title', rx.text('body'))\n# after\nrx.markdown('# Title\\n\\nbody')","handlingStrategy":"validation","validationCode":"assert len(children) == 1 and isinstance(children[0], (str, Var))\nrx.markdown(*children)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Join multiple text blocks into one string before rx.markdown","Never nest components inside markdown"],"tags":["reflex","markdown","children-validation"],"backgroundTag":"component-child-type-mismatch","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}