-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
child component doesn't re-render when the property is modified by the parent #899
Comments
why do you not want to |
Yeah, this is working as intended. The only properties that will automatically trigger a re-render are those listed in |
@justinfagnani @daKmoR If the child component is already watching his I don't understand why i have to re-render the whole parent to make the child re-render. Using the developer console:
I'm probably missing something, and i would like to know what. |
@dvolp the child component is observing its You need to re-render the parent when you set The binding in here only runs on a render. If this isn't run, there's nothing else to set the //inside parent component
render(){
return html`
<child-component title="${this._privateVariable}"></child-component>
`
} This is exactly why you must include |
Live Demo
https://stackblitz.com/edit/lit-element-t3yobz
Description
Let's say i have a parent component and a child component.
title
inside thestatic get properties()
object.static get properties()
of the parent component.setTimeout
inside the parent component, i change the value of the private variable.I'm not sure what should happen in this situation. Since the child component is already watching the title property, my guess is that it should see the value change and re-render even when inside the parent template.
If this is not the case, and I need to manually re-render the parent html, i would love to know why and how to do it correctly:
requestUpdate()
manually?static get properties()
method of the parent component, and pass that property to the child component?Are there other better solutions to this problem?
Thanks
Steps to Reproduce.
es.
<child-component title="${this._privateVariable}"></child-component>
Expected Results
The child component should see the property has changed and re-render accordingly.
Actual Results
The child component does not re-render, unless manually calling
requestUpdate()
from the parent component, or unless the private property is placed in the object returned by LitElementstatic get getProperty()
method of the parent component.Browsers Affected
Versions
The text was updated successfully, but these errors were encountered: