Skip to content

Commit

Permalink
fix: add isChildPublicInstance to ReactNativeTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxyq committed Dec 5, 2023
1 parent 223db40 commit 55a31ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react-native-renderer/src/ReactNativePublicCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*/

import type {Node, HostComponent} from './ReactNativeTypes';
import type {PublicInstance as FabricPublicInstance} from './ReactFiberConfigFabric';
import type {PublicInstance as PaperPublicInstance} from './ReactFiberConfigNative';
import type {ElementRef, ElementType} from 'react';

// Modules provided by RN:
Expand Down Expand Up @@ -225,6 +223,11 @@ export function getNodeFromInternalInstanceHandle(
);
}

// Should have been PublicInstance from ReactFiberConfigFabric
type FabricPublicInstance = mixed;
// Should have been PublicInstance from ReactFiberConfigNative
type PaperPublicInstance = HostComponent<mixed>;

// Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.
export function isChildPublicInstance(
parentInstance: FabricPublicInstance | PaperPublicInstance,
Expand All @@ -251,8 +254,10 @@ export function isChildPublicInstance(
}

const parentInternalInstanceHandle =
// $FlowExpectedError[incompatible-call] PublicInstance from ReactNativeTypes is opaque, treat it as PublicInstance from ReactFiberConfigFabric.
getInternalInstanceHandleFromPublicInstance(parentInstance);
const childInternalInstanceHandle =
// $FlowExpectedError[incompatible-call] PublicInstance from ReactNativeTypes is opaque, treat it as PublicInstance from ReactFiberConfigFabric.
getInternalInstanceHandleFromPublicInstance(childInstance);

// Fabric
Expand Down
5 changes: 5 additions & 0 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ export type ReactNativeType = {
findNodeHandle<TElementType: ElementType>(
componentOrHandle: ?(ElementRef<TElementType> | number),
): ?number,
isChildPublicInstance(
parent: PublicInstance | HostComponent<mixed>,
child: PublicInstance | HostComponent<mixed>,
): boolean,
dispatchCommand(
handle: ElementRef<HostComponent<mixed>>,
command: string,
Expand Down Expand Up @@ -229,6 +233,7 @@ export type ReactFabricType = {
command: string,
args: Array<mixed>,
): void,
isChildPublicInstance(parent: PublicInstance, child: PublicInstance): boolean,
sendAccessibilityEvent(
handle: ElementRef<HostComponent<mixed>>,
eventType: string,
Expand Down

0 comments on commit 55a31ac

Please sign in to comment.