forked from reactive-python/reactpy-django
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchild.py
More file actions
23 lines (21 loc) · 689 Bytes
/
child.py
File metadata and controls
23 lines (21 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from reactpy import component, html, use_state
@component
def root():
value, set_value = use_state(0)
return html.article(
{"id": "child"},
"This was embedded via a server-side component.",
html.div(
{"className": "grid"},
html.button(
{"className": "plus", "onClick": lambda _: set_value(value + 1)},
"+",
),
html.button(
{"className": "minus", "onClick": lambda _: set_value(value - 1)},
"-",
),
),
"Current value",
html.pre({"style": {"font-style": "bold"}, "data-value": str(value)}, str(value)),
)