{"record":{"id":"48926f7f602ad5c9","repo":"reflex-dev/reflex","slug":"link-without-a-child-will-not-display","errorCode":null,"errorMessage":"Link without a child will not display","messagePattern":"Link without a child will not display","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-radix/src/reflex_components_radix/themes/typography/link.py","lineNumber":98,"sourceCode":"\n        Returns:\n            Component: The link component\n\n        Raises:\n            ValueError: in case of missing children\n        \"\"\"\n        props.setdefault(\"_hover\", {\"color\": color(\"accent\", 8)})\n        href = props.get(\"href\")\n\n        is_external = props.pop(\"is_external\", None)\n\n        if is_external is not None:\n            props[\"target\"] = cond(is_external, \"_blank\", \"\")\n\n        if href is not None:\n            if not len(children):\n                msg = \"Link without a child will not display\"\n                raise ValueError(msg)\n\n            if \"as_child\" not in props:\n                # Extract props for the ReactRouterLink, the rest go to the Link/A element.\n                react_router_link_props = {}\n                for prop in props.copy():\n                    if prop in _KNOWN_REACT_ROUTER_LINK_PROPS:\n                        react_router_link_props[prop] = props.pop(prop)\n\n                react_router_link_props[\"to\"] = react_router_link_props.pop(\n                    \"href\", href\n                )\n\n                # If user does not use `as_child`, by default we render using react_router_link to avoid page refresh during internal navigation\n                return super().create(\n                    ReactRouterLink.create(*children, **react_router_link_props),\n                    as_child=True,\n                    **props,\n                )","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-radix/src/reflex_components_radix/themes/typography/link.py#L80-L116","documentation":"rx.link() with an href but no children renders an empty anchor that displays nothing. Reflex raises ValueError to catch this likely mistake at compile time instead of leaving an invisible dead link in the UI.","triggerScenarios":"rx.link(href='https://example.com') with no children; building links in a loop where the label variable is empty/None and the child expression is dropped.","commonSituations":"Passing the label only in props by mistake; dynamic label Vars that evaluate to empty strings with the child omitted entirely; refactoring that removed the link text.","solutions":["Add a child: rx.link('Docs', href='https://example.com')","For dynamic labels: rx.link(State.label, href=State.url)","Use as_child to wrap a component: rx.link(rx.button('Go'), href='...', as_child=True)"],"exampleFix":"# before\nrx.link(href='https://example.com')\n# after\nrx.link('Example', href='https://example.com')","handlingStrategy":"validation","validationCode":"label = label or 'link'\nrx.link(label, href=url)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass link text or a child component alongside href","Default dynamic labels to a non-empty string"],"tags":["reflex","radix","link","missing-children"],"backgroundTag":"missing-required-prop","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}