MCPcopy Index your code
hub / github.com/reactive-python/reactpy / Item

Function Item

src/py/reactpy/tests/test_core/test_layout.py:1209–1222  ·  view source on GitHub ↗
(item: str, all_items: State[list[str]])

Source from the content-addressed store, hash-verified

1207
1208 @component
1209 def Item(item: str, all_items: State[list[str]]):
1210 color = use_state(None)
1211
1212 def deleteme(event):
1213 all_items.set_value([i for i in all_items.value if (i != item)])
1214
1215 def colorize(event):
1216 color.set_value("blue" if not color.value else None)
1217
1218 return html.div(
1219 {"id": item, "color": color.value},
1220 html.button({"on_click": colorize}, f"Color {item}"),
1221 html.button({"on_click": deleteme}, f"Delete {item}"),
1222 )
1223
1224 @component
1225 def App():

Callers 1

AppFunction · 0.70

Calls 1

use_stateFunction · 0.90

Tested by

no test coverage detected