reflex-dev/reflex · error · ValueError
Markdown component must have exactly one child containing…
Error message
Markdown component must have exactly one child containing the markdown source.
What it means
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.
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))
Example fix
# before
rx.markdown('# Title', rx.text('body'))
# after
rx.markdown('# Title\n\nbody') Defensive patterns
Strategy: validation
Validate before calling
assert len(children) == 1 and isinstance(children[0], (str, Var)) rx.markdown(*children)
Prevention
- Join multiple text blocks into one string before rx.markdown
- Never nest components inside markdown
When it happens
Trigger: rx.markdown() with no args, rx.markdown('# Hi', rx.text('extra')), or rx.markdown(rx.text('# Hi')).
Common situations: Forgetting the source string; trying to nest components inside markdown; passing a list of blocks instead of one joined string.
Related errors
- f"Expected EscapeSequence to have a single RawText child…
- f"FormControl can only have at most one child, got
- f"No markdown component found for tag
- A case tuple should have at least a match case element and…
- All parameters of ` ` must be annotated as `rx.Var[...]` or…
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/4f9edbfd5ed1d294.
Report an issue: GitHub.
Appendix: source
Thrown at packages/reflex-components-markdown/src/reflex_components_markdown/markdown.py:247
cls,
*children,
**props,
) -> Component:
"""Create a markdown component.
Args:
*children: The children of the component.
**props: The properties of the component.
Returns:
The markdown component.
Raises:
ValueError: If the children are not valid.
"""
if len(children) != 1 or not isinstance(children[0], (str, Var)):
msg = "Markdown component must have exactly one child containing the markdown source."
raise ValueError(msg)
# Update the base component map with the custom component map.
component_map = {**get_base_component_map(), **props.pop("component_map", {})}
# Get the markdown source.
src = children[0]
# Dedent the source.
if isinstance(src, str):
src = textwrap.dedent(src)
# Create the component.
return super().create(
src,
component_map=component_map,
component_map_hash=cls._component_map_hash(component_map),
**props,
)View on GitHub (pinned to 45b8ed5ab7)