reflex-dev/reflex · error · TypeError
`@rx.memo` does not support `*args` in `{fn_name}`.
Error message
`@rx.memo` does not support `*args` in `{fn_name}`. What it means
`@rx.memo` inspects the wrapped function's signature and rejects `*args` (VAR_POSITIONAL) parameters. Memoized component functions must have a fully explicit signature so Reflex can statically map each parameter to a typed prop at compile time; variadic positional arguments cannot be classified as props.
Source
Thrown at packages/reflex-base/src/reflex_base/components/memo.py:1359
)
return tuple(params)
def _check_parameter_kind(parameter: inspect.Parameter, fn_name: str) -> None:
"""Reject Python parameter kinds (``*args`` / ``**kwargs`` / positional-only)
that memo does not support.
Args:
parameter: The parameter to check.
fn_name: The function name for error messages.
Raises:
TypeError: If the parameter uses an unsupported kind.
"""
if parameter.kind is inspect.Parameter.VAR_POSITIONAL:
msg = f"`@rx.memo` does not support `*args` in `{fn_name}`."
raise TypeError(msg)
if parameter.kind is inspect.Parameter.VAR_KEYWORD:
msg = f"`@rx.memo` does not support `**kwargs` in `{fn_name}`."
raise TypeError(msg)
if parameter.kind is inspect.Parameter.POSITIONAL_ONLY:
msg = f"`@rx.memo` does not support positional-only parameters in `{fn_name}`."
raise TypeError(msg)
def _classify_parameter(
annotation: Any, param_name: str, fn_name: str
) -> tuple[MemoParamKind, Any]:
"""Walk ``_CLASSIFICATION_ORDER`` and return the first matching kind.
Args:
annotation: The parameter annotation.
param_name: The parameter name (some kinds care, e.g. ``children``).
fn_name: The function name for error messages.
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Remove `*args` and declare each prop explicitly with `rx.Var[...]` annotations, e.g. `def item(label: rx.Var[str], count: rx.Var[int])`.
- If you need a variable set of props, declare a single `rx.RestProp` parameter instead of `*args`.
- Keep variadic-argument helpers as plain functions outside `@rx.memo` and pass their result in as an explicit prop.
Example fix
// before
@rx.memo
def item(*args):
return rx.box(*args)
# after
@rx.memo
def item(a: rx.Var[str], b: rx.Var[str]):
return rx.box(a, b) Defensive patterns
Strategy: validation
Validate before calling
import inspect
def memo_signature_ok(fn) -> bool:
for p in inspect.signature(fn).parameters.values():
if p.kind is inspect.Parameter.VAR_POSITIONAL:
return False
return True
assert memo_signature_ok(item), "remove *args before applying @rx.memo" Prevention
- Always annotate every memo parameter explicitly; never use *args or **kwargs in @rx.memo functions.
- Use rx.RestProp when you need flexible extra props.
- Add a lint/test that reflects over memo functions to assert signatures are explicit.
When it happens
Trigger: Decorating a function with `@rx.memo` where the signature contains `*args`, e.g. `@rx.memo def item(*args): ...`. The error is raised eagerly at decoration time by `_analyze_params` -> `_check_parameter_kind`.
Common situations: Copying a plain Python helper that used `*args` into a memoized component; refactoring a render function to accept flexible arguments; converting a wrapper/decorator-style function to `@rx.memo`.
Related errors
- `@rx.memo` does not support `**kwargs` in `{fn_name}`.
- `@rx.memo` does not support positional-only parameters in `{
- All parameters of `{fn_name}` must be annotated as `rx.Var[.
- Component-returning `@rx.memo` `{fn.__name__}` must return a
- `{definition.python_name}` only accepts children positionall
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/70d1b28adcd64419.
Report an issue: GitHub.