2424from pynecone .utils import format , imports , path_ops , types
2525from pynecone .var import BaseVar , Var
2626
27- if typing .TYPE_CHECKING :
28- from pynecone .state import State
29-
3027
3128class Component (Base , ABC ):
3229 """The base class for all Pynecone components."""
@@ -37,9 +34,6 @@ class Component(Base, ABC):
3734 # The style of the component.
3835 style : Style = Style ()
3936
40- # The app state the component is connected to.
41- state : Optional [Type [State ]] = None
42-
4337 # A mapping from event triggers to event chains.
4438 event_triggers : Dict [str , Union [EventChain , Var ]] = {}
4539
@@ -120,7 +114,7 @@ def __init__(self, *args, **kwargs):
120114 if types ._issubclass (field_type , Var ):
121115 try :
122116 # Try to create a var from the value.
123- kwargs [key ] = Var .create (value , is_string = type ( value ) == str )
117+ kwargs [key ] = Var .create (value )
124118
125119 # Check that the var type is not None.
126120 if kwargs [key ] is None :
@@ -365,7 +359,7 @@ def create(cls, *children, **props) -> Component:
365359 children = [
366360 child
367361 if isinstance (child , Component )
368- else Bare .create (contents = Var .create (child ))
362+ else Bare .create (contents = Var .create (child , is_string = True ))
369363 for child in children
370364 ]
371365 return cls (children = children , ** props )
@@ -399,19 +393,6 @@ def add_style(self, style: ComponentStyle) -> Component:
399393 child .add_style (style )
400394 return self
401395
402- def set_state (self , state : Type [State ]):
403- """Set the state of the component and its children.
404-
405- Args:
406- state: The state to set.
407- """
408- # Set the state of the component.
409- self .state = state
410-
411- # Set the state of the children.
412- for child in self .children :
413- child .set_state (state )
414-
415396 def render (self ) -> str :
416397 """Render the component.
417398
0 commit comments