🔧 Remove unnecessary re-renders (#3014)

* 🔧 Remove unnecessary re-renders

* address review comments

* address review comments
This commit is contained in:
Ian Richardson
2019-03-26 00:18:16 -05:00
committed by GitHub
parent 669358bf1a
commit 004892e11a
23 changed files with 163 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import {
CSSResult,
css,
customElement,
PropertyValues,
} from "lit-element";
import "../components/hui-generic-entity-row";
@@ -14,6 +15,7 @@ import "../components/hui-warning";
import computeStateDisplay from "../../../common/entity/compute_state_display";
import { HomeAssistant } from "../../../types";
import { EntityRow, EntityConfig } from "./types";
import { hasConfigOrEntityChanged } from "../common/has-changed";
@customElement("hui-text-entity-row")
class HuiTextEntityRow extends LitElement implements EntityRow {
@@ -28,6 +30,10 @@ class HuiTextEntityRow extends LitElement implements EntityRow {
this._config = config;
}
protected shouldUpdate(changedProps: PropertyValues): boolean {
return hasConfigOrEntityChanged(this, changedProps);
}
protected render(): TemplateResult | void {
if (!this._config || !this.hass) {
return html``;