Open gniewus opened 1 month ago
Minimal repro
import reflex as rx
class State(rx.State):
@rx.var
def computed(self) -> int:
return 42
class Other(rx.State):
ref: int
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ref = State.computed
def index() -> rx.Component:
return rx.container(
rx.vstack(
rx.text(f"Bug bug {State.computed} {Other.ref}")
),
rx.logo(),
)
app = rx.App()
app.add_page(index)
This seems to be caused when assigning a ComputedVar to a regular attribute, instead of using get_state
to get the actual value.
We can possibly detect this if it's a common error and print a more reasonable error message.
@masenf let me know if i should get on that.
Can you explain how would the correct way of doing that using get_state
look like ?
Can you explain how would the correct way of doing that using
get_state
look like ?
TenKDialogState
a substate of BaseState
and access the value directly from self
class TenKDialogState(rx.State):
is_open: bool = False
ten_k: TenK = None
async def toggle_dialog(self):
self.is_open = not self.is_open
if self.is_open:
# Fetch the latest value
base_state = await self.get_state(BaseState)
self.ten_k = base_state.current_company.ten_k
def close_dialog(self):
self.is_open = False
Describe the bug Hey, im having a very hard time self-hosting the reflex app on GCP.
reflex==0.5.10
I've tried connecting Redis (tried both 7.0 and 7.2) and I'm having issues with the app as it's throwing serialization errors:
Upgrading reflex to 0.6.x does not solve the issue but it causes some other issues when picking state objects:
This makes me think that there must be an issue with my implementation and a huge State class that im using. However i can't tell which attribute/compute var is causing the problem + I also made sure wrap all attributes different from bool/dict/list into
rx.Base
objects. On 0.5.10 the error goes away when i don't use Redis :/Specifics (please complete the following information):