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

Fix React's StrictMode warning: unmounted component rerender #227

Merged

Conversation

luisherranz
Copy link

What

This PR fixes the warning that appears in development when using React's StrictMode, explained in more detail in #196.

It doesn't fix the memory leak that will happen in React Concurrent mode. To talk about that I will open a new issue.

Proposed changes

I have added a flag to check if a component was finally mounted or not. If the component was not mounted, we avoid calling its setState.

I have also added another flag for the case when a reaction was invalidated before the component was mounted. If I am not mistaken, this cannot happen in React right now, but it can happen in React Concurrent mode, so why not add it now.

@rolandszoke
Copy link
Member

@luisherranz Thanks for the fix! 🚀 We will merge your commits to the temp branch along with other changes, so we can make sure everything works fine (tests and build process), and eventually (probably this week) we will release it to alpha.

@rolandszoke rolandszoke self-requested a review January 25, 2021 14:44
@rolandszoke rolandszoke changed the base branch from master to temp January 25, 2021 14:45
@rolandszoke rolandszoke merged commit ccee321 into RisingStack:temp Jan 25, 2021
@luisherranz
Copy link
Author

Great, thanks 👍

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.

2 participants