diff --git a/packages/react-native/Libraries/Inspector/BoxInspector.js b/packages/react-native/Libraries/Inspector/BoxInspector.js
index 4da88e666f4efd..8e67f3b97eaa50 100644
--- a/packages/react-native/Libraries/Inspector/BoxInspector.js
+++ b/packages/react-native/Libraries/Inspector/BoxInspector.js
@@ -10,11 +10,15 @@
'use strict';
+import type {TextStyleProp, ViewStyleProp} from '../StyleSheet/StyleSheet';
+import type {InspectedElementFrame} from './Inspector';
+
+import React from 'react';
+
const View = require('../Components/View/View');
const StyleSheet = require('../StyleSheet/StyleSheet');
const Text = require('../Text/Text');
const resolveBoxStyle = require('./resolveBoxStyle');
-const React = require('react');
const blank = {
top: 0,
@@ -23,51 +27,65 @@ const blank = {
bottom: 0,
};
-class BoxInspector extends React.Component<$FlowFixMeProps> {
- render(): React.Node {
- const frame = this.props.frame;
- const style = this.props.style;
- const margin = (style && resolveBoxStyle('margin', style)) || blank;
- const padding = (style && resolveBoxStyle('padding', style)) || blank;
- return (
-
-
-
-
- ({(frame.left || 0).toFixed(1)}, {(frame.top || 0).toFixed(1)})
-
-
- {(frame.width || 0).toFixed(1)} ×{' '}
- {(frame.height || 0).toFixed(1)}
-
-
-
-
- );
- }
-}
+type BoxInspectorProps = $ReadOnly<{
+ style: ViewStyleProp,
+ frame: ?InspectedElementFrame,
+}>;
+
+function BoxInspector({style, frame}: BoxInspectorProps): React.Node {
+ const margin = (style && resolveBoxStyle('margin', style)) || blank;
+ const padding = (style && resolveBoxStyle('padding', style)) || blank;
-class BoxContainer extends React.Component<$FlowFixMeProps> {
- render(): React.Node {
- const box = this.props.box;
- return (
-
-
- {}
-
- {this.props.title}
+ return (
+
+
+
+
+ ({(frame?.left || 0).toFixed(1)}, {(frame?.top || 0).toFixed(1)})
+
+
+ {(frame?.width || 0).toFixed(1)} ×{' '}
+ {(frame?.height || 0).toFixed(1)}
- {box.top}
-
-
- {box.left}
- {this.props.children}
- {box.right}
- {box.bottom}
+
+
+ );
+}
+
+type BoxContainerProps = $ReadOnly<{
+ title: string,
+ titleStyle?: TextStyleProp,
+ box: $ReadOnly<{
+ top: number,
+ left: number,
+ right: number,
+ bottom: number,
+ }>,
+ children: React.Node,
+}>;
+
+function BoxContainer({
+ title,
+ titleStyle,
+ box,
+ children,
+}: BoxContainerProps): React.Node {
+ return (
+
+
+ {}
+ {title}
+ {box.top}
+
+
+ {box.left}
+ {children}
+ {box.right}
- );
- }
+ {box.bottom}
+
+ );
}
const styles = StyleSheet.create({
diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
index 71a9b247674d31..32b72e85d0ba5d 100644
--- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
+++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
@@ -5167,10 +5167,11 @@ declare module.exports: BorderBox;
`;
exports[`public API should not change unintentionally Libraries/Inspector/BoxInspector.js 1`] = `
-"declare const React: $FlowFixMe;
-declare class BoxInspector extends React.Component<$FlowFixMeProps> {
- render(): React.Node;
-}
+"type BoxInspectorProps = $ReadOnly<{
+ style: ViewStyleProp,
+ frame: ?InspectedElementFrame,
+}>;
+declare function BoxInspector(BoxInspectorProps): React.Node;
declare module.exports: BoxInspector;
"
`;