Skip to content

Commit 0225b96

Browse files
authored
correctly handle backend rx.Field default values (#5833)
1 parent e2105fe commit 0225b96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

reflex/state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def __init_subclass__(cls, mixin: bool = False, **kwargs):
533533
cls._check_overridden_computed_vars()
534534

535535
new_backend_vars = {
536-
name: value
536+
name: value if not isinstance(value, Field) else value.default_value()
537537
for name, value in list(cls.__dict__.items())
538538
if types.is_backend_base_variable(name, cls)
539539
}
@@ -1207,7 +1207,8 @@ def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
12071207
The default value of the var or None.
12081208
"""
12091209
try:
1210-
return getattr(cls, name)
1210+
value = getattr(cls, name)
1211+
return value if not isinstance(value, Field) else value.default_value()
12111212
except AttributeError:
12121213
try:
12131214
return types.get_default_value_for_type(annotation_value)

0 commit comments

Comments
 (0)