From 62fd68ffa6823f40ec614491a12d05e196f37e78 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Tue, 20 Aug 2024 18:24:49 -0700 Subject: [PATCH] Skip instantiation of VarData unless data was actually merged --- reflex/vars.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/reflex/vars.py b/reflex/vars.py index ab21db29c7..8428151ec1 100644 --- a/reflex/vars.py +++ b/reflex/vars.py @@ -181,15 +181,14 @@ def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None: var_data.interpolations if isinstance(var_data, VarData) else [] ) - return ( - cls( + if state or _imports or hooks or interpolations: + return cls( state=state, imports=_imports, hooks=hooks, interpolations=interpolations, ) - or None - ) + return None def __bool__(self) -> bool: """Check if the var data is non-empty. @@ -301,14 +300,13 @@ def merge( else {k: None for k in var_data.hooks} ) - return ( - ImmutableVarData( + if state or _imports or hooks: + return ImmutableVarData( state=state, imports=_imports, hooks=hooks, ) - or None - ) + return None def __bool__(self) -> bool: """Check if the var data is non-empty.