Skip to content

Commit

Permalink
Fixes #27292 - workaround for c3 destroy issue
Browse files Browse the repository at this point in the history
There is a known issue in react-c3js that can lead to the charts to
disappear due to some race condition during component unmounting/destroy
phase bcbcarl/react-c3js#22.

Delaying the actual destroy a bit seems to help with workarounding the
issue.
  • Loading branch information
iNecas committed Jul 12, 2019
1 parent 0b6bdc6 commit 253162e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webpack/ForemanTasks/Components/Chart/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ class C3Chart extends React.Component {

destroyChart() {
try {
this.chart = this.chart.destroy();
// A workaround for a case, where the chart might be still in transition
// phase while unmounting/destroying - destroying right away leads
// to issue described in https://github.com/bcbcarl/react-c3js/issues/22.
// Delaying the destroy a bit seems to resolve the issue.
setTimeout(this.chart.destroy, 1000);
this.chart = null;
} catch (err) {
throw new Error('Internal C3 error', err);
}
Expand Down

0 comments on commit 253162e

Please sign in to comment.