Skip to content

Commit 99bba8c

Browse files
gabelevifacebook-github-bot-7
authored andcommitted
Use .flow files to tell Flow about react-native module
Reviewed By: jeffmo Differential Revision: D2735788 fb-gh-sync-id: 7a15caa5effb89b902bba7e0031822f534813c52
1 parent fe69ac9 commit 99bba8c

4 files changed

Lines changed: 128 additions & 1 deletion

File tree

Examples/Movies/MovieCell.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ var MovieCell = React.createClass({
4545
onShowUnderlay={this.props.onHighlight}
4646
onHideUnderlay={this.props.onUnhighlight}>
4747
<View style={styles.row}>
48+
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
49+
* omit a property or set it to undefined if it's inside a shape,
50+
* even if it isn't required */}
4851
<Image
4952
source={getImageSource(this.props.movie, 'det')}
5053
style={styles.cellImage}

Examples/Movies/MovieScreen.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ var MovieScreen = React.createClass({
3434
return (
3535
<ScrollView contentContainerStyle={styles.contentContainer}>
3636
<View style={styles.mainSection}>
37+
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
38+
* omit a property or set it to undefined if it's inside a shape,
39+
* even if it isn't required */}
3740
<Image
3841
source={getImageSource(this.props.movie, 'det')}
3942
style={styles.detailsImage}

Examples/UIExplorer/NetInfoExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const IsConnected = React.createClass({
130130
const IsConnectionExpensive = React.createClass({
131131
getInitialState() {
132132
return {
133-
isConnectionExpensive: null,
133+
isConnectionExpensive: (null : ?boolean),
134134
};
135135
},
136136
_checkIfExpensive() {
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* This file exists because react-native.js started using getters and setters
10+
* and Flow doesn't have a good way to enable getters and setters for
11+
* react-native without forcing all react-native users to also enable getters
12+
* and setters. Until we solve that issue, we can use this .flow file to
13+
* pretend like react-native doesn't use getters and setters
14+
*
15+
* @flow
16+
*/
17+
'use strict';
18+
19+
// Export React, plus some native additions.
20+
//
21+
// The use of Object.create/assign is to work around a Flow bug (#6560135).
22+
// Once that is fixed, change this back to
23+
//
24+
// var ReactNative = {...require('React'), /* additions */}
25+
//
26+
var ReactNative = Object.assign(Object.create(require('React')), {
27+
// Components
28+
ActivityIndicatorIOS: require('ActivityIndicatorIOS'),
29+
ART: require('ReactNativeART'),
30+
DatePickerIOS: require('DatePickerIOS'),
31+
DrawerLayoutAndroid: require('DrawerLayoutAndroid'),
32+
Image: require('Image'),
33+
ListView: require('ListView'),
34+
MapView: require('MapView'),
35+
Modal: require('Modal'),
36+
Navigator: require('Navigator'),
37+
NavigatorIOS: require('NavigatorIOS'),
38+
PickerIOS: require('PickerIOS'),
39+
ProgressBarAndroid: require('ProgressBarAndroid'),
40+
ProgressViewIOS: require('ProgressViewIOS'),
41+
ScrollView: require('ScrollView'),
42+
SegmentedControlIOS: require('SegmentedControlIOS'),
43+
SliderIOS: require('SliderIOS'),
44+
SnapshotViewIOS: require('SnapshotViewIOS'),
45+
Switch: require('Switch'),
46+
PullToRefreshViewAndroid: require('PullToRefreshViewAndroid'),
47+
SwitchAndroid: require('SwitchAndroid'),
48+
SwitchIOS: require('SwitchIOS'),
49+
TabBarIOS: require('TabBarIOS'),
50+
Text: require('Text'),
51+
TextInput: require('TextInput'),
52+
ToastAndroid: require('ToastAndroid'),
53+
ToolbarAndroid: require('ToolbarAndroid'),
54+
Touchable: require('Touchable'),
55+
TouchableHighlight: require('TouchableHighlight'),
56+
TouchableNativeFeedback: require('TouchableNativeFeedback'),
57+
TouchableOpacity: require('TouchableOpacity'),
58+
TouchableWithoutFeedback: require('TouchableWithoutFeedback'),
59+
View: require('View'),
60+
ViewPagerAndroid: require('ViewPagerAndroid'),
61+
WebView: require('WebView'),
62+
63+
// APIs
64+
ActionSheetIOS: require('ActionSheetIOS'),
65+
AdSupportIOS: require('AdSupportIOS'),
66+
AlertIOS: require('AlertIOS'),
67+
Animated: require('Animated'),
68+
AppRegistry: require('AppRegistry'),
69+
AppStateIOS: require('AppStateIOS'),
70+
AsyncStorage: require('AsyncStorage'),
71+
BackAndroid: require('BackAndroid'),
72+
CameraRoll: require('CameraRoll'),
73+
Dimensions: require('Dimensions'),
74+
Easing: require('Easing'),
75+
ImagePickerIOS: require('ImagePickerIOS'),
76+
IntentAndroid: require('IntentAndroid'),
77+
InteractionManager: require('InteractionManager'),
78+
LayoutAnimation: require('LayoutAnimation'),
79+
LinkingIOS: require('LinkingIOS'),
80+
NetInfo: require('NetInfo'),
81+
PanResponder: require('PanResponder'),
82+
PixelRatio: require('PixelRatio'),
83+
PushNotificationIOS: require('PushNotificationIOS'),
84+
Settings: require('Settings'),
85+
StatusBarIOS: require('StatusBarIOS'),
86+
StyleSheet: require('StyleSheet'),
87+
UIManager: require('UIManager'),
88+
VibrationIOS: require('VibrationIOS'),
89+
90+
// Plugins
91+
DeviceEventEmitter: require('RCTDeviceEventEmitter'),
92+
NativeAppEventEmitter: require('RCTNativeAppEventEmitter'),
93+
NativeModules: require('NativeModules'),
94+
Platform: require('Platform'),
95+
processColor: require('processColor'),
96+
requireNativeComponent: require('requireNativeComponent'),
97+
98+
// Prop Types
99+
EdgeInsetsPropType: require('EdgeInsetsPropType'),
100+
PointPropType: require('PointPropType'),
101+
102+
// See http://facebook.github.io/react/docs/addons.html
103+
addons: {
104+
LinkedStateMixin: require('LinkedStateMixin'),
105+
Perf: undefined,
106+
PureRenderMixin: require('ReactComponentWithPureRenderMixin'),
107+
TestModule: require('NativeModules').TestModule,
108+
TestUtils: undefined,
109+
batchedUpdates: require('ReactUpdates').batchedUpdates,
110+
cloneWithProps: require('cloneWithProps'),
111+
createFragment: require('ReactFragment').create,
112+
update: require('update'),
113+
},
114+
});
115+
116+
if (__DEV__) {
117+
ReactNative.addons.Perf = require('ReactDefaultPerf');
118+
ReactNative.addons.TestUtils = require('ReactTestUtils');
119+
}
120+
121+
module.exports = ReactNative;

0 commit comments

Comments
 (0)