I would like to ask a question about rx.ComponentState:
Why do we need use that two:
created_ComponentState = ComponentState.create
instance_created_ComponentState = created_ComponentState()
can run:
class ComponentState(rx.ComponentState):
var: str = 'TEXT'
@classmethod
def get_component(cls):
return rx.box()
created_ComponentState = ComponentState.create
instance_created_ComponentState = created_ComponentState()
class state(rx.State):
async def function(self):
get_state = await self.get_state(created_ComponentState.State)
print(get_state.var)
def test() -> rx.Component:
return rx.button('click_me', on_click=state.function)
Why can’t it be like this:
can’t run
class ComponentState(rx.ComponentState):
var: str = 'TEXT'
@classmethod
def get_component(cls):
return rx.box()
created_ComponentState = ComponentState.create
class state(rx.State):
async def function(self):
get_state = await self.get_state(created_ComponentState().State)
print(get_state.var)
def test() -> rx.Component:
return rx.button('click_me', on_click=state.function)
it while return error:
raise RuntimeError( RuntimeError: Cannot populate parent states of reflex___state____state.reflex___istate___dynamic____component_state_n3 without redis. (All states should already be available – this is likely a bug).
is it realy a bug?
I seem to think it’s my way of using it that’s not right