Skip to content

Commit 48a7840

Browse files
coadofacebook-github-bot
authored andcommitted
Replace $FlowFixMe in BorderBox (facebook#48593)
Summary: Pull Request resolved: facebook#48593 Changelog: [General][Changed] - Improve types on BorderBox Reviewed By: NickGerleman Differential Revision: D68014754 fbshipit-source-id: ab6af9ffb4a80a4040011c1a27ede95ea2c59171
1 parent 8369922 commit 48a7840

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

packages/react-native/Libraries/Inspector/BorderBox.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,35 @@
1010

1111
'use strict';
1212

13+
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
14+
15+
import React from 'react';
16+
1317
const View = require('../Components/View/View');
14-
const React = require('react');
1518

16-
class BorderBox extends React.Component<$FlowFixMeProps> {
17-
render(): $FlowFixMe | React.Node {
18-
const box = this.props.box;
19-
if (!box) {
20-
return this.props.children;
21-
}
22-
const style = {
23-
borderTopWidth: box.top,
24-
borderBottomWidth: box.bottom,
25-
borderLeftWidth: box.left,
26-
borderRightWidth: box.right,
27-
};
28-
return <View style={[style, this.props.style]}>{this.props.children}</View>;
19+
type Props = $ReadOnly<{
20+
children: React.Node,
21+
box?: ?$ReadOnly<{
22+
top: number,
23+
right: number,
24+
bottom: number,
25+
left: number,
26+
...
27+
}>,
28+
style?: ViewStyleProp,
29+
}>;
30+
31+
function BorderBox({children, box, style}: Props): React.Node {
32+
if (!box) {
33+
return children;
2934
}
35+
const borderStyle = {
36+
borderTopWidth: box.top,
37+
borderBottomWidth: box.bottom,
38+
borderLeftWidth: box.left,
39+
borderRightWidth: box.right,
40+
};
41+
return <View style={[borderStyle, style]}>{children}</View>;
3042
}
3143

3244
module.exports = BorderBox;

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,10 +5150,18 @@ declare module.exports: resolveAssetSource;
51505150
`;
51515151

51525152
exports[`public API should not change unintentionally Libraries/Inspector/BorderBox.js 1`] = `
5153-
"declare const React: $FlowFixMe;
5154-
declare class BorderBox extends React.Component<$FlowFixMeProps> {
5155-
render(): $FlowFixMe | React.Node;
5156-
}
5153+
"type Props = $ReadOnly<{
5154+
children: React.Node,
5155+
box?: ?$ReadOnly<{
5156+
top: number,
5157+
right: number,
5158+
bottom: number,
5159+
left: number,
5160+
...
5161+
}>,
5162+
style?: ViewStyleProp,
5163+
}>;
5164+
declare function BorderBox(Props): React.Node;
51575165
declare module.exports: BorderBox;
51585166
"
51595167
`;

0 commit comments

Comments
 (0)