Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove source usages from getInspectorData #43020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions packages/react-native/Libraries/Inspector/ElementProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

import type {InspectorData} from '../Renderer/shims/ReactNativeTypes';
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
import type {InspectedElementSource} from './Inspector';

const TouchableHighlight = require('../Components/Touchable/TouchableHighlight');
const TouchableWithoutFeedback = require('../Components/Touchable/TouchableWithoutFeedback');
const View = require('../Components/View/View');
const openFileInEditor = require('../Core/Devtools/openFileInEditor');
const flattenStyle = require('../StyleSheet/flattenStyle');
const StyleSheet = require('../StyleSheet/StyleSheet');
const Text = require('../Text/Text');
Expand All @@ -29,7 +27,6 @@ const React = require('react');
type Props = $ReadOnly<{|
hierarchy: ?InspectorData['hierarchy'],
style?: ?ViewStyleProp,
source?: ?InspectedElementSource,
frame?: ?Object,
selection?: ?number,
setSelection?: number => mixed,
Expand All @@ -39,22 +36,7 @@ class ElementProperties extends React.Component<Props> {
render(): React.Node {
const style = flattenStyle(this.props.style);
const selection = this.props.selection;
let openFileButton;
const source = this.props.source;
const {fileName, lineNumber} = source || {};
if (fileName && lineNumber) {
const parts = fileName.split('/');
const fileNameShort = parts[parts.length - 1];
openFileButton = (
<TouchableHighlight
style={styles.openButton}
onPress={openFileInEditor.bind(null, fileName, lineNumber)}>
<Text style={styles.openButtonTitle} numberOfLines={1}>
{fileNameShort}:{lineNumber}
</Text>
</TouchableHighlight>
);
}

// Without the `TouchableWithoutFeedback`, taps on this inspector pane
// would change the inspected element to whatever is under the inspector
return (
Expand Down Expand Up @@ -88,7 +70,6 @@ class ElementProperties extends React.Component<Props> {
<View style={styles.row}>
<View style={styles.col}>
<StyleInspector style={style} />
{openFileButton}
</View>
{<BoxInspector style={style} frame={this.props.frame} />}
</View>
Expand Down Expand Up @@ -134,17 +115,6 @@ const styles = StyleSheet.create({
info: {
padding: 10,
},
openButton: {
padding: 10,
backgroundColor: '#000',
marginVertical: 5,
marginRight: 5,
borderRadius: 2,
},
openButtonTitle: {
color: 'white',
fontSize: 8,
},
});

module.exports = ElementProperties;
8 changes: 1 addition & 7 deletions packages/react-native/Libraries/Inspector/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ type SelectedTab =
| 'performance-profiling';

export type InspectedElementFrame = TouchedViewDataAtPoint['frame'];
export type InspectedElementSource = InspectorData['source'];
export type InspectedElement = $ReadOnly<{
frame: InspectedElementFrame,
source?: InspectedElementSource,
style?: ViewStyleProp,
}>;
export type ElementsHierarchy = InspectorData['hierarchy'];
Expand Down Expand Up @@ -74,14 +72,12 @@ function Inspector({
}

// We pass in findNodeHandle as the method is injected
const {measure, props, source} =
hierarchyItem.getInspectorData(findNodeHandle);
const {measure, props} = hierarchyItem.getInspectorData(findNodeHandle);

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

Expand All @@ -95,7 +91,6 @@ function Inspector({
hierarchy,
props,
selectedIndex,
source,
frame,
pointerY,
touchedViewTag,
Expand All @@ -120,7 +115,6 @@ function Inspector({
// $FlowFixMe[incompatible-call] `props` from InspectorData are defined as <string, string> dictionary, which is incompatible with ViewStyleProp
setInspectedElement({
frame,
source,
style: props.style,
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class InspectorPanel extends React.Component<Props> {
<ElementProperties
style={this.props.inspected.style}
frame={this.props.inspected.frame}
source={this.props.inspected.source}
hierarchy={this.props.hierarchy}
selection={this.props.selection}
setSelection={this.props.setSelection}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4626,10 +4626,8 @@ declare module.exports: resolveAssetSource;
exports[`public API should not change unintentionally Libraries/Inspector/Inspector.js 1`] = `
"declare const React: $FlowFixMe;
export type InspectedElementFrame = TouchedViewDataAtPoint[\\"frame\\"];
export type InspectedElementSource = InspectorData[\\"source\\"];
export type InspectedElement = $ReadOnly<{
frame: InspectedElementFrame,
source?: InspectedElementSource,
style?: ViewStyleProp,
}>;
export type ElementsHierarchy = InspectorData[\\"hierarchy\\"];
Expand Down
Loading