Is it possible to somehow trigger component re-render when the property of the observed object changes? I know that the component will re-render if I replace the object but it does not when I just change its property
class SomeComponent extends LitElement {
static get properties() {
return {
obj: { type: Object, reflect: true }
}
}
constructor() {
super();
this.obj = {
value: 'value'
};
}
handleClick(value) {
this.obj.value = value;
}
render() {
return html `
<div>
<p>My Value: ${this.obj.value}</p>
<button @click="${() => this.handleClick('new value')}">Button</button>
</div>
`;
}
}
customElements.define('some-component', SomeComponent);
Tried to use this.requestUpdate()
and it works, but i am not sure if such solution is optimized