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

[Tooltip] Prevent state change on unmounted component #2827

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hanselabreu
Copy link

Description

This pull request addresses an issue where the Tooltip attempts to set state on an unmounted component, leading to potential memory leaks and unexpected behavior.

Issue:

Currently the Tooltip attempts to update its state even after it has been unmounted. This results in warnings in the console and can lead to unpredictable behavior, particularly in asynchronous operations.

Proposed Solution:

To fix this issue, I have implemented a check to ensure that state is only updated if the component is still mounted. This is achieved by utilizing a boolean flag (isMountedRef) to track the mounted state of the component. When the component is unmounted, this flag is set to false, preventing any state updates.

@lucaspolizeli
Copy link

Good catch. I'm facing the warnings you mentioned, and I probably think this is the reason.

@fslc92
Copy link

fslc92 commented Apr 10, 2024

+1

1 similar comment
@dajs3010
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants