-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I finally understood what causes the problem (but not why). due to the refactoring, I have sub-sub-states and that is the issue:
from typing import List, Dict
import pynecone as pc
class ButtonModel(pc.Model, table=False):
title: str
class AppState(pc.State):
"""The app state."""
default_field: str
class LocalState(AppState):
button_state: List[bool] = [False for i in range(10)]
@pc.var
def get_buttonmodel(self) -> List[ButtonModel]:
self.default_field = "break me"
return [ButtonModel(id=0, title="this is a button which breaks pynecone"), ButtonModel(id=1, title=self.default_field)]
class SubState(LocalState):
def trigger_fault(self) -> None:
print("error")
def index():
return pc.center(
pc.vstack(
pc.foreach(LocalState.get_buttonmodel, lambda a_model: display_form(a_model)),
spacing="1.5em",
font_size="2em",
),
padding_top="10%",
)
def display_form(model: ButtonModel):
return pc.button(model.title, size="lg", on_click=SubState.trigger_fault)
# Add state and page to the app.
app = pc.App(state=AppState)
app.add_page(index)
app.compile()Originally posted by @matt-grain in #136 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
