File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,30 @@ def MyComponent():
243
243
244
244
# gives the target ID for onClick where from the last render of MyComponent
245
245
static_handlers.target
246
+
247
+ If you need to capture event handlers from different instances of a component
248
+ the you should create multiple ``StaticEventHandler`` instances.
249
+
250
+ .. code-block::
251
+
252
+ static_handlers_by_key = {
253
+ "first": StaticEventHandler(),
254
+ "second": StaticEventHandler(),
255
+ }
256
+
257
+ @idom.component
258
+ def Parent():
259
+ return idom.html.div(Child(key="first"), Child(key="second"))
260
+
261
+ @idom.component
262
+ def Child(key):
263
+ state, set_state = idom.hooks.use_state(0)
264
+ handler = static_handlers_by_key[key].use(lambda event: set_state(state + 1))
265
+ return idom.html.button({"onClick": handler}, "Click me!")
266
+
267
+ # grab the individual targets for each instance above
268
+ first_target = static_handlers_by_key["first"].target
269
+ second_target = static_handlers_by_key["second"].target
246
270
"""
247
271
248
272
def __init__ (self ) -> None :
You can’t perform that action at this time.
0 commit comments