|
10 | 10 |
|
11 | 11 | 'use strict';
|
12 | 12 |
|
| 13 | +import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; |
| 14 | +import type {____FlattenStyleProp_Internal} from '../StyleSheet/StyleSheetTypes'; |
| 15 | + |
| 16 | +import React from 'react'; |
| 17 | + |
13 | 18 | const View = require('../Components/View/View');
|
14 | 19 | const StyleSheet = require('../StyleSheet/StyleSheet');
|
15 | 20 | const Text = require('../Text/Text');
|
16 |
| -const React = require('react'); |
17 | 21 |
|
18 |
| -class StyleInspector extends React.Component<$FlowFixMeProps> { |
19 |
| - render(): React.Node { |
20 |
| - if (!this.props.style) { |
21 |
| - return <Text style={styles.noStyle}>No style</Text>; |
22 |
| - } |
23 |
| - const names = Object.keys(this.props.style); |
24 |
| - return ( |
25 |
| - <View style={styles.container}> |
26 |
| - <View> |
27 |
| - {names.map(name => ( |
28 |
| - <Text key={name} style={styles.attr}> |
29 |
| - {name}: |
30 |
| - </Text> |
31 |
| - ))} |
32 |
| - </View> |
| 22 | +type Props = $ReadOnly<{ |
| 23 | + style?: ?____FlattenStyleProp_Internal<ViewStyleProp>, |
| 24 | +}>; |
33 | 25 |
|
34 |
| - <View> |
35 |
| - {names.map(name => { |
36 |
| - const value = this.props.style[name]; |
37 |
| - return ( |
38 |
| - <Text key={name} style={styles.value}> |
39 |
| - {typeof value !== 'string' && typeof value !== 'number' |
40 |
| - ? JSON.stringify(value) |
41 |
| - : value} |
42 |
| - </Text> |
43 |
| - ); |
44 |
| - })} |
45 |
| - </View> |
46 |
| - </View> |
47 |
| - ); |
| 26 | +function StyleInspector({style}: Props): React.Node { |
| 27 | + if (!style) { |
| 28 | + return <Text style={styles.noStyle}>No style</Text>; |
48 | 29 | }
|
| 30 | + const names = Object.keys(style); |
| 31 | + return ( |
| 32 | + <View style={styles.container}> |
| 33 | + <View> |
| 34 | + {names.map(name => ( |
| 35 | + <Text key={name} style={styles.attr}> |
| 36 | + {name}: |
| 37 | + </Text> |
| 38 | + ))} |
| 39 | + </View> |
| 40 | + |
| 41 | + <View> |
| 42 | + {names.map(name => { |
| 43 | + const value = style?.[name]; |
| 44 | + return ( |
| 45 | + <Text key={name} style={styles.value}> |
| 46 | + {typeof value !== 'string' && typeof value !== 'number' |
| 47 | + ? JSON.stringify(value) |
| 48 | + : value} |
| 49 | + </Text> |
| 50 | + ); |
| 51 | + })} |
| 52 | + </View> |
| 53 | + </View> |
| 54 | + ); |
49 | 55 | }
|
50 | 56 |
|
51 | 57 | const styles = StyleSheet.create({
|
|
0 commit comments