{"record":{"id":"99bd32743a331106","repo":"reflex-dev/reflex","slug":"no-default-value-or-factory-provided","errorCode":null,"errorMessage":"No default value or factory provided.","messagePattern":"No default value or factory provided\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/field.py","lineNumber":63,"sourceCode":"            # For other types (including Union), preserve the original type\n            self.type_ = annotated_type\n        self.type_origin = type_origin\n\n    def default_value(self) -> FIELD_TYPE:\n        \"\"\"Get the default value for the field.\n\n        Returns:\n            The default value for the field.\n\n        Raises:\n            ValueError: If no default value or factory is provided.\n        \"\"\"\n        if self.default is not MISSING:\n            return self.default\n        if self.default_factory is not None:\n            return self.default_factory()\n        msg = \"No default value or factory provided.\"\n        raise ValueError(msg)\n\n\nclass FieldBasedMeta(type):\n    \"\"\"Shared metaclass for field-based classes like components and props.\n\n    Provides common field inheritance and processing logic for both\n    PropsBaseMeta and BaseComponentMeta.\n    \"\"\"\n\n    def __new__(\n        cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any]\n    ) -> type:\n        \"\"\"Create a new field-based class.\n\n        Args:\n            name: The name of the class.\n            bases: The base classes.\n            namespace: The class namespace.","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/field.py#L45-L81","documentation":"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.","triggerScenarios":"`@rx.dynamic(route)` on a function with zero or multiple parameters, or an instance method / lambda with extra args.","commonSituations":"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.","solutions":["Give the function exactly one parameter and pass the state class: `def page(state: MyState) -> rx.Component`","Remove extra parameters; get other data via state or get_state"],"exampleFix":"// before\n@rx.dynamic(route=\"/post/[pid]\")\ndef post(): ...\n// after\n@rx.dynamic(route=\"/post/[pid]\")\ndef post(state: PostState) -> rx.Component: ...","handlingStrategy":"validation","validationCode":"import inspect\nparams = list(inspect.signature(fn).parameters)\nassert len(params) == 1, \"dynamic page fn must take exactly the state class\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write dynamic pages as def page(state: PageState) -> rx.Component"],"tags":["reflex","dynamic-routes","decorator","signature"],"backgroundTag":"invalid-function-signature","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}