Document that a named storage var shares one key across ComponentState instances
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- This change requires a documentation update
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable? (docs only)
- Have you successfully ran tests with your changes locally? (pre-commit)
What and why
Finding A3-03 from the 0.10.0a3 pre-release re-verification. An independent verifier narrowed it to a documentation caveat.
Each ComponentState instance gets its own state class and its own configured default. A browser storage var declared with a name, though, keeps that name in every instance, so all instances read and write one browser key. After a reload, one component shows another's stored choice. 0.9.12 shared the key the same way. 0.10.0a2 only hid it because N-005 dropped the storage.
The 0.10 changelog entry for #7495 uses exactly this pattern as its example: cls.theme = initial in get_component for rx.LocalStorage("light", name="theme"). base_vars.md says get_component configures defaults "independently for each component". Neither mentions the shared key.
Changes
The caveat goes in three places, each with the two ways to store a value per component:
docs/vars/base_vars.md: one sentence after "independently for each component".docs/state_structure/component_state.md: a short paragraph after thecls.textexample.news/+storage-default-assignment.bugfix.md, the unreleased #7495 entry: one sentence on itsthemeexample.
A docs-site fragment is added under docs/app/news/.
Checked against main. In a probe, two create() calls of a ComponentState with rx.LocalStorage("light", name="theme") both store under theme. Assigning cls.theme = rx.LocalStorage(initial, name=f"theme_{key}") in get_component gives theme_c and theme_d. An unnamed storage var is keyed by its own component state.
Related: #7506 (several sync=True vars sharing one name only sync the last one across tabs). Evidence: A3-03 in FINDINGS.md. Repro app: a3_hydration/src/csbox, with driver a3_hydration/drivers/csbox_check.py.
š¤ Generated with Claude Code