reflex-dev/reflex · error · ValueError
Only one default import is allowed.
Error message
Only one default import is allowed.
What it means
compile_import_statement validates an ImportTag set and raises ValueError when two or more fields in a single import statement are marked as default imports. An ES module import can have only one default binding (e.g. import Def, { named } from 'mod'), so multiple defaults are ambiguous.
Source
Thrown at reflex/compiler/utils.py:70
Args:
fields: The set of fields to import from the library.
Returns:
The libraries for default and rest.
default: default library. When install "import def from library".
rest: rest of libraries. When install "import {rest1, rest2} from library"
Raises:
ValueError: If there is more than one default import.
"""
# ignore the ImportVar fields with render=False during compilation
fields_set = {field for field in fields if field.render}
# Check for default imports.
defaults = {field for field in fields_set if field.is_default}
if len(defaults) >= 2:
msg = "Only one default import is allowed."
raise ValueError(msg)
# Get the default import, and the specific imports.
default = next(iter({field.name for field in defaults}), "")
rest = {field.name for field in fields_set - defaults}
return default, sorted(rest)
def validate_imports(import_dict: ParsedImportDict):
"""Verify that the same Tag is not used in multiple import.
Args:
import_dict: The dict of imports to validate
Raises:
ValueError: if a conflict on "tag/alias" is detected for an import.
"""
used_tags = {}View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Ensure only one field per module uses the default import; convert extras to named imports
- Audit custom component code that builds import dicts manually and deduplicate default tags
- After upgrading Reflex, regenerate or update import declarations to the current API (rxImportVar / ImportTag usage)
Example fix
# before
imports = {"react": [ImportVar(tag="default", is_default=True), ImportVar(tag="other", is_default=True)]}
# after
imports = {"react": [ImportVar(tag="default", is_default=True), ImportVar(tag="other")]} Defensive patterns
Strategy: validation
Validate before calling
defaults = [f for f in fields if f.is_default] assert len(defaults) <= 1, "only one default import per module"
Prevention
- Emit at most one default ImportVar/ImportTag per module
- Deduplicate defaults when merging import dicts
- Regenerate import code after Reflex upgrades
When it happens
Trigger: Passing multiple fields with is_default=True for the same module when building an import statement, e.g. via custom components or libraries constructing ImportVar/ImportTag lists with several defaults; merging imports that each carry their own default tag for the same package.
Common situations: Custom component libraries or code generators emitting two default ImportVars for one module; Reflex version changes altering how default imports are declared (older field-based API vs newer ImportTag API) after an upgrade.
Related errors
- Var-returning `@rx.memo` `{func_name}` cannot import `{lib}`
- prop value for {key!s} of the `{comp_name}` component should
- Compiled app root must be a Component.
- Compiled page {route!r} root must be a Component before it c
- To access rx.State in frontend components, at least one subc
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/7aa0487057caa438.
Report an issue: GitHub.