1
0
Эх сурвалжийг харах

Create StatefulComponent for LiteralComponentVar

TODO: actually pass through locals properly
Masen Furer 4 сар өмнө
parent
commit
ec02b2c2db

+ 6 - 0
reflex/components/component.py

@@ -2274,6 +2274,10 @@ class StatefulComponent(BaseComponent):
 
 
         return _compile_component(self)
         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
     @classmethod
     def compile_from(cls, component: BaseComponent) -> BaseComponent:
     def compile_from(cls, component: BaseComponent) -> BaseComponent:
         """Walk through the component tree and memoize all stateful components.
         """Walk through the component tree and memoize all stateful components.
@@ -2474,6 +2478,8 @@ class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
         Returns:
         Returns:
             The var.
             The var.
         """
         """
+        if not isinstance(value, StatefulComponent):
+            value = StatefulComponent.compile_from(value) or value
         return LiteralComponentVar(
         return LiteralComponentVar(
             _js_expr="",
             _js_expr="",
             _var_type=type(value),
             _var_type=type(value),