Skip to content

Commit

Permalink
fix: add isChildPublicInstance to ReactNativeTypes (#27788)
Browse files Browse the repository at this point in the history
Follow-up on #27783.

React Native is actually using `ReactNativeTypes`, which are synced from
this repo. In order to make `isChildPublicInstance` visible for
renderers inside React Native repository, we need to list it in
`ReactNativeTypes`.

Because of current circular dependency between React Native and React,
it is impossible to actually type it properly:
- Can't import any types in `ReactNativeTypes` from local files, because
it will break React Native, once synced.
- Implementations can't use real types in their definitions, because it
will break these checks:

https://github.com/facebook/react/blob/223db40d5a04dc3311f963f5296675f7f43139e8/packages/react-native-renderer/fabric.js#L12-L13

https://github.com/facebook/react/blob/223db40d5a04dc3311f963f5296675f7f43139e8/packages/react-native-renderer/index.js#L12-L14

DiffTrain build for commit c29ca23.
  • Loading branch information
hoxyq committed Dec 5, 2023
1 parent de3fc70 commit 56c0aff
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25474,7 +25474,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-5ab6bbb4b-20231204";
var ReactVersion = "18.3.0-canary-c29ca23af-20231205";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9083,7 +9083,7 @@ var devToolsConfig$jscomp$inline_1033 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-5ab6bbb4b-20231204",
version: "18.3.0-canary-c29ca23af-20231205",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1226 = {
Expand Down Expand Up @@ -9114,7 +9114,7 @@ var internals$jscomp$inline_1226 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-5ab6bbb4b-20231204"
reconcilerVersion: "18.3.0-canary-c29ca23af-20231205"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1227 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9509,7 +9509,7 @@ var devToolsConfig$jscomp$inline_1075 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-5ab6bbb4b-20231204",
version: "18.3.0-canary-c29ca23af-20231205",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1267 = {
Expand Down Expand Up @@ -9540,7 +9540,7 @@ var internals$jscomp$inline_1267 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-5ab6bbb4b-20231204"
reconcilerVersion: "18.3.0-canary-c29ca23af-20231205"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1268 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (__DEV__) {
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = "18.3.0-canary-5ab6bbb4b-20231204";
var ReactVersion = "18.3.0-canary-c29ca23af-20231205";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-5ab6bbb4b-20231204";
exports.version = "18.3.0-canary-c29ca23af-20231205";
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-5ab6bbb4b-20231204";
exports.version = "18.3.0-canary-c29ca23af-20231205";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5ab6bbb4b058e22658fc6d4734db5acfbf393345
c29ca23af91d8aeb9e175c08a0866ba54286f0f3
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<685bf7c576463dfbb4cf704d94b8c71b>>
* @generated SignedSource<<86b0cafe89bf505872d503a476664cf5>>
*/

"use strict";
Expand Down Expand Up @@ -27829,7 +27829,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "18.3.0-canary-ad95fe0f";
var ReactVersion = "18.3.0-canary-e53565aa";

function createPortal$1(
children,
Expand Down Expand Up @@ -28711,7 +28711,9 @@ to return true:wantsResponderID| |
internalInstanceHandle.stateNode && // $FlowExpectedError[incompatible-use]
internalInstanceHandle.stateNode.node
);
} // Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.
} // Should have been PublicInstance from ReactFiberConfigFabric
// Should have been PublicInstance from ReactFiberConfigNative
// Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.

function isChildPublicInstance(parentInstance, childInstance) {
{
Expand All @@ -28733,11 +28735,11 @@ to return true:wantsResponderID| |
return false;
}

var parentInternalInstanceHandle =
var parentInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
parentInstance
);
var childInternalInstanceHandle =
var childInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for childInstance should have been PublicInstance from ReactFiberConfigFabric.
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
childInstance
); // Fabric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d24e5265ff25936497dfc29885a7ed06>>
* @generated SignedSource<<d78568faa845f2ded9fe23a625f144a4>>
*/

"use strict";
Expand Down Expand Up @@ -28270,7 +28270,7 @@ to return true:wantsResponderID| |
return root;
}

var ReactVersion = "18.3.0-canary-6d7633fe";
var ReactVersion = "18.3.0-canary-07e71c82";

function createPortal$1(
children,
Expand Down Expand Up @@ -28994,7 +28994,9 @@ to return true:wantsResponderID| |
internalInstanceHandle.stateNode && // $FlowExpectedError[incompatible-use]
internalInstanceHandle.stateNode.node
);
} // Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.
} // Should have been PublicInstance from ReactFiberConfigFabric
// Should have been PublicInstance from ReactFiberConfigNative
// Remove this once Paper is no longer supported and DOM Node API are enabled by default in RN.

function isChildPublicInstance(parentInstance, childInstance) {
{
Expand All @@ -29016,11 +29018,11 @@ to return true:wantsResponderID| |
return false;
}

var parentInternalInstanceHandle =
var parentInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for parentInstance should have been PublicInstance from ReactFiberConfigFabric.
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
parentInstance
);
var childInternalInstanceHandle =
var childInternalInstanceHandle = // $FlowExpectedError[incompatible-call] Type for childInstance should have been PublicInstance from ReactFiberConfigFabric.
ReactNativePrivateInterface.getInternalInstanceHandleFromPublicInstance(
childInstance
); // Fabric
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noformat
* @flow strict
* @nolint
* @generated SignedSource<<1836a1b6639552dce12199ef2c85f63d>>
* @generated SignedSource<<30640e7dd83e22e14db1648ca63f4316>>
*/

import type {ElementRef, ElementType, Element, AbstractComponent} from 'react';
Expand Down Expand Up @@ -193,6 +193,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 @@ -231,6 +235,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 56c0aff

Please sign in to comment.