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

Remove PropTypes from ElementProperties #21350

Closed
wants to merge 4 commits into from
Closed
Changes from 3 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
31 changes: 11 additions & 20 deletions Libraries/Inspector/ElementProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'use strict';

const BoxInspector = require('BoxInspector');
const PropTypes = require('prop-types');
const React = require('React');
const StyleInspector = require('StyleInspector');
const StyleSheet = require('StyleSheet');
Expand All @@ -24,29 +23,21 @@ const flattenStyle = require('flattenStyle');
const mapWithSeparator = require('mapWithSeparator');
const openFileInEditor = require('openFileInEditor');

import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier/prettier: Replace (number) with number

import type {ViewStyleProp} from 'StyleSheet';

class ElementProperties extends React.Component<{
type Props = $ReadOnly<{|
hierarchy: Array<$FlowFixMe>,
style?: DangerouslyImpreciseStyleProp,
source?: {
fileName?: string,
lineNumber?: number,
style?: ?ViewStyleProp,
source?: ?{
fileName?: ?string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure these should be nullable. Lets leave fileName and lineNumber the way they were:

fileName?: string,
lineNumber?: string

lineNumber?: ?number,
},
}> {
static propTypes = {
hierarchy: PropTypes.array.isRequired,
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.array,
PropTypes.number,
]),
source: PropTypes.shape({
fileName: PropTypes.string,
lineNumber: PropTypes.number,
}),
};
frame?: ?Object,
selection?: ?number,
setSelection?: (?number) => mixed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setSelection is only ever called with a number, never with null, so the argument shouldn't be nullable. setSelection?: (number) => mixed

|}>;

class ElementProperties extends React.Component<Props> {
render() {
const style = flattenStyle(this.props.style);
// $FlowFixMe found when converting React.createClass to ES6
Expand Down