Skip to content

Commit 9c07a58

Browse files
committed
fix: @radix-ui/react-presence memory leak
radix-ui/primitives#3234
1 parent cd63ace commit 9c07a58

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
"postcss": "8.4.49",
9595
"swr": "2.2.6-beta.4",
9696
"use-sync-external-store": "1.4.0"
97+
},
98+
"patchedDependencies": {
99+
"@radix-ui/[email protected]": "patches/@[email protected]"
97100
}
98101
}
99102
}

patches/@[email protected]

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/dist/index.js b/dist/index.js
2+
index 5d139c059b54dd3a6578121a95386241e82c87c7..741e7250d91d95c4fd94ac7b11d5f8c342255694 100644
3+
--- a/dist/index.js
4+
+++ b/dist/index.js
5+
@@ -145,7 +145,11 @@ function usePresence(present) {
6+
return {
7+
isPresent: ["mounted", "unmountSuspended"].includes(state),
8+
ref: React2.useCallback((node2) => {
9+
- if (node2) stylesRef.current = getComputedStyle(node2);
10+
+ if (node2) {
11+
+ stylesRef.current = getComputedStyle(node2);
12+
+ } else {
13+
+ stylesRef.current = {};
14+
+ }
15+
setNode(node2);
16+
}, [])
17+
};
18+
diff --git a/dist/index.mjs b/dist/index.mjs
19+
index 5ab5280818c2471068756b1122c11463b5e19a18..03073875f284f40abf15c72c7fea2292ee63e518 100644
20+
--- a/dist/index.mjs
21+
+++ b/dist/index.mjs
22+
@@ -110,7 +110,11 @@ function usePresence(present) {
23+
return {
24+
isPresent: ["mounted", "unmountSuspended"].includes(state),
25+
ref: React2.useCallback((node2) => {
26+
- if (node2) stylesRef.current = getComputedStyle(node2);
27+
+ if (node2) {
28+
+ stylesRef.current = getComputedStyle(node2);
29+
+ } else {
30+
+ stylesRef.current = {} as any;
31+
+ }
32+
setNode(node2);
33+
}, [])
34+
};

pnpm-lock.yaml

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)