diff --git a/pyproject.toml b/pyproject.toml index a4199f6b0..0ee37bb83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "reflex" -version = "0.3.9" +version = "0.3.10" description = "Web apps in pure Python." license = "Apache-2.0" authors = [ diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index 2b73a3689..052936f7f 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -63,6 +63,10 @@ def _compile_theme(theme: dict) -> str: return templates.THEME.render(theme=theme) +def _is_dev_mode() -> bool: + return os.environ.get("REFLEX_ENV_MODE", "dev") == "dev" + + def _compile_contexts(state: Optional[Type[BaseState]]) -> str: """Compile the initial state and contexts. @@ -72,16 +76,15 @@ def _compile_contexts(state: Optional[Type[BaseState]]) -> str: Returns: The compiled context file. """ - is_dev_mode = os.environ.get("REFLEX_ENV_MODE", "dev") == "dev" return ( templates.CONTEXT.render( initial_state=utils.compile_state(state), state_name=state.get_name(), client_storage=utils.compile_client_storage(state), - is_dev_mode=is_dev_mode, + is_dev_mode=_is_dev_mode(), ) if state - else templates.CONTEXT.render(is_dev_mode=is_dev_mode) + else templates.CONTEXT.render(is_dev_mode=_is_dev_mode()) ) @@ -238,7 +241,12 @@ def _compile_stateful_components( # When the component is referenced by more than one page, render it # to be included in the STATEFUL_COMPONENTS module. - if isinstance(component, StatefulComponent) and component.references > 1: + # Skip this step in dev mode, thereby avoiding potential hot reload errors for larger apps + if ( + isinstance(component, StatefulComponent) + and component.references > 1 + and not _is_dev_mode() + ): # Reset this flag to render the actual component. component.rendered_as_shared = False