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
Assigning a plain default at class level to a LocalStorage/Cookie var silently drops browser persistence (incl. the documented ComponentState cls.value = initial pattern) #7471
Severity: MEDIUM, side effect of #7461 (0.10.0a2). Confirmed by two clusters.
What happens
classS(rx.State):
pref: str=rx.LocalStorage("light")
S.pref="dark"# or, in ComponentState.get_component: cls.pref = initial
After the assignment the var is a plain var: the ClientStorageBase wrapper (LocalStorage / Cookie / SessionStorage, with its name/sync/same_site options) is replaced by the bare value, so the value is no longer read from or written to the browser. No warning. The ComponentState form (cls.pref = "dark" on an rx.LocalStorage var inside get_component) is the pattern the docs recommend for per-instance defaults.
On 0.9.12 the class assignment was ignored for instances (the F-004 bug), so persistence survived; #7461 made the assignment take effect and the wrapper is lost in the process.
Suggested fix
When the declared default is a ClientStorageBase instance and a plain value of the right type is assigned, keep the wrapper and update only its value (preserving the storage options); assigning a new ClientStorageBase instance replaces it as today. Unit test that the field default stays a LocalStorage/Cookie after class assignment and that the client-storage wiring still lists the var; integration test that the assigned value persists across reload.
Repro and evidence
reverify_core/verification/n005-storage-assign/`` and reverify_hydration/probes/cs_storage_default_probe.py (ComponentState form, `src/csbox`).
Activity
linear-code commentedon Oct 7, 2026
ENG-13139
Bound replaced-default history and cache the mangled-name prefixes
Keep browser storage from a declared factory on plain assignment
Reuse _private_prefixes for the dev-mode private-name guard
Skip the declared factory when a storage value is assigned
Fix class-level State attribute regressions from reflex-dev#7461 / re…