Skip to content

Commit

Permalink
fix: Mark chart with @State to prevent HMR bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Feb 25, 2019
1 parent 5e5f60f commit dc2f28b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/apex-chart/apex-chart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Prop } from '@stencil/core';
import { Component, Prop, State } from '@stencil/core';
import ApexCharts from 'apexcharts';

@Component({
Expand All @@ -8,13 +8,15 @@ import ApexCharts from 'apexcharts';
})
export class chart {
el: HTMLElement;
chart: ApexCharts = null;
@State() chart: ApexCharts = null;

@Prop() options: object = {}

componentDidLoad() {
this.chart = new ApexCharts(this.el, this.options);
return this.chart.render();
if (this.chart === null) {
this.chart = new ApexCharts(this.el, this.options);
return this.chart.render();
}
}

componentDidUnload() {
Expand Down

0 comments on commit dc2f28b

Please sign in to comment.