cerebral / overmind

Overmind - Frictionless state management
https://overmindjs.org
MIT License
1.58k stars 95 forks source link

Fix bug with unmounted component when working in development mode #545

Closed LarsFlieger closed 2 years ago

LarsFlieger commented 2 years ago

There is a bug while working in the development mode when components unmount:

Minimum reproduction code: https://github.com/dopeshot/ionic-overmind-cant-perform-state-update

How to reproduce:

  1. Go to the other page
  2. Increase the count (modify state)
  3. Go back to main page
  4. Increase the count (modify state) ==> Go to console and there is the error
    Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

Video of the issue: https://www.youtube.com/watch?v=5w6r1_lxoS8

StackOverflow discussion: https://stackoverflow.com/questions/70744871/ionic-react-overmind-cant-perform-a-react-state-update-on-an-unmounted-componen

Branchverse commented 2 years ago

I highly appreciate this, so simple yet so useful, this saved my day!!!

LarsFlieger commented 2 years ago

Looks good to me. Would you be able to add a test to prevent regression?

Thank you! I'm going to add them as soon as I got time. :)

henri-hulski commented 2 years ago

@LarsFlieger Are you still planning to add the test? If not I would merge it as it is.

LarsFlieger commented 2 years ago

@LarsFlieger Are you still planning to add the test? If not I would merge it as it is.

I'm currently very busy. I'll come back to this when I got time. So feel free to merge it :)

henri-hulski commented 2 years ago

Ok. Done! You can get it by installing overmind-react@next. 😊

fmal commented 2 years ago

thanks for the fix @LarsFlieger and @henri-hulski for merging 👍 Just run into this issue, so perfect timing

fmal commented 2 years ago

@henri-hulski seems like this didn't get published as overmind-react@next. The last published version on next channel was: https://www.npmjs.com/package/overmind-react/v/29.0.1-1624784835264 few months ago

fmal commented 2 years ago

https://app.travis-ci.com/github/cerebral/overmind/builds/246438851#L4463

ERR! publish Failed PUT 401\n\nnpm \nERR! code E401\n\nnpm ERR! This operation requires a one-time password from your authenticator

seems like a new "automation" NPM access token needs to be added to CI

jonsherrard commented 2 years ago

@henri-hulski is it possible to update the CI token, or manually publish this fix?

henri-hulski commented 2 years ago

I think @anna-bucher is in contact with @christianalfoni to change the access rights. After I will be able to publish. For updates follow the #random channel on Discord.