diff --git a/packages/react-native/Libraries/Inspector/StyleInspector.js b/packages/react-native/Libraries/Inspector/StyleInspector.js
index bb5af029d8c4d5..ac757adfe882b6 100644
--- a/packages/react-native/Libraries/Inspector/StyleInspector.js
+++ b/packages/react-native/Libraries/Inspector/StyleInspector.js
@@ -10,42 +10,48 @@
'use strict';
+import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
+import type {____FlattenStyleProp_Internal} from '../StyleSheet/StyleSheetTypes';
+
+import React from 'react';
+
const View = require('../Components/View/View');
const StyleSheet = require('../StyleSheet/StyleSheet');
const Text = require('../Text/Text');
-const React = require('react');
-class StyleInspector extends React.Component<$FlowFixMeProps> {
- render(): React.Node {
- if (!this.props.style) {
- return No style;
- }
- const names = Object.keys(this.props.style);
- return (
-
-
- {names.map(name => (
-
- {name}:
-
- ))}
-
+type Props = $ReadOnly<{
+ style?: ?____FlattenStyleProp_Internal,
+}>;
-
- {names.map(name => {
- const value = this.props.style[name];
- return (
-
- {typeof value !== 'string' && typeof value !== 'number'
- ? JSON.stringify(value)
- : value}
-
- );
- })}
-
-
- );
+function StyleInspector({style}: Props): React.Node {
+ if (!style) {
+ return No style;
}
+ const names = Object.keys(style);
+ return (
+
+
+ {names.map(name => (
+
+ {name}:
+
+ ))}
+
+
+
+ {names.map(name => {
+ const value = style?.[name];
+ return (
+
+ {typeof value !== 'string' && typeof value !== 'number'
+ ? JSON.stringify(value)
+ : value}
+
+ );
+ })}
+
+
+ );
}
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 ee3d98fe77041d..662c8eb0d58673 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
@@ -5324,10 +5324,10 @@ declare export default function ReactDevToolsOverlay(Props): React.Node;
`;
exports[`public API should not change unintentionally Libraries/Inspector/StyleInspector.js 1`] = `
-"declare const React: $FlowFixMe;
-declare class StyleInspector extends React.Component<$FlowFixMeProps> {
- render(): React.Node;
-}
+"type Props = $ReadOnly<{
+ style?: ?____FlattenStyleProp_Internal,
+}>;
+declare function StyleInspector(Props): React.Node;
declare module.exports: StyleInspector;
"
`;