5
5
* LICENSE file in the root directory of this source tree.
6
6
*
7
7
* @format
8
+ * @flow
8
9
*/
9
10
10
11
'use strict' ;
@@ -13,10 +14,10 @@ const React = require('react');
13
14
const createReactClass = require ( 'create-react-class' ) ;
14
15
const ReactNative = require ( 'react-native' ) ;
15
16
const RCTNativeAppEventEmitter = require ( 'RCTNativeAppEventEmitter' ) ;
16
- const Subscribable = require ( 'Subscribable' ) ;
17
17
const { View} = ReactNative ;
18
18
19
19
const { TestModule} = ReactNative . NativeModules ;
20
+ import type EmitterSubscription from 'EmitterSubscription' ;
20
21
21
22
const reactViewWidth = 111 ;
22
23
const reactViewHeight = 222 ;
@@ -25,16 +26,21 @@ let finalState = false;
25
26
26
27
const SizeFlexibilityUpdateTest = createReactClass ( {
27
28
displayName : 'SizeFlexibilityUpdateTest' ,
28
- mixins : [ Subscribable . Mixin ] ,
29
+ _subscription : ( null : ? EmitterSubscription ) ,
29
30
30
31
UNSAFE_componentWillMount : function ( ) {
31
- this . addListenerOn (
32
- RCTNativeAppEventEmitter ,
32
+ this . _subscription = RCTNativeAppEventEmitter . addListener (
33
33
'rootViewDidChangeIntrinsicSize' ,
34
34
this . rootViewDidChangeIntrinsicSize ,
35
35
) ;
36
36
} ,
37
37
38
+ componentWillUnmount : function ( ) {
39
+ if ( this . _subscription != null ) {
40
+ this . _subscription . remove ( ) ;
41
+ }
42
+ } ,
43
+
38
44
markPassed : function ( ) {
39
45
TestModule . markTestPassed ( true ) ;
40
46
finalState = true ;
0 commit comments