Skip to content

Commit

Permalink
fix: @radix-ui/react-presence memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ggallon committed Dec 9, 2024
1 parent cd63ace commit 9c07a58
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
"postcss": "8.4.49",
"swr": "2.2.6-beta.4",
"use-sync-external-store": "1.4.0"
},
"patchedDependencies": {
"@radix-ui/[email protected]": "patches/@[email protected]"
}
}
}
34 changes: 34 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/dist/index.js b/dist/index.js
index 5d139c059b54dd3a6578121a95386241e82c87c7..741e7250d91d95c4fd94ac7b11d5f8c342255694 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -145,7 +145,11 @@ function usePresence(present) {
return {
isPresent: ["mounted", "unmountSuspended"].includes(state),
ref: React2.useCallback((node2) => {
- if (node2) stylesRef.current = getComputedStyle(node2);
+ if (node2) {
+ stylesRef.current = getComputedStyle(node2);
+ } else {
+ stylesRef.current = {};
+ }
setNode(node2);
}, [])
};
diff --git a/dist/index.mjs b/dist/index.mjs
index 5ab5280818c2471068756b1122c11463b5e19a18..03073875f284f40abf15c72c7fea2292ee63e518 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -110,7 +110,11 @@ function usePresence(present) {
return {
isPresent: ["mounted", "unmountSuspended"].includes(state),
ref: React2.useCallback((node2) => {
- if (node2) stylesRef.current = getComputedStyle(node2);
+ if (node2) {
+ stylesRef.current = getComputedStyle(node2);
+ } else {
+ stylesRef.current = {} as any;
+ }
setNode(node2);
}, [])
};
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c07a58

Please sign in to comment.