@@ -27,8 +27,6 @@ import {doesFiberContain} from 'react-reconciler/src/ReactFiberTreeReflection';
2727import ReactSharedInternals from 'shared/ReactSharedInternals' ;
2828import getComponentNameFromType from 'shared/getComponentNameFromType' ;
2929
30- import ReactNativeFiberHostComponent from './ReactNativeFiberHostComponent' ;
31-
3230const ReactCurrentOwner = ReactSharedInternals . ReactCurrentOwner ;
3331
3432export function findHostInstance_DEPRECATED < TElementType : ElementType > (
@@ -234,25 +232,6 @@ export function isChildPublicInstance(
234232 childInstance : FabricPublicInstance | PaperPublicInstance ,
235233) : boolean {
236234 if ( __DEV__ ) {
237- // Paper
238- if (
239- parentInstance instanceof ReactNativeFiberHostComponent ||
240- childInstance instanceof ReactNativeFiberHostComponent
241- ) {
242- if (
243- parentInstance instanceof ReactNativeFiberHostComponent &&
244- childInstance instanceof ReactNativeFiberHostComponent
245- ) {
246- return doesFiberContain (
247- parentInstance . _internalFiberInstanceHandleDEV ,
248- childInstance . _internalFiberInstanceHandleDEV ,
249- ) ;
250- }
251-
252- // Means that one instance is from Fabric and other is from Paper.
253- return false ;
254- }
255-
256235 const parentInternalInstanceHandle =
257236 // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
258237 getInternalInstanceHandleFromPublicInstance ( parentInstance ) ;
@@ -271,6 +250,24 @@ export function isChildPublicInstance(
271250 ) ;
272251 }
273252
253+ // Paper
254+ if (
255+ // $FlowExpectedError[incompatible-type]
256+ // $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
257+ parentInstance . _internalFiberInstanceHandleDEV &&
258+ // $FlowExpectedError[incompatible-type]
259+ // $FlowExpectedError[prop-missing] Don't check via `instanceof ReactNativeFiberHostComponent`, so it won't be leaked to Fabric.
260+ childInstance . _internalFiberInstanceHandleDEV
261+ ) {
262+ return doesFiberContain (
263+ // $FlowExpectedError[incompatible-call]
264+ parentInstance . _internalFiberInstanceHandleDEV ,
265+ // $FlowExpectedError[incompatible-call]
266+ childInstance . _internalFiberInstanceHandleDEV ,
267+ ) ;
268+ }
269+
270+ // Means that one instance is from Fabric and other is from Paper.
274271 return false ;
275272 } else {
276273 throw new Error ( 'isChildPublicInstance() is not available in production.' ) ;
0 commit comments