Skip to content

Parent control and reactive properties #4623

Answered by sorvell
dsgaye asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  1. On the child element, the click event that sets the property fires a 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.
  2. The child part is bound via the property and not the attribute (add the . here .myreactiveprop). This isn't strictly necessary but it's typically b…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dsgaye
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants