File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
packages/react/presence/src Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @radix-ui/react-presence ' : patch
3
+ ---
4
+
5
+ Fix memory leak in Presence
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ Presence.displayName = 'Presence';
31
31
32
32
function usePresence ( present : boolean ) {
33
33
const [ node , setNode ] = React . useState < HTMLElement > ( ) ;
34
- const stylesRef = React . useRef < CSSStyleDeclaration > ( { } as any ) ;
34
+ const stylesRef = React . useRef < CSSStyleDeclaration | null > ( null ) ;
35
35
const prevPresentRef = React . useRef ( present ) ;
36
36
const prevAnimationNameRef = React . useRef < string > ( 'none' ) ;
37
37
const initialState = present ? 'mounted' : 'unmounted' ;
@@ -153,15 +153,15 @@ function usePresence(present: boolean) {
153
153
return {
154
154
isPresent : [ 'mounted' , 'unmountSuspended' ] . includes ( state ) ,
155
155
ref : React . useCallback ( ( node : HTMLElement ) => {
156
- if ( node ) stylesRef . current = getComputedStyle ( node ) ;
156
+ stylesRef . current = node ? getComputedStyle ( node ) : null ;
157
157
setNode ( node ) ;
158
158
} , [ ] ) ,
159
159
} ;
160
160
}
161
161
162
162
/* -----------------------------------------------------------------------------------------------*/
163
163
164
- function getAnimationName ( styles ? : CSSStyleDeclaration ) {
164
+ function getAnimationName ( styles : CSSStyleDeclaration | null ) {
165
165
return styles ?. animationName || 'none' ;
166
166
}
167
167
You can’t perform that action at this time.
0 commit comments