reflex-dev/reflex · error · ValueError

No default value or factory provided.

Error message

No default value or factory provided.

What it means

The @rx.dynamic(page) decorator requires the wrapped function to take exactly one parameter — the page's state class. Any other arity raises DynamicComponentInvalidSignatureError at decoration time.

Source

Thrown at packages/reflex-base/src/reflex_base/components/field.py:63

            # For other types (including Union), preserve the original type
            self.type_ = annotated_type
        self.type_origin = type_origin

    def default_value(self) -> FIELD_TYPE:
        """Get the default value for the field.

        Returns:
            The default value for the field.

        Raises:
            ValueError: If no default value or factory is provided.
        """
        if self.default is not MISSING:
            return self.default
        if self.default_factory is not None:
            return self.default_factory()
        msg = "No default value or factory provided."
        raise ValueError(msg)


class FieldBasedMeta(type):
    """Shared metaclass for field-based classes like components and props.

    Provides common field inheritance and processing logic for both
    PropsBaseMeta and BaseComponentMeta.
    """

    def __new__(
        cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any]
    ) -> type:
        """Create a new field-based class.

        Args:
            name: The name of the class.
            bases: The base classes.
            namespace: The class namespace.

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Give the function exactly one parameter and pass the state class: `def page(state: MyState) -> rx.Component`
  2. Remove extra parameters; get other data via state or get_state

Example fix

// before
@rx.dynamic(route="/post/[pid]")
def post(): ...
// after
@rx.dynamic(route="/post/[pid]")
def post(state: PostState) -> rx.Component: ...
Defensive patterns

Strategy: validation

Validate before calling

import inspect
params = list(inspect.signature(fn).parameters)
assert len(params) == 1, "dynamic page fn must take exactly the state class"

Prevention

When it happens

Trigger: `@rx.dynamic(route)` on a function with zero or multiple parameters, or an instance method / lambda with extra args.

Common situations: Converting a regular page component into a dynamic route page and forgetting to add the `state` parameter; copying a static component function that takes props.

Related errors


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