Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Removed resize event listener to avoid event triggering from an unmounted component #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Splitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ var Splitter = /** @class */ (function (_super) {
window.addEventListener('resize', this.getSize);
}
};
Splitter.prototype.componentWillUnmount = function () {
/********************************
* Remove event listeners after component is mounted.
* We need to remove the event listener to avoid triggering from an unmounted component
********************************/
window.removeEventListener('resize', this.getSize);
};
Splitter.prototype.render = function () {
var _this = this;
var _a;
Expand Down
8 changes: 8 additions & 0 deletions src/components/Splitters/Splitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export class Splitter extends React.Component<SplitterProps, SplitterState> {
}
}

componentWillUnmount() {
/********************************
* Remove event listeners after component is mounted.
* We need to remove the event listener to avoid triggering from an unmounted component
********************************/
window.removeEventListener('resize', this.getSize);
}

handleMouseDown = (e: any) => {
/********************************
* If the right button was clicked - stop the function
Expand Down