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

Memory leak that causes crash #220

Open
diamond-darrell opened this issue Feb 17, 2022 · 1 comment
Open

Memory leak that causes crash #220

diamond-darrell opened this issue Feb 17, 2022 · 1 comment

Comments

@diamond-darrell
Copy link

diamond-darrell commented Feb 17, 2022

What is the current behavior?
When a user is dragging scrollbar scroller by mouse (not mouse wheel, it's important!) and the scrollbars component is being removed from the DOM it fails to properly clean event listeners which causes <DraggableCore>: Unmounted during event! error.
image

Steps to reproduce it and if possible a minimal demo of the problem.
Here's the link to an example https://codesandbox.io/s/jolly-silence-seoznl?file=/src/App.js
Steps: once the example is loaded grab the scrollbar by mouse and start dragging until timeout removes element from the dom.

What is the expected behavior?
Properly clean event handlers to prevent memory leak

A little about versions:

  • OS: MacOS Monterey
  • Browser (vendor and version): Chrome 98.0.4758.80
  • React: 17.0.2
  • react-scrollbars-custom: 4.0.27
  • Did this worked in the previous package version? Not sure, probably not

Also, verified similar scenario on the react-draggable itself, the issue is not reproduced here, so I assume it comes somewhere from react-scrollbars-custom. Here's the link for react-draggable sandbox https://codesandbox.io/s/keen-nobel-dxed5h?file=/src/App.js

@diamond-darrell
Copy link
Author

I could track it down here https://github.com/xobotyi/react-scrollbars-custom/blob/master/src/ScrollbarThumb.tsx#L55
It seems setting elementRef null here prevents DraggableCore to unsubscribe from event listeners

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

No branches or pull requests

1 participant