From eb2e1c0633fd76a71f8dfc2cca1e8482fc893972 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Thu, 19 Mar 2026 16:05:08 -0700 Subject: [PATCH 1/2] exp isinstance check --- reflex/compiler/compiler.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index 38ccd647722..108480db562 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -6,7 +6,7 @@ from collections.abc import Callable, Iterable, Sequence from inspect import getmodule from pathlib import Path -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, TypeGuard from reflex import constants from reflex.compiler import templates, utils @@ -387,6 +387,10 @@ def _compile_memo_components( ) +def is_stateful_component(component: BaseComponent) -> TypeGuard[StatefulComponent]: + return StatefulComponent in type(component).__mro__ + + def _get_shared_components_recursive( component: BaseComponent, rendered_components: dict[str, None], @@ -410,11 +414,7 @@ def _get_shared_components_recursive( # When the component is referenced by more than one page, render it # to be included in the STATEFUL_COMPONENTS module. # Skip this step in dev mode, thereby avoiding potential hot reload errors for larger apps - if ( - isinstance(component, StatefulComponent) - and component.references > 1 - and is_prod_mode() - ): + if is_stateful_component(component) and component.references > 1 and is_prod_mode(): # Reset this flag to render the actual component. component.rendered_as_shared = False From 5cb1beaee0807fc5ec8a2e50fc5cfe74279e0861 Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Thu, 19 Mar 2026 16:16:27 -0700 Subject: [PATCH 2/2] what are we doing here --- reflex/compiler/compiler.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/reflex/compiler/compiler.py b/reflex/compiler/compiler.py index 108480db562..a097b2d99f2 100644 --- a/reflex/compiler/compiler.py +++ b/reflex/compiler/compiler.py @@ -6,7 +6,7 @@ from collections.abc import Callable, Iterable, Sequence from inspect import getmodule from pathlib import Path -from typing import TYPE_CHECKING, Any, TypeGuard +from typing import TYPE_CHECKING, Any from reflex import constants from reflex.compiler import templates, utils @@ -387,10 +387,6 @@ def _compile_memo_components( ) -def is_stateful_component(component: BaseComponent) -> TypeGuard[StatefulComponent]: - return StatefulComponent in type(component).__mro__ - - def _get_shared_components_recursive( component: BaseComponent, rendered_components: dict[str, None], @@ -414,7 +410,7 @@ def _get_shared_components_recursive( # When the component is referenced by more than one page, render it # to be included in the STATEFUL_COMPONENTS module. # Skip this step in dev mode, thereby avoiding potential hot reload errors for larger apps - if is_stateful_component(component) and component.references > 1 and is_prod_mode(): + if isinstance(component, StatefulComponent) and component.references > 1: # Reset this flag to render the actual component. component.rendered_as_shared = False @@ -620,7 +616,7 @@ def compile_stateful_components( progress_function() page_components.append(page_component) - code = _compile_stateful_components(page_components) + code = _compile_stateful_components(page_components) if is_prod_mode() else "" return output_path, code, page_components