You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A str-annotated field whose default_factory produces browser storage is never treated as browser storage #7498
State._is_client_storage("theme") is False, the var is not compiled into the client storage section, and it is never synced with the browser. Each instance just holds a LocalStorage instance as an ordinary str value. Nothing warns.
The same declaration with the storage annotation (theme: rx.LocalStorage = rx.field(default_factory=...)) is detected through the annotation (but see the separate hydration error issue filed with this one).
Why
BaseState._is_client_storage (reflex/state.py) only looks at field.default and at the annotation. A factory only reveals what it produces when called, and nothing calls it at class creation. After #7495 a plain assignment through the class (State.theme = "dark") calls the factory once and turns the field into browser storage, so the var is detected from then on; without such an assignment it is not. Note also that _is_client_storage is cached per class, so a class assignment made after the first lookup would not be seen until the cache is cleared.
Options
Evaluate a declared default_factory once at class creation when the annotation is not a storage type, and classify the field by the result (cost: one factory call per such field per class).
Or reject / warn about a factory-produced storage default and document that browser storage must be declared as a default value or with a storage annotation.
Activity
linear-code commentedon Oct 7, 2026
ENG-13172
prerelease 10-07: #7494 drops the previous-release pickle entries; #7495