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
See original GitHub issueHey interesting issue - I’m redirecting a user after a sound and it looks like potentially a useEffect within use-sound isn’t returning a way to unmount. Thoughts?
const [play,] = useSound(beepSfx)
const history = useHistory()
const onBeep = useCallback(() => play())
const onCreate = useCallback(() => {
onBeep()
history.push(ROUTES.MANAGE_BRANDS)
})
Console errors:
index.js:1 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.
in WelcomeSelectPage (created by Context.Consumer)
| console.<computed> | @ | index.js:1
-- | -- | -- | --
| r | @ | react_devtools_backend.js:6
| printWarning | @ | react-dom.development.js:88
| error | @ | react-dom.development.js:60
| warnAboutUpdateOnUnmountedFiberInDEV | @ | react-dom.development.js:23192
| scheduleUpdateOnFiber | @ | react-dom.development.js:21200
| dispatchAction | @ | react-dom.development.js:15682
| (anonymous) | @ | index.ts:105
| (anonymous) | @ | howler.js:1856
| setTimeout (async) | |
| _emit | @ | howler.js:1855
| _ended | @ | howler.js:1920
| setTimeout (async) | |
| playWebAudio | @ | howler.js:843
| play | @ | howler.js:855
| (anonymous) | @ | index.ts:103
| (anonymous) | @ | select.js:37
Line 37 is onBeep declaration
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top Results From Across the Web
React useEffect causing: Can't perform a React state update ...
This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a...
Read more >How to fix the React memory leak warning - DEV Community
Warning : Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in...
Read more >How to clean up subscriptions in react components using ...
Warning : Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in...
Read more >Can't perform a React state update on an unmounted ... - Reddit
This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a...
Read more >React & useEffect cleanups - Tasos Kakouris
index.js:27 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@joshwcomeau actually got this warning as well, it occurs after navigating to another page in Gatsby. Any chance you can re-open this?
I have the same problem here
const [play, { stop }] = useSound(alertSfx);
const alertsCritical = useSelector((state) => state.alerts.alertsCritical, shallowEqual);
useEffect(() => { if (alertsCritical.length > 0) { play(); } return () => { if (alertsCritical.length > 0) { stop(); } }; }, [alertsCritical, play, stop]);