omnibar icon indicating copy to clipboard operation
omnibar copied to clipboard

Handle componentWillUnmount

Open jondavidjohn opened this issue 4 years ago • 0 comments

First, this is a great component, thanks for sharing it!

I'm writing some simple specs using @testing-library/react and I'm getting this warning:

  console.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 the componentWillUnmount method.
        at Omnibar (/Users/.../node_modules/omnibar/dist/index.js:224:28)
        at Omnisearch

      at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
      at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
      at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23914:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21840:5)
      at Object.enqueueSetState (node_modules/react-dom/cjs/react-dom.development.js:12467:5)
      at Omnibar.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:365:16)
      at node_modules/omnibar/dist/index.js:234:27

In doing some research, it looks like this may be of help => https://www.robinwieruch.de/react-warning-cant-call-setstate-on-an-unmounted-component

Does it look like maybe the component continues to get state updates after it is unmounted?

jondavidjohn avatar Dec 06 '20 04:12 jondavidjohn