Skip to content

Facing "this.legend.destroy is not a function" when component unmounts #79

Description

@shivangkumar

Context:

One of the pages of the app I am working on has a list of components displaying some sort of data. Each list item makes a request for data to an API and uses the response to make a chart. Users can switch to different tabs on the page (implemented using react router) that show different dashboards.

Issue:

There seems to be somewhat of a race condition. When the user opens the page with the charts while the data is being loaded from the API, if the user switches to a different tab then it is possible that though the legend exists as a part of the chart object, the destroy method has not been assigned yet.

Consequences:

As a result, when switching to a different page the console shows the following error:
TypeError: this.legend.destroy is not a function

image

Solution

I was able to bypass the issue by using a simple check before clearing the chart and made the pull request here

@Pauan @amcharts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions