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

  1. Pass all props by keyword: `badge(label="hello")`.
  2. 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

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


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/d0b56a25f8fdb385. Report an issue: GitHub.