-
Hi everybody, I am in a project with lit using some controls with reactive properties, but we found that when the value change inside the child control this value is not received by the parent. Here is a simple playground to explain it Is something wrong in the code or is a bug? We need to be able to get de value of the children control from the parent without addintional functions while they are in diferents files as in the playground. Thanks a lot for your help and support. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This behavior is not automatic by design. Instead when you want to sync a property between a child and a parent, the child should dispatch an event that the parent handles to set its property. For additional background see the Events docs and Event communication between web components. Here's an updated example. There are 2 changes:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your fast answer! |
Beta Was this translation helpful? Give feedback.
This behavior is not automatic by design. Instead when you want to sync a property between a child and a parent, the child should dispatch an event that the parent handles to set its property. For additional background see the Events docs and Event communication between web components.
Here's an updated example. There are 2 changes:
change
event. The name of this can be whatever you want. The parent then handles this event@change
and sets its property to the child property..
here.myreactiveprop
). This isn't strictly necessary but it's typically b…