@@ -24,6 +24,8 @@ if (__DEV__) {
24
24
var ReactFiberInstrumentation = require ( 'ReactFiberInstrumentation' ) ;
25
25
}
26
26
27
+ var { findCurrentHostFiber } = require ( 'ReactFiberTreeReflection' ) ;
28
+
27
29
type Deadline = {
28
30
timeRemaining : ( ) => number
29
31
} ;
@@ -58,17 +60,20 @@ export type HostConfig<T, P, I, TI, C> = {
58
60
59
61
type OpaqueNode = Fiber ;
60
62
61
- export type Reconciler < C , I > = {
63
+ export type Reconciler < C , I , TI > = {
62
64
mountContainer ( element : ReactElement < any > , containerInfo : C ) : OpaqueNode ,
63
65
updateContainer ( element : ReactElement < any > , container : OpaqueNode ) : void ,
64
66
unmountContainer ( container : OpaqueNode ) : void ,
65
67
performWithPriority ( priorityLevel : PriorityLevel , fn : Function ) : void ,
66
68
67
69
// Used to extract the return value from the initial render. Legacy API.
68
- getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | I | null ) ,
70
+ getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | TI | I | null ) ,
71
+
72
+ // Use for findDOMNode/findHostNode. Legacy API.
73
+ findHostInstance ( component : ReactComponent < any , any, any > ) : I | TI | null ,
69
74
} ;
70
75
71
- module . exports = function < T , P , I , TI , C > ( config : HostConfig < T , P , I , TI , C > ) : Reconciler < C , I > {
76
+ module . exports = function < T , P , I , TI , C > ( config : HostConfig < T , P , I , TI , C > ) : Reconciler < C , I , TI > {
72
77
73
78
var { scheduleWork, performWithPriority } = ReactFiberScheduler ( config ) ;
74
79
@@ -122,7 +127,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) :
122
127
123
128
performWithPriority ,
124
129
125
- getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | I | null ) {
130
+ getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | I | TI | null ) {
126
131
const root : FiberRoot = ( container . stateNode : any ) ;
127
132
const containerFiber = root . current ;
128
133
if ( ! containerFiber . child ) {
@@ -131,6 +136,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) :
131
136
return containerFiber . child . stateNode ;
132
137
} ,
133
138
139
+ findHostInstance ( component : ReactComponent < any , any , any > ) : I | TI | null {
140
+ const fiber = findCurrentHostFiber ( component ) ;
141
+ if ( ! fiber ) {
142
+ return null ;
143
+ }
144
+ return fiber . stateNode ;
145
+ } ,
146
+
134
147
} ;
135
148
136
149
} ;
0 commit comments