File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,11 @@ export class DynamicStyleSheet {
81
81
if ( ! canUseDOM ) {
82
82
debug ( 'unsubscribing from mql' ) ;
83
83
mql . forEach ( mq => mq . unsubscribe ( ) ) ;
84
+ // @ts -expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55354
85
+ subscription . remove ( ) ;
86
+ } else {
87
+ Appearance . removeChangeListener ( appearanceListener ) ;
84
88
}
85
-
86
- // @ts -expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55354
87
- subscription . remove ( ) ;
88
89
} ;
89
90
} , [ ] ) ;
90
91
Original file line number Diff line number Diff line change 1
1
import { Dimensions , ScaledSize } from 'react-native' ;
2
2
import { useEffect , useRef , useState } from 'react' ;
3
+ import { canUseDOM } from '../utils/utils' ;
3
4
4
5
/**
5
6
* Use some value derived from dimensions.
@@ -26,8 +27,14 @@ export const useDerivedValue = <T>(func: DerivedFunc<T>): T => {
26
27
27
28
const subscription = Dimensions . addEventListener ( 'change' , listener ) ;
28
29
29
- // @ts -expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55354
30
- return subscription . remove ;
30
+ return ( ) => {
31
+ if ( ! canUseDOM ) {
32
+ // @ts -expect-error https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55354
33
+ subscription . remove ( ) ;
34
+ } else {
35
+ Dimensions . removeEventListener ( 'change' , listener ) ;
36
+ }
37
+ } ;
31
38
} , [ ] ) ;
32
39
33
40
return valueRef . current ;
You can’t perform that action at this time.
0 commit comments