Skip to content

Commit 6b2cf35

Browse files
fix: properly initialize rx.Field annotated backend vars in mixin states
1 parent fb19fb4 commit 6b2cf35

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

reflex/state.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,15 @@ def __init_subclass__(cls, mixin: bool = False, **kwargs):
523523

524524
new_backend_vars = {
525525
name: value if not isinstance(value, Field) else value.default_value()
526-
for name, value in list(cls.__dict__.items())
526+
for mixin_cls in [*cls._mixins(), cls]
527+
for name, value in list(mixin_cls.__dict__.items())
527528
if types.is_backend_base_variable(name, cls)
528529
}
529530
# Add annotated backend vars that may not have a default value.
530531
new_backend_vars.update({
531532
name: cls._get_var_default(name, annotation_value)
532-
for name, annotation_value in cls._get_type_hints().items()
533+
for mixin_cls in [*cls._mixins(), cls]
534+
for name, annotation_value in mixin_cls._get_type_hints().items()
533535
if name not in new_backend_vars
534536
and types.is_backend_base_variable(name, cls)
535537
})
@@ -579,9 +581,6 @@ def __init_subclass__(cls, mixin: bool = False, **kwargs):
579581
cls.computed_vars[name] = newcv
580582
cls.vars[name] = newcv
581583
continue
582-
if types.is_backend_base_variable(name, mixin_cls):
583-
cls.backend_vars[name] = copy.deepcopy(value)
584-
continue
585584
if events.get(name) is not None:
586585
continue
587586
if not cls._item_is_event_handler(name, value):

0 commit comments

Comments
 (0)