Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow disabling auto-setters via state_auto_setters config #4480

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,9 @@ class Config: # pyright: ignore [reportIncompatibleVariableOverride]
# Path to file containing key-values pairs to override in the environment; Dotenv format.
env_file: Optional[str] = None

# Whether to automatically create setters for state base vars
state_auto_setters: bool = True

# Whether to display the sticky "Built with Reflex" badge on all pages.
show_built_with_reflex: bool = True

Expand Down
3 changes: 2 additions & 1 deletion reflex/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@ def _init_var(cls, prop: Var):
f'Found var "{prop._js_expr}" with type {prop._var_type}.'
)
cls._set_var(prop)
cls._create_setter(prop)
if get_config().state_auto_setters:
cls._create_setter(prop)
cls._set_default_value(prop)

@classmethod
Expand Down
Loading