Dont create new array on every render (#5177)

This commit is contained in:
Bram Kragten 2020-03-12 21:02:05 +01:00 committed by GitHub
parent 785ae4a83d
commit 669ed5cb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,12 +15,15 @@ import "../../../components/map/ha-map";
import { HomeAssistant } from "../../../types";
import { showZoneEditor } from "../../../data/zone";
import { fireEvent } from "../../../common/dom/fire_event";
import memoizeOne from "memoize-one";
@customElement("more-info-person")
class MoreInfoPerson extends LitElement {
@property() public hass!: HomeAssistant;
@property() public stateObj?: HassEntity;
private _entityArray = memoizeOne((entityId: string) => [entityId]);
protected render(): TemplateResult {
if (!this.hass || !this.stateObj) {
return html``;
@ -35,7 +38,7 @@ class MoreInfoPerson extends LitElement {
? html`
<ha-map
.hass=${this.hass}
.entities=${[this.stateObj.entity_id]}
.entities=${this._entityArray(this.stateObj.entity_id)}
></ha-map>
`
: ""}