reflex-dev/reflex · error · TypeError
`{definition.python_name}` only accepts keyword props.
Error message
`{definition.python_name}` only accepts keyword props. What it means
A memoized component's declared props are keyword-only at the call site. If you pass positional arguments to a memo that has no children parameter, Reflex raises this TypeError because there is no positional slot for the values.
Source
Thrown at packages/reflex-base/src/reflex_base/components/memo.py:1553
raise TypeError(msg)
if rest_param is not None and rest_param.name in kwargs:
msg = (
f"`{definition.python_name}` captures rest props from extra keyword "
f"arguments. Do not pass `{rest_param.name}=` directly."
)
raise TypeError(msg)
if args and children_param is None:
msg = f"`{definition.python_name}` only accepts keyword props."
raise TypeError(msg)
if any(not _is_component_child(child) for child in args):
msg = (
f"`{definition.python_name}` only accepts positional children that are "
"`rx.Component` or `rx.Var[rx.Component]`."
)
raise TypeError(msg)
# Bind declared props before collecting any rest props.
explicit_params = [
param
for param in definition.params
if param.kind not in (MemoParamKind.REST, MemoParamKind.CHILDREN)
]
explicit_values = {}
remaining_props = kwargs.copy()
for param in explicit_params:
if param.name in remaining_props:
explicit_values[param.name] = remaining_props.pop(param.name)
elif param.default is not inspect.Parameter.empty:
explicit_values[param.name] = param.default
else:
msg = f"`{definition.python_name}` is missing required prop `{param.name}`."
raise TypeError(msg)
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Pass all props by keyword: `badge(label="hello")`.
- If you intended the value to be children, add a children parameter to the memo signature (or rely on the children convention) and keep the positional argument.
Example fix
# before
badge("hello")
# after
badge(label="hello") Defensive patterns
Strategy: type-guard
Validate before calling
def call_memo(memo_fn, args: tuple, kwargs: dict):
if args and "children" not in memo_fn.__annotations__:
kwargs = dict(kwargs)
# convert positional props to keyword if you know the first param name
return memo_fn(*args, **kwargs) Prevention
- Always call prop-only memos with keyword arguments: memo(label="x").
- Only positional arguments you pass to a memo should be children components.
- Configure your linter/IDE to flag calls with unexpected positional args.
When it happens
Trigger: Calling `badge("hello")` where `@rx.memo def badge(label: rx.Var[str])` has no children param — the positional string has nowhere to bind. Any positional args on a children-less memo trigger it.
Common situations: Calling a prop-only memo like a plain function; passing a string first argument by habit (common when migrating from functions that took a label positionally); forgetting that only children, not props, may be positional.
Related errors
- `@rx.memo` does not support `*args` in `{fn_name}`.
- `@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
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/d0b56a25f8fdb385.
Report an issue: GitHub.