useSelector results memory leak in child component
See original GitHub issueusing this in parent component and back-forth to page, left memory uncleaned. without useselector issue is fixed.:
export function RegisterScreenFooter () {
let footerState = useSelector((state: registration) => state.registration.footer);
https://stackoverflow.com/questions/62622168/useselector-results-memory-leak-in-child-component
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Cleanup memory leaks on an Unmounted Component in ...
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
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 >[Solved]-Can a Redux store lead to a memory leak?-Reactjs
Assuming you are following the recommended approaches for updating data, old data references are discarded and will be garbage-collected. Redux itself does not ......
Read more >How to connect Redux Store components with useSelector ...
We've broken down the best practices on how to properly connect all functional components to the Redux Store with the help of useSelector...
Read more >React state update on an unmounted component - debuggr.io
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...
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
Yes,
this.unsubscribe()
is the right line.A
Subscription
instance will be subscribed to either the Redux store directly, or its nearestSubscription
ancestor. So, per these lines,this.unsubscribe
is the subscription cleanup function that was either returned fromstore.subscribe()
, orparentSub.addNestedSub()
:https://github.com/reduxjs/react-redux/blob/a9235530f4799dd4b2acb3cc65e9caf32efbc44b/src/utils/Subscription.js#L105-L107
@LaxmanPache123 you should be doing
const permissions = useSelector((state) => { return state.user.permissions; });
but either way that will just lead to more rerenders, not to a memory leak. It is highly unlikely that that line is causing any kind of leak, but if it does: please read the comment above yours.Without any reproduction (a runnable repository where we can see it happening) we cannot do anything about this.