reflex-dev/reflex · error · ValueError

DataEditor data must be an ArrayVar if rows is not provided.

Error message

DataEditor data must be an ArrayVar if rows is not provided.

What it means

data_editor needs to know the row count. When rows is not given, it derives it from data — but only ArrayVar data supports .length(); a non-array Var (e.g. a dict-typed state var) has no length, so Reflex raises this.

Source

Thrown at packages/reflex-components-dataeditor/src/reflex_components_dataeditor/dataeditor.py:522

            **props: The props of the data editor.

        Returns:
            The DataEditor component.&

        Raises:
            ValueError: invalid input.
        """
        from reflex_components_core.el import Div

        columns = props.get("columns", [])
        data = props.get("data", [])
        rows = props.get("rows")

        # If rows is not provided, determine from data.
        if rows is None:
            if isinstance(data, Var) and not isinstance(data, ArrayVar):
                msg = "DataEditor data must be an ArrayVar if rows is not provided."
                raise ValueError(msg)

            props["rows"] = data.length() if isinstance(data, ArrayVar) else len(data)

        if not isinstance(columns, Var) and len(columns):
            if types.is_dataframe(type(data)) or (
                isinstance(data, Var) and types.is_dataframe(data._var_type)
            ):
                msg = "Cannot pass in both a pandas dataframe and columns to the data_editor component."
                raise ValueError(msg)
            props["columns"] = [
                format.format_data_editor_column(col) for col in columns
            ]

        if "theme" in props:
            theme = props.get("theme")
            if isinstance(theme, Mapping):
                props["theme"] = DataEditorTheme(**theme)

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Pass an explicit rows=count or rows=State.n_rows prop
  2. Type the data var as a list/array (e.g. data: list[list] on state) so it is an ArrayVar
  3. If data is a DataFrame, ensure it is passed as the raw DataFrame or a properly typed var

Example fix

# before
rx.data_editor(data=State.table_data)  # dict var
# after
rx.data_editor(data=State.table_data, rows=State.row_count)
Defensive patterns

Strategy: validation

Validate before calling

from reflex.vars import Var
if isinstance(data, Var) and not _is_array_var(data) and rows is None:
    rows = fallback_row_count  # or raise early with your own message

Type guard

def needs_explicit_rows(data: Any, rows: Any) -> bool:
    from reflex.vars import ArrayVar
    return rows is None and isinstance(data, Var) and not isinstance(data, ArrayVar)

Prevention

When it happens

Trigger: Passing data=State.my_dict_var or any Var whose type is not an array (dict, object, DataFrame-unwrapped var) without rows=... to data_editor.

Common situations: Switching data from a list-based state var to a dict/computed var and forgetting to pass rows; passing a DataFrame-backed var shaped differently than expected.

Related errors


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