Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/KLineChartPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Logo = (
)

export default class KLineChartPro implements ChartPro {
private _disposeFn?: () => void;
constructor (options: ChartProOptions) {
if (utils.isString(options.container)) {
this._container = document.getElementById(options.container as string)
Expand All @@ -41,7 +42,7 @@ export default class KLineChartPro implements ChartPro {
this._container.classList.add('klinecharts-pro')
this._container.setAttribute('data-theme', options.theme ?? 'light')

render(
this._disposeFn = render(
() => (
<ChartProComponent
ref={(chart: ChartPro) => { this._chartApi = chart }}
Expand Down Expand Up @@ -128,4 +129,8 @@ export default class KLineChartPro implements ChartPro {
getPeriod (): Period {
return this._chartApi!.getPeriod()
}

dispose(): void {
this._disposeFn?.();
}
}