Skip to content

Commit 6daf7d2

Browse files
author
Basil Hosmer
committed
last batch of UIExplorer flowification
1 parent 23094db commit 6daf7d2

7 files changed

Lines changed: 64 additions & 6 deletions

File tree

.flowconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
[libs]
2323
Libraries/react-native/react-native-interface.js
24+
Examples/UIExplorer/ImageMocks.js
2425

2526
[options]
2627
module.system=haste

Examples/UIExplorer/ImageCapInsetsExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule ImageCapInsetsExample
10+
* @flow
1011
*/
1112
'use strict';
1213

Examples/UIExplorer/ImageExample.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
810
*/
911
'use strict';
1012

Examples/UIExplorer/ImageMocks.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2004-present Facebook. All Rights Reserved.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree. An additional grant
6+
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
9+
*/
10+
'use strict';
11+
12+
declare module 'image!story-background' {
13+
declare var uri: string;
14+
declare var isStatic: boolean;
15+
}
16+
17+
declare module 'image!uie_comment_highlighted' {
18+
declare var uri: string;
19+
declare var isStatic: boolean;
20+
}
21+
22+
declare module 'image!uie_comment_normal' {
23+
declare var uri: string;
24+
declare var isStatic: boolean;
25+
}
26+
27+
declare module 'image!uie_thumb_normal' {
28+
declare var uri: string;
29+
declare var isStatic: boolean;
30+
}
31+
32+
declare module 'image!uie_thumb_selected' {
33+
declare var uri: string;
34+
declare var isStatic: boolean;
35+
}

Examples/UIExplorer/MapViewExample.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
810
*/
911
'use strict';
1012

@@ -188,7 +190,7 @@ exports.description = 'Base component to display maps';
188190
exports.examples = [
189191
{
190192
title: 'Map',
191-
render() { return <MapViewExample />; }
193+
render(): ReactElement { return <MapViewExample />; }
192194
},
193195
{
194196
title: 'Map shows user location',

Examples/UIExplorer/TabBarExample.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @flow
810
*/
911
'use strict';
1012

@@ -31,7 +33,7 @@ var TabBarExample = React.createClass({
3133
};
3234
},
3335

34-
_renderContent: function(color, pageText) {
36+
_renderContent: function(color: string, pageText: string) {
3537
return (
3638
<View style={[styles.tabContent, {backgroundColor: color}]}>
3739
<Text style={styles.tabText}>{pageText}</Text>

Examples/UIExplorer/createExamplePage.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule createExamplePage
10+
* @flow
1011
*/
1112
'use strict';
1213

@@ -16,7 +17,19 @@ var UIExplorerPage = require('./UIExplorerPage');
1617

1718
var invariant = require('invariant');
1819

19-
var createExamplePage = function(title, exampleModule) {
20+
class Example extends React.Component {
21+
title: string;
22+
description: string;
23+
}
24+
25+
type ExampleModule = {
26+
title: string;
27+
description: string;
28+
examples: Array<Example>;
29+
};
30+
31+
var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
32+
: ReactClass<any, any, any> {
2033
invariant(!!exampleModule.examples, 'The module must have examples');
2134

2235
var ExamplePage = React.createClass({
@@ -31,15 +44,17 @@ var createExamplePage = function(title, exampleModule) {
3144
var originalRenderComponent = React.renderComponent;
3245
var originalRender = React.render;
3346
var renderedComponent;
34-
React.render = React.renderComponent = function(element, container) {
47+
// TODO remove typecasts when Flow bug #6560135 is fixed
48+
// and workaround is removed from react-native.js
49+
(React: Object).render = (React: Object).renderComponent = function(element, container) {
3550
renderedComponent = element;
3651
};
3752
var result = example.render(null);
3853
if (result) {
3954
renderedComponent = result;
4055
}
41-
React.renderComponent = originalRenderComponent;
42-
React.render = originalRender;
56+
(React: Object).renderComponent = originalRenderComponent;
57+
(React: Object).render = originalRender;
4358
return (
4459
<UIExplorerBlock
4560
key={i}

0 commit comments

Comments
 (0)