From 7aa870b457277b36a2edfe85e88d5d2cba23bc14 Mon Sep 17 00:00:00 2001 From: Shivang Kumar Date: Wed, 15 Aug 2018 12:16:30 +1000 Subject: [PATCH] Checking if legend destroy exists before clearing a chart in componentDidUnmount --- amcharts3-react.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amcharts3-react.js b/amcharts3-react.js index aa1219e..610e47e 100644 --- a/amcharts3-react.js +++ b/amcharts3-react.js @@ -269,7 +269,10 @@ console.warn("Version 1.0 is outdated. Please upgrade to version 2.0:\nhttps://g componentWillUnmount: function () { if (this.state.chart) { - this.state.chart.clear(); + var chart = this.state.chart; + if(chart.legend && chart.legend.destroy){ + chart.clear(); + } } },