Skip to content

Conversation

@6uliver
Copy link
Contributor

@6uliver 6uliver commented Mar 2, 2023

About the changes

I discovered that the event listeners are not removed properly in useFlag and useVariant. The original author's intention was correct but a return statement were missing by a mistake. It can cause "Can't perform a React state update on an unmounted component." error and unallocated resources.

Closes #90

Important files

I wrote tests first to prove the error so you should start the review with the new tests. The fix is simple, I've just added the missing returns in the implementation.

Discussion points

In the test suites I moved the mockClear calls inside the beforeEach, I think it's better to call them before every tests.

@6uliver
Copy link
Contributor Author

6uliver commented Mar 2, 2023

This fixes #90 which should be reopened as the original PR #96 had not fixed the problem.

Copy link
Contributor

@FredrikOseberg FredrikOseberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Thanks for spotting that! LGTM

@6uliver
Copy link
Contributor Author

6uliver commented Mar 3, 2023

Wow. Thanks for spotting that! LGTM

Thank you very much for your quick response!
When could you merge it and release a new version to npm?

@thomasheartman thomasheartman merged commit 62dd2fc into Unleash:main Mar 6, 2023
@thomasheartman
Copy link
Contributor

@6uliver Thanks for the contribution! It's merged now and we're aiming to get the release out some time this week 🚀 Great work 🥇

@Tymek
Copy link
Contributor

Tymek commented Mar 10, 2023

Pre-released in v3.5.3-beta.0.

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.

Leak in useFlag

4 participants