@@ -24,6 +24,8 @@ if (__DEV__) {
2424 var ReactFiberInstrumentation = require ( 'ReactFiberInstrumentation' ) ;
2525}
2626
27+ var { findCurrentHostFiber } = require ( 'ReactFiberTreeReflection' ) ;
28+
2729type Deadline = {
2830 timeRemaining : ( ) => number
2931} ;
@@ -58,17 +60,20 @@ export type HostConfig<T, P, I, TI, C> = {
5860
5961type OpaqueNode = Fiber ;
6062
61- export type Reconciler < C , I > = {
63+ export type Reconciler < C , I , TI > = {
6264 mountContainer ( element : ReactElement < any > , containerInfo : C ) : OpaqueNode ,
6365 updateContainer ( element : ReactElement < any > , container : OpaqueNode ) : void ,
6466 unmountContainer ( container : OpaqueNode ) : void ,
6567 performWithPriority ( priorityLevel : PriorityLevel , fn : Function ) : void ,
6668
6769 // 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 ,
6974} ;
7075
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 > {
7277
7378 var { scheduleWork, performWithPriority } = ReactFiberScheduler ( config ) ;
7479
@@ -122,7 +127,7 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) :
122127
123128 performWithPriority ,
124129
125- getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | I | null ) {
130+ getPublicRootInstance ( container : OpaqueNode ) : ( ReactComponent < any , any , any > | I | TI | null ) {
126131 const root : FiberRoot = ( container . stateNode : any ) ;
127132 const containerFiber = root . current ;
128133 if ( ! containerFiber . child ) {
@@ -131,6 +136,14 @@ module.exports = function<T, P, I, TI, C>(config : HostConfig<T, P, I, TI, C>) :
131136 return containerFiber . child . stateNode ;
132137 } ,
133138
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+
134147 } ;
135148
136149} ;
0 commit comments