File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
packages/react-native-renderer/src Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import {
4040 sendAccessibilityEvent ,
4141 getNodeFromInternalInstanceHandle ,
4242} from './ReactNativePublicCompat' ;
43+ import { getPublicInstanceFromInternalInstanceHandle } from './ReactFabricHostConfig' ;
4344
4445// $FlowFixMe[missing-local-annot]
4546function onRecoverableError ( error ) {
@@ -124,6 +125,10 @@ export {
124125 // This method allows it to acess the most recent shadow node for
125126 // the instance (it's only accessible through it).
126127 getNodeFromInternalInstanceHandle ,
128+ // Fabric native methods to traverse the host tree return the same internal
129+ // instance handles we use to dispatch events. This provides a way to access
130+ // the public instances we created from them (potentially created lazily).
131+ getPublicInstanceFromInternalInstanceHandle ,
127132} ;
128133
129134injectIntoDevTools ( {
Original file line number Diff line number Diff line change @@ -241,6 +241,13 @@ export function getPublicInstance(instance: Instance): null | PublicInstance {
241241 return null ;
242242}
243243
244+ export function getPublicInstanceFromInternalInstanceHandle (
245+ internalInstanceHandle : Object ,
246+ ) : null | PublicInstance {
247+ const instance : Instance = internalInstanceHandle . stateNode ;
248+ return getPublicInstance ( instance ) ;
249+ }
250+
244251export function prepareForCommit ( containerInfo : Container ) : null | Object {
245252 // Noop
246253 return null ;
Original file line number Diff line number Diff line change @@ -213,6 +213,8 @@ export type ReactNativeType = {
213213} ;
214214
215215export opaque type Node = mixed ;
216+ type InternalInstanceHandle = mixed ;
217+ type PublicInstance = mixed ;
216218
217219export type ReactFabricType = {
218220 findHostInstance_DEPRECATED < TElementType : ElementType > (
@@ -237,7 +239,12 @@ export type ReactFabricType = {
237239 concurrentRoot : ?boolean ,
238240 ) : ?ElementRef < ElementType > ,
239241 unmountComponentAtNode ( containerTag : number ) : void ,
240- getNodeFromInternalInstanceHandle ( internalInstanceHandle : mixed ) : ?Node ,
242+ getNodeFromInternalInstanceHandle (
243+ internalInstanceHandle : InternalInstanceHandle ,
244+ ) : ?Node ,
245+ getPublicInstanceFromInternalInstanceHandle (
246+ internalInstanceHandle : InternalInstanceHandle ,
247+ ) : PublicInstance ,
241248 ...
242249} ;
243250
You can’t perform that action at this time.
0 commit comments