Skip to content

Commit b1e1e10

Browse files
committed
fix: add isChildPublicInstance to ReactNativeTypes
1 parent 223db40 commit b1e1e10

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/react-native-renderer/src/ReactNativePublicCompat.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
* @flow
88
*/
99

10-
import type {Node, HostComponent} from './ReactNativeTypes';
11-
import type {PublicInstance as FabricPublicInstance} from './ReactFiberConfigFabric';
12-
import type {PublicInstance as PaperPublicInstance} from './ReactFiberConfigNative';
10+
import type {Node, HostComponent, PublicInstance} from './ReactNativeTypes';
1311
import type {ElementRef, ElementType} from 'react';
1412

1513
// Modules provided by RN:
@@ -225,6 +223,11 @@ export function getNodeFromInternalInstanceHandle(
225223
);
226224
}
227225

226+
// Should have been PublicInstance from ReactFiberConfigFabric
227+
type FabricPublicInstance = PublicInstance;
228+
// Should have been PublicInstance from ReactFiberConfigNative
229+
type PaperPublicInstance = HostComponent<mixed>;
230+
228231
// Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.
229232
export function isChildPublicInstance(
230233
parentInstance: FabricPublicInstance | PaperPublicInstance,
@@ -251,8 +254,10 @@ export function isChildPublicInstance(
251254
}
252255

253256
const parentInternalInstanceHandle =
257+
// $FlowExpectedError[incompatible-call] PublicInstance from ReactNativeTypes is opaque, treat it as PublicInstance from ReactFiberConfigFabric.
254258
getInternalInstanceHandleFromPublicInstance(parentInstance);
255259
const childInternalInstanceHandle =
260+
// $FlowExpectedError[incompatible-call] PublicInstance from ReactNativeTypes is opaque, treat it as PublicInstance from ReactFiberConfigFabric.
256261
getInternalInstanceHandleFromPublicInstance(childInstance);
257262

258263
// Fabric

packages/react-native-renderer/src/ReactNativeTypes.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export type ReactNativeType = {
191191
findNodeHandle<TElementType: ElementType>(
192192
componentOrHandle: ?(ElementRef<TElementType> | number),
193193
): ?number,
194+
isChildPublicInstance(
195+
parent: HostComponent<mixed>,
196+
child: HostComponent<mixed>,
197+
): boolean,
194198
dispatchCommand(
195199
handle: ElementRef<HostComponent<mixed>>,
196200
command: string,
@@ -214,7 +218,7 @@ export type ReactNativeType = {
214218

215219
export opaque type Node = mixed;
216220
export opaque type InternalInstanceHandle = mixed;
217-
type PublicInstance = mixed;
221+
export opaque type PublicInstance = mixed;
218222
type PublicTextInstance = mixed;
219223

220224
export type ReactFabricType = {
@@ -229,6 +233,7 @@ export type ReactFabricType = {
229233
command: string,
230234
args: Array<mixed>,
231235
): void,
236+
isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
232237
sendAccessibilityEvent(
233238
handle: ElementRef<HostComponent<mixed>>,
234239
eventType: string,

0 commit comments

Comments
 (0)