Fix ClientStateVar late mount default sync
Closed
HA
3mo ago+150+150+012345678901234567890123456789-1-1-0123456789
Fixes #6823
Summary
Fixes a global ClientStateVar rendering bug where a component that mounted while the shared value was non-default
could get stuck when the value was later pushed back to the default.
Changes
- Initialize global
ClientStateVarlocal state from the sharedrefsmirror when available. - Preserve the existing plain
useState(default)behavior for non-global client state. - Add regression coverage for:
- global client state reading from the shared ref
- global client state without a default using
undefined - local client state not reading from shared refs
- Add a bugfix news fragment.
Testing
uv run pytest tests/units/test_client_state.py -quv run pytest tests/units/compiler/test_memoize_plugin.py -k client_state -quv run ruff check reflex/experimental/client_state.py tests/units/test_client_state.pyuv run ruff format --check reflex/experimental/client_state.py tests/units/test_client_state.pyuv run pyright reflex/experimental/client_state.py tests/units/test_client_state.pyuv run towncrier check --config pyproject.toml --dir . --compare-with origin/main