From ec02b2c2db7153f0a046a502245cbb1f995206a5 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 27 Jan 2025 06:05:26 -0800 Subject: [PATCH] Create StatefulComponent for LiteralComponentVar TODO: actually pass through locals properly --- reflex/components/component.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reflex/components/component.py b/reflex/components/component.py index 8c3bc5184..5fc3d8435 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -2274,6 +2274,10 @@ class StatefulComponent(BaseComponent): return _compile_component(self) + def __getattr__(self, name) -> Any: + # if we don't provide the attribute, get it from the wrapped component + return getattr(self.component, name) + @classmethod def compile_from(cls, component: BaseComponent) -> BaseComponent: """Walk through the component tree and memoize all stateful components. @@ -2474,6 +2478,8 @@ class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar): Returns: The var. """ + if not isinstance(value, StatefulComponent): + value = StatefulComponent.compile_from(value) or value return LiteralComponentVar( _js_expr="", _var_type=type(value),