pc.input value type number error : TypeError: Invalid var passed for prop value, expected type <class 'str'>, got value {state.price} of type <class 'int'>. #992
bobwatcherx
announced in
News
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i have problem how to use int in value pc.input
i have error
File "/home/mopt/belajar/pynecrud/pynecrud/pynecrud.py", line 151, in index
pc.input(
File "/usr/local/lib/python3.10/dist-packages/pynecone/components/component.py", line 365, in create
return cls(children=children, **props)
File "/usr/local/lib/python3.10/dist-packages/pynecone/components/component.py", line 131, in init
raise TypeError(
TypeError: Invalid var passed for prop value, expected type <class 'str'>, got value {state.price} of type <class 'int'>.
my code
import pynecone as pc
from .mymodel.food import Foods
class State(pc.State):
name:str
price:int
stock:int
id_edit:int
def showcustomer(user:Foods):
print(user)
return pc.tr(
pc.td(user.food_name),
pc.td(user.price),
pc.td(user.stock),
pc.td(
pc.button("Edit",
on_click=lambda: State.edit_data(user),
bg="red",
color="white"
),
pc.button("delete",
on_click=lambda: State.delete_data(user.id),
bg="blue",
color="white"
),
)
)
def index():
return pc.vstack(
pc.heading("Crud Pynecone",size="md"),
pc.input(
focus_border_color="purple",
placeholder="Food Name",
on_change=State.set_name),
Add state and page to the app.
app = pc.App(state=State)
app.add_page(index)
app.compile()
Beta Was this translation helpful? Give feedback.
All reactions