Closed
Description
Current Situation
If two children obtain their key
from a parent, both children's use_state
are wiped if either child changes key
.
from idom import component, html, run, hooks
@component
def Parent():
state, set_state = hooks.use_state(1)
return html.div(
html.button({"onClick": lambda event: set_state(state + 1)}, "click me"),
Child("key-0"),
Child(f"key-{state}"),
)
@component
def Child(child_key):
state, set_state = hooks.use_state(0)
@hooks.use_effect
async def whatever():
if state:
return
print(f"Child {child_key!r} has no state")
set_state(1)
return html.div(
child_key,
key=child_key,
)
run(Parent)
Proposed Actions
Investigate and resolve this parent-child key abnormality
Work Items
See above