File tree Expand file tree Collapse file tree 5 files changed +18
-29
lines changed
packages/react-native-renderer/src Expand file tree Collapse file tree 5 files changed +18
-29
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ injectIntoDevTools({
137
137
version : ReactVersion ,
138
138
rendererPackageName : 'react-native-renderer' ,
139
139
rendererConfig : {
140
+ getInspectorDataForInstance,
140
141
getInspectorDataForViewTag : getInspectorDataForViewTag ,
141
142
getInspectorDataForViewAtPoint : getInspectorDataForViewAtPoint . bind (
142
143
null ,
Original file line number Diff line number Diff line change 7
7
* @flow
8
8
*/
9
9
10
- import type { TouchedViewDataAtPoint , ViewConfig } from './ReactNativeTypes' ;
10
+ import type {
11
+ InspectorData ,
12
+ TouchedViewDataAtPoint ,
13
+ ViewConfig ,
14
+ } from './ReactNativeTypes' ;
11
15
import { create , diff } from './ReactNativeAttributePayload' ;
12
16
import { dispatchEvent } from './ReactFabricEventEmitter' ;
13
17
import {
14
18
DefaultEventPriority ,
15
19
DiscreteEventPriority ,
16
20
type EventPriority ,
17
21
} from 'react-reconciler/src/ReactEventPriorities' ;
22
+ import type { Fiber } from 'react-reconciler/src/ReactInternalTypes' ;
18
23
import { HostText } from 'react-reconciler/src/ReactWorkTags' ;
19
24
20
25
// Modules provided by RN:
@@ -94,6 +99,7 @@ export type NoTimeout = -1;
94
99
export type TransitionStatus = mixed ;
95
100
96
101
export type RendererInspectionConfig = $ReadOnly < {
102
+ getInspectorDataForInstance ?: ( instance : Fiber | null ) => InspectorData ,
97
103
// Deprecated. Replaced with getInspectorDataForViewAtPoint.
98
104
getInspectorDataForViewTag ?: ( tag : number ) => Object ,
99
105
getInspectorDataForViewAtPoint ?: (
Original file line number Diff line number Diff line change 7
7
* @flow
8
8
*/
9
9
10
- import type { TouchedViewDataAtPoint } from './ReactNativeTypes' ;
10
+ import type { InspectorData , TouchedViewDataAtPoint } from './ReactNativeTypes' ;
11
11
12
12
// Modules provided by RN:
13
13
import {
@@ -28,6 +28,7 @@ import {
28
28
DefaultEventPriority ,
29
29
type EventPriority ,
30
30
} from 'react-reconciler/src/ReactEventPriorities' ;
31
+ import type { Fiber } from 'react-reconciler/src/ReactInternalTypes' ;
31
32
32
33
const { get : getViewConfigForType } = ReactNativeViewConfigRegistry ;
33
34
@@ -49,6 +50,7 @@ export type NoTimeout = -1;
49
50
export type TransitionStatus = mixed ;
50
51
51
52
export type RendererInspectionConfig = $ReadOnly < {
53
+ getInspectorDataForInstance ?: ( instance : Fiber | null ) => InspectorData ,
52
54
// Deprecated. Replaced with getInspectorDataForViewAtPoint.
53
55
getInspectorDataForViewTag ?: ( tag : number ) => Object ,
54
56
getInspectorDataForViewAtPoint ?: (
Original file line number Diff line number Diff line change @@ -117,9 +117,11 @@ function getInspectorDataForInstance(
117
117
selectedIndex,
118
118
source,
119
119
} ;
120
- } else {
121
- return ( null : any ) ;
122
120
}
121
+
122
+ throw new Error (
123
+ 'getInspectorDataForInstance() is not available in production' ,
124
+ ) ;
123
125
}
124
126
125
127
function getOwnerHierarchy ( instance : any ) {
@@ -153,34 +155,11 @@ function traverseOwnerTreeUp(
153
155
}
154
156
}
155
157
156
- function getInspectorDataForViewTag ( viewTag : number ) : Object {
158
+ function getInspectorDataForViewTag ( viewTag : number ) : InspectorData {
157
159
if ( __DEV__ ) {
158
160
const closestInstance = getClosestInstanceFromNode ( viewTag ) ;
159
161
160
- // Handle case where user clicks outside of ReactNative
161
- if ( ! closestInstance ) {
162
- return {
163
- hierarchy : [ ] ,
164
- props : emptyObject ,
165
- selectedIndex : null ,
166
- source : null ,
167
- } ;
168
- }
169
-
170
- const fiber = findCurrentFiberUsingSlowPath ( closestInstance ) ;
171
- const fiberHierarchy = getOwnerHierarchy ( fiber ) ;
172
- const instance = lastNonHostInstance ( fiberHierarchy ) ;
173
- const hierarchy = createHierarchy ( fiberHierarchy ) ;
174
- const props = getHostProps ( instance ) ;
175
- const source = instance . _debugSource ;
176
- const selectedIndex = fiberHierarchy . indexOf ( instance ) ;
177
-
178
- return {
179
- hierarchy,
180
- props,
181
- selectedIndex,
182
- source,
183
- } ;
162
+ return getInspectorDataForInstance ( closestInstance ) ;
184
163
} else {
185
164
throw new Error (
186
165
'getInspectorDataForViewTag() is not available in production' ,
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ injectIntoDevTools({
145
145
version : ReactVersion ,
146
146
rendererPackageName : 'react-native-renderer' ,
147
147
rendererConfig : {
148
+ getInspectorDataForInstance,
148
149
getInspectorDataForViewTag : getInspectorDataForViewTag ,
149
150
getInspectorDataForViewAtPoint : getInspectorDataForViewAtPoint . bind (
150
151
null ,
You can’t perform that action at this time.
0 commit comments