Skip to content

Commit 2100254

Browse files
Ruslan Lesiutinfacebook-github-bot
Ruslan Lesiutin
authored andcommitted
feat[ReactFabricPrivateInterface]: add getInternalInstanceHandleFromPublicInstance (facebook#41786)
Summary: Changelog: [Internal] This is the preprequisite for facebook/react#27783 Reviewed By: rubennorte Differential Revision: D51808831
1 parent e9b8097 commit 2100254

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
* @flow strict-local
99
*/
1010

11+
/**
12+
* This module is meant to be used by the React renderers to create public
13+
* instances and get some data from them (like their instance handle / fiber).
14+
*/
15+
1116
import type ReactNativeElement from '../../DOM/Nodes/ReactNativeElement';
1217
import type ReadOnlyText from '../../DOM/Nodes/ReadOnlyText';
1318
import typeof ReactFabricType from '../../Renderer/shims/ReactFabric';
@@ -79,3 +84,9 @@ export function getNodeFromPublicInstance(
7984
publicInstance.__internalInstanceHandle,
8085
);
8186
}
87+
88+
export function getInternalInstanceHandleFromPublicInstance(
89+
publicInstance: ReactFabricHostComponent | ReactNativeElement,
90+
): InternalInstanceHandle {
91+
return publicInstance.__internalInstanceHandle;
92+
}

packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import typeof CustomEvent from '../Events/CustomEvent';
1919
import typeof {
2020
createPublicInstance,
2121
createPublicTextInstance,
22+
getInternalInstanceHandleFromPublicInstance,
2223
getNativeTagFromPublicInstance,
2324
getNodeFromPublicInstance,
2425
} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance';
@@ -108,4 +109,8 @@ module.exports = {
108109
return require('../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
109110
.getNodeFromPublicInstance;
110111
},
112+
get getInternalInstanceHandleFromPublicInstance(): getInternalInstanceHandleFromPublicInstance {
113+
return require('../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
114+
.getInternalInstanceHandleFromPublicInstance;
115+
},
111116
};

0 commit comments

Comments
 (0)