reflex-dev/reflex · error · ValueError
Memo name collision for `{key[0]}`: `{existing.fn.__module__
Error message
Memo name collision for `{key[0]}`: `{existing.fn.__module__}.{existing.python_name}` and `{definition.fn.__module__}.{definition.python_name}` both compile to the same memo name in the same module. What it means
Beyond arity, @rx.dynamic requires the single parameter to carry a type hint resolving to the page's state class. Missing or extra type hints raise DynamicComponentInvalidSignatureError.
Source
Thrown at packages/reflex-base/src/reflex_base/components/memo.py:559
"""Register a memo definition.
Args:
definition: The memo definition to register.
Raises:
ValueError: If another memo already compiles to the same exported name.
"""
key = _memo_registry_key(definition)
if (existing := MEMOS.get(key)) is not None and (
not _is_memo_reregistration(existing, definition)
):
msg = (
f"Memo name collision for `{key[0]}`: "
f"`{existing.fn.__module__}.{existing.python_name}` and "
f"`{definition.fn.__module__}.{definition.python_name}` both compile "
"to the same memo name in the same module."
)
raise ValueError(msg)
MEMOS[key] = definition
def _annotation_inner_type(annotation: Any) -> Any:
"""Unwrap a Var-like annotation to its inner type.
Args:
annotation: The annotation to unwrap.
Returns:
The inner type for the annotation.
"""
if _is_rest_annotation(annotation):
return dict[str, Any]
annotation = _strip_annotated(annotation)
origin = get_origin(annotation) or annotationView on GitHub (pinned to 45b8ed5ab7)
Solutions
- Annotate the parameter with the state class: `def page(state: PostState) -> rx.Component`
- Ensure PostState subclasses rx.State and is imported at decoration time
Example fix
// before @rx.dynamic(route="/post/[pid]") def post(state): ... // after @rx.dynamic(route="/post/[pid]") def post(state: PostState) -> rx.Component: ...
Defensive patterns
Strategy: validation
Validate before calling
import inspect sig = inspect.signature(fn) (p,) = sig.parameters.values() assert p.annotation is not inspect.Parameter.empty, "annotate the state param"
Prevention
- Annotate the state parameter with the exact State subclass
- Don't strip type hints in builds that use @rx.dynamic
When it happens
Trigger: `def page(state): ...` (no annotation) under @rx.dynamic; or annotations resolving to zero/multiple entries after signature inspection.
Common situations: Omitting annotations for brevity; hinting with a non-state type; IDE auto-stripping type hints in optimized builds.
Related errors
- No default value or factory provided.
- Route part `{part}` with argument is not valid. Reflex only
- ChildrenTypeError(component=cls.__name__, child=child)
- Do not override _add_style directly. Use add_style instead.
- The component `{comp_name}` cannot have `{child_name}` as a
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/35fc16e2fd3f1330.
Report an issue: GitHub.