gantt icon indicating copy to clipboard operation
gantt copied to clipboard

Gantt chart click listener event issue or bug

Open sisardor opened this issue 8 years ago • 1 comments

When used in reactjs gantt chart add button fires multiple time when component updates or router changes, I have only one instance of gantt but it fires multiple time anywhere, older version of gantt chart doesn't do that

sisardor avatar Feb 22 '18 01:02 sisardor

Hi, it probably has to do with event handlers being attached on componentDidMount and never detached. So after a component has been mounted for the second time your handlers will be duplicated.

As a solution, you'll need to set some flag and attach event handlers only once as shown here https://dhtmlx.com/blog/create-react-gantt-chart-component-dhtmlxgantt/#comment-196907 I'll try to update the react demo repo and an article in the nearest time

Starting from dhtmlxgantt v5.1 a gantt instance will have a destructor method, so you'll be able to create a new instance of gantt in componentDidMount and destroy it in componentWillUnmount and not have such issue.

AlexKlimenkov avatar Feb 22 '18 13:02 AlexKlimenkov