Skip to content

Commit

Permalink
fix unmount logic. fixes #247
Browse files Browse the repository at this point in the history
  • Loading branch information
maslianok committed Dec 23, 2023
1 parent a5a729b commit 45bcedb
Show file tree
Hide file tree
Showing 3 changed files with 825 additions and 520 deletions.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^11.1.1",
"@types/lodash": "^4.14.194",
"@types/react": "^18.2.7",
"@types/react-dom": "^18.2.4",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"@rollup/plugin-typescript": "^11.1.0",
"@types/lodash": "^4.14.192",
"@types/react": "^18.0.33",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.37.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"prettier": "^2.8.8",
"rollup": "^3.23.0",
"rollup-plugin-node-externals": "^6.0.1",
"prettier": "^3.1.1",
"rollup": "^4.9.1",
"rollup-plugin-node-externals": "^6.1.2",
"tslib": "^2.6.2",
"typescript": "^5.0.4"
},
"peerDependencies": {
Expand Down
9 changes: 0 additions & 9 deletions src/useResizeDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ function useResizeDetector<T extends HTMLElement = any>({
// adding `current` to make it compatible with useRef shape
onRefChange.current = refElement;

useEffect(() => {
return () => {
// component is unmounted
// clear ref to avoid memory leaks
setRefElement(null);
onRefChange.current = null;
};
}, []);

const shouldSetSize = useCallback(
(prevSize: ReactResizeDetectorDimensions, nextSize: ReactResizeDetectorDimensions) => {
if (prevSize.width === nextSize.width && prevSize.height === nextSize.height) {
Expand Down
Loading

0 comments on commit 45bcedb

Please sign in to comment.