Skip to content

Commit fbbb2a7

Browse files
hoxyqfacebook-github-bot
authored andcommitted
refactor: remove source usages from getInspectorData
Summary: Changelog: [Internal] Required for landing D53543159. 2 reasons for landing this: 1. Inspector is technically deprecated and will be removed once React DevTools are shipped with Chrome DevTools for RN debugging. 2. Long-term solution for source fetching is lazy loading based on component stacks - facebook/react#28265 Differential Revision: D53757524
1 parent 48f1f2d commit fbbb2a7

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed

packages/react-native/Libraries/Inspector/ElementProperties.js

+1-27
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212

1313
import type {InspectorData} from '../Renderer/shims/ReactNativeTypes';
1414
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
15-
import type {InspectedElementSource} from './Inspector';
1615

1716
const TouchableHighlight = require('../Components/Touchable/TouchableHighlight');
1817
const TouchableWithoutFeedback = require('../Components/Touchable/TouchableWithoutFeedback');
1918
const View = require('../Components/View/View');
20-
const openFileInEditor = require('../Core/Devtools/openFileInEditor');
2119
const flattenStyle = require('../StyleSheet/flattenStyle');
2220
const StyleSheet = require('../StyleSheet/StyleSheet');
2321
const Text = require('../Text/Text');
@@ -29,7 +27,6 @@ const React = require('react');
2927
type Props = $ReadOnly<{|
3028
hierarchy: ?InspectorData['hierarchy'],
3129
style?: ?ViewStyleProp,
32-
source?: ?InspectedElementSource,
3330
frame?: ?Object,
3431
selection?: ?number,
3532
setSelection?: number => mixed,
@@ -39,22 +36,7 @@ class ElementProperties extends React.Component<Props> {
3936
render(): React.Node {
4037
const style = flattenStyle(this.props.style);
4138
const selection = this.props.selection;
42-
let openFileButton;
43-
const source = this.props.source;
44-
const {fileName, lineNumber} = source || {};
45-
if (fileName && lineNumber) {
46-
const parts = fileName.split('/');
47-
const fileNameShort = parts[parts.length - 1];
48-
openFileButton = (
49-
<TouchableHighlight
50-
style={styles.openButton}
51-
onPress={openFileInEditor.bind(null, fileName, lineNumber)}>
52-
<Text style={styles.openButtonTitle} numberOfLines={1}>
53-
{fileNameShort}:{lineNumber}
54-
</Text>
55-
</TouchableHighlight>
56-
);
57-
}
39+
5840
// Without the `TouchableWithoutFeedback`, taps on this inspector pane
5941
// would change the inspected element to whatever is under the inspector
6042
return (
@@ -88,7 +70,6 @@ class ElementProperties extends React.Component<Props> {
8870
<View style={styles.row}>
8971
<View style={styles.col}>
9072
<StyleInspector style={style} />
91-
{openFileButton}
9273
</View>
9374
{<BoxInspector style={style} frame={this.props.frame} />}
9475
</View>
@@ -134,13 +115,6 @@ const styles = StyleSheet.create({
134115
info: {
135116
padding: 10,
136117
},
137-
openButton: {
138-
padding: 10,
139-
backgroundColor: '#000',
140-
marginVertical: 5,
141-
marginRight: 5,
142-
borderRadius: 2,
143-
},
144118
openButtonTitle: {
145119
color: 'white',
146120
fontSize: 8,

packages/react-native/Libraries/Inspector/Inspector.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ type SelectedTab =
3838
| 'performance-profiling';
3939

4040
export type InspectedElementFrame = TouchedViewDataAtPoint['frame'];
41-
export type InspectedElementSource = InspectorData['source'];
4241
export type InspectedElement = $ReadOnly<{
4342
frame: InspectedElementFrame,
44-
source?: InspectedElementSource,
4543
style?: ViewStyleProp,
4644
}>;
4745
export type ElementsHierarchy = InspectorData['hierarchy'];
@@ -74,14 +72,12 @@ function Inspector({
7472
}
7573

7674
// We pass in findNodeHandle as the method is injected
77-
const {measure, props, source} =
78-
hierarchyItem.getInspectorData(findNodeHandle);
75+
const {measure, props} = hierarchyItem.getInspectorData(findNodeHandle);
7976

8077
measure((x, y, width, height, left, top) => {
8178
// $FlowFixMe[incompatible-call] `props` from InspectorData are defined as <string, string> dictionary, which is incompatible with ViewStyleProp
8279
setInspectedElement({
8380
frame: {left, top, width, height},
84-
source,
8581
style: props.style,
8682
});
8783

@@ -95,7 +91,6 @@ function Inspector({
9591
hierarchy,
9692
props,
9793
selectedIndex,
98-
source,
9994
frame,
10095
pointerY,
10196
touchedViewTag,
@@ -120,7 +115,6 @@ function Inspector({
120115
// $FlowFixMe[incompatible-call] `props` from InspectorData are defined as <string, string> dictionary, which is incompatible with ViewStyleProp
121116
setInspectedElement({
122117
frame,
123-
source,
124118
style: props.style,
125119
});
126120
};

packages/react-native/Libraries/Inspector/InspectorPanel.js

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class InspectorPanel extends React.Component<Props> {
5858
<ElementProperties
5959
style={this.props.inspected.style}
6060
frame={this.props.inspected.frame}
61-
source={this.props.inspected.source}
6261
hierarchy={this.props.hierarchy}
6362
selection={this.props.selection}
6463
setSelection={this.props.setSelection}

0 commit comments

Comments
 (0)