diff --git a/reflex/state.py b/reflex/state.py index d1a602ec549..04b48fd90b8 100644 --- a/reflex/state.py +++ b/reflex/state.py @@ -1619,6 +1619,9 @@ def dict( base_vars = { prop_name: self.get_value(getattr(self, prop_name), include=self.base_vars[prop_name]._var_used_attributes) # type: ignore[call-arg] for prop_name in self.base_vars + if self.base_vars[prop_name]._var_is_used + or prop_name == constants.ROUTER + or prop_name == constants.CompileVars.IS_HYDRATED } if initial: computed_vars = { @@ -1628,13 +1631,18 @@ def dict( and not isinstance(cv._initial_value, types.Unset) else self.get_value(getattr(self, prop_name), include=self.computed_vars[prop_name]._var_used_attributes) # type: ignore[call-arg] for prop_name, cv in self.computed_vars.items() + if self.computed_vars[prop_name]._var_is_used } elif include_computed: computed_vars = { # Include the computed vars. prop_name: self.get_value(getattr(self, prop_name), include=self.computed_vars[prop_name]._var_used_attributes) # type: ignore[call-arg] for prop_name in self.computed_vars + if self.computed_vars[prop_name]._var_is_used } + else: + computed_vars = {} + variables = {**base_vars, **computed_vars} d = {