Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart initialized in unmounted component #3725

Closed
mpressmar opened this issue Nov 30, 2022 · 1 comment · Fixed by #3724
Closed

Chart initialized in unmounted component #3725

mpressmar opened this issue Nov 30, 2022 · 1 comment · Fixed by #3724
Assignees
Labels
React 18/19 Issue or pull request is *only* related to React 18/19 Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@mpressmar
Copy link
Contributor

Describe the bug

The initChart method will in some case asynchronously create a chart object (after loading chart.js/auto). If during the asynchronous process the Chart component was already unmounted, the Chart will still be created, but for a null canvas. As a consequence, a zombie Chart is created that is never cleaned up.

Context/Usage

We have a simple usage of a line chart, which is rendered for each detail of a master-detail view. That means switching the selection between the entries in the master view will each time unmount the Chart component and then create a new one with different curve data.

The mentioned issue can be provoked already with a minimal Chart as this (but also with actual configuration and data):

        <Chart
               type="line"
               data={{labels: [], datasets: []}}
               options={{}}/>

Issue

Oftentimes we see these two errors in the log while switching from one detail to the other:

image

image

Reproducer

No response

PrimeReact version

8.7.2

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@mpressmar mpressmar added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 30, 2022
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 30, 2022
@melloware melloware added this to the 8.7.3 milestone Nov 30, 2022
@melloware melloware linked a pull request Nov 30, 2022 that will close this issue
@melloware
Copy link
Member

Thank you for the detailed description and the PR!

@melloware melloware added the React 18/19 Issue or pull request is *only* related to React 18/19 label Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React 18/19 Issue or pull request is *only* related to React 18/19 Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants