diff --git a/RNTester/RNTesterUnitTests/RNTesterUnitTestsBundle.js b/RNTester/RNTesterUnitTests/RNTesterUnitTestsBundle.js
index e6ff98a10..9e387e5ee 100644
--- a/RNTester/RNTesterUnitTests/RNTesterUnitTestsBundle.js
+++ b/RNTester/RNTesterUnitTests/RNTesterUnitTestsBundle.js
@@ -4,11 +4,14 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
-const __fbBatchedBridge = { // eslint-disable-line no-unused-vars
+const __fbBatchedBridge = {
+ // eslint-disable-line no-unused-vars
flushedQueue: function() {
return null;
- }
+ },
};
diff --git a/RNTester/js/ARTExample.js b/RNTester/js/ARTExample.js
index fb8d0378c..15ae6de03 100644
--- a/RNTester/js/ARTExample.js
+++ b/RNTester/js/ARTExample.js
@@ -4,76 +4,92 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- ART,
- Platform,
- View,
-} = ReactNative;
-
-const {
- Surface,
- Path,
- Group,
- Transform,
- Shape,
-} = ART;
+var {ART, Platform, View} = ReactNative;
+const {Surface, Path, Group, Transform, Shape} = ART;
var scale = Platform.isTVOS ? 4 : 1;
class ARTExample extends React.Component<{}> {
- render(){
- const pathRect = new Path()
- .moveTo(scale * 0,scale * 0)
- .lineTo(scale * 0,scale * 110)
- .lineTo(scale * 110,scale * 110)
- .lineTo(scale * 110,scale * 0)
- .close();
+ render() {
+ const pathRect = new Path()
+ .moveTo(scale * 0, scale * 0)
+ .lineTo(scale * 0, scale * 110)
+ .lineTo(scale * 110, scale * 110)
+ .lineTo(scale * 110, scale * 0)
+ .close();
- const pathCircle0 = new Path()
- .moveTo(scale * 30,scale * 5)
- .arc(scale * 0,scale * 50,scale * 25)
- .arc(scale * 0,-scale * 50,scale * 25)
- .close();
+ const pathCircle0 = new Path()
+ .moveTo(scale * 30, scale * 5)
+ .arc(scale * 0, scale * 50, scale * 25)
+ .arc(scale * 0, -scale * 50, scale * 25)
+ .close();
- const pathCircle1 = new Path()
- .moveTo(scale * 30,scale * 55)
- .arc(scale * 0,scale * 50,scale * 25)
- .arc(scale * 0,-scale * 50,scale * 25)
- .close();
+ const pathCircle1 = new Path()
+ .moveTo(scale * 30, scale * 55)
+ .arc(scale * 0, scale * 50, scale * 25)
+ .arc(scale * 0, -scale * 50, scale * 25)
+ .close();
- const pathCircle2 = new Path()
- .moveTo(scale * 55,scale * 30)
- .arc(scale * 50,scale * 0,scale * 25)
- .arc(-scale * 50,scale * 0,scale * 25)
- .close();
+ const pathCircle2 = new Path()
+ .moveTo(scale * 55, scale * 30)
+ .arc(scale * 50, scale * 0, scale * 25)
+ .arc(-scale * 50, scale * 0, scale * 25)
+ .close();
- const pathCircle3 = new Path()
- .moveTo(scale * 55,scale * 80)
- .arc(scale * 50,scale * 0,scale * 25)
- .arc(-scale * 50,scale * 0,scale * 25)
- .close();
+ const pathCircle3 = new Path()
+ .moveTo(scale * 55, scale * 80)
+ .arc(scale * 50, scale * 0, scale * 25)
+ .arc(-scale * 50, scale * 0, scale * 25)
+ .close();
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
exports.title = '';
@@ -84,6 +100,6 @@ exports.examples = [
title: 'ART Example',
render(): React.Element {
return ;
- }
+ },
},
];
diff --git a/RNTester/js/AccessibilityAndroidExample.android.js b/RNTester/js/AccessibilityAndroidExample.android.js
index 6c6a80d41..e193d3393 100644
--- a/RNTester/js/AccessibilityAndroidExample.android.js
+++ b/RNTester/js/AccessibilityAndroidExample.android.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
var React = require('react');
@@ -21,7 +23,12 @@ var {
var RNTesterBlock = require('./RNTesterBlock');
var RNTesterPage = require('./RNTesterPage');
-var importantForAccessibilityValues = ['auto', 'yes', 'no', 'no-hide-descendants'];
+var importantForAccessibilityValues = [
+ 'auto',
+ 'yes',
+ 'no',
+ 'no-hide-descendants',
+];
class AccessibilityAndroidExample extends React.Component {
static title = 'Accessibility';
@@ -37,11 +44,11 @@ class AccessibilityAndroidExample extends React.Component {
componentDidMount() {
AccessibilityInfo.addEventListener(
'change',
- this._handleScreenReaderToggled
+ this._handleScreenReaderToggled,
);
- AccessibilityInfo.fetch().done((isEnabled) => {
+ AccessibilityInfo.fetch().done(isEnabled => {
this.setState({
- screenReaderEnabled: isEnabled
+ screenReaderEnabled: isEnabled,
});
});
}
@@ -49,15 +56,15 @@ class AccessibilityAndroidExample extends React.Component {
componentWillUnmount() {
AccessibilityInfo.removeEventListener(
'change',
- this._handleScreenReaderToggled
+ this._handleScreenReaderToggled,
);
}
- _handleScreenReaderToggled = (isEnabled) => {
+ _handleScreenReaderToggled = isEnabled => {
this.setState({
screenReaderEnabled: isEnabled,
});
- }
+ };
_addOne = () => {
this.setState({
@@ -80,23 +87,16 @@ class AccessibilityAndroidExample extends React.Component {
render() {
return (
-
-
- This is
-
-
- nontouchable normal view.
-
+ This is
+ nontouchable normal view.
-
- This is
-
+ This is
nontouchable accessible view without label.
@@ -104,11 +104,10 @@ class AccessibilityAndroidExample extends React.Component {
-
-
- This is
-
+ This is
nontouchable accessible view with label.
@@ -117,7 +116,9 @@ class AccessibilityAndroidExample extends React.Component {
ToastAndroid.show('Toasts work by default', ToastAndroid.SHORT)}
+ onPress={() =>
+ ToastAndroid.show('Toasts work by default', ToastAndroid.SHORT)
+ }
accessibilityComponentType="button">
Click me
@@ -139,7 +140,8 @@ class AccessibilityAndroidExample extends React.Component {
- The screen reader is {this.state.screenReaderEnabled ? 'enabled' : 'disabled'}.
+ The screen reader is{' '}
+ {this.state.screenReaderEnabled ? 'enabled' : 'disabled'}.
@@ -152,15 +154,17 @@ class AccessibilityAndroidExample extends React.Component {
top: 10,
right: 10,
height: 100,
- backgroundColor: 'green'}}
+ backgroundColor: 'green',
+ }}
accessible={true}
accessibilityLabel="First layout"
importantForAccessibility={
- importantForAccessibilityValues[this.state.backgroundImportantForAcc]}>
+ importantForAccessibilityValues[
+ this.state.backgroundImportantForAcc
+ ]
+ }>
-
- Hello
-
+ Hello
+ importantForAccessibilityValues[
+ this.state.forgroundImportantForAcc
+ ]
+ }>
-
- world
-
+ world
-
+
Change importantForAccessibility for background layout.
@@ -190,14 +198,17 @@ class AccessibilityAndroidExample extends React.Component {
+ Background layout importantForAccessibility
- Background layout importantForAccessibility
-
-
- {importantForAccessibilityValues[this.state.backgroundImportantForAcc]}
+ {
+ importantForAccessibilityValues[
+ this.state.backgroundImportantForAcc
+ ]
+ }
-
+
Change importantForAccessibility for forground layout.
@@ -205,30 +216,31 @@ class AccessibilityAndroidExample extends React.Component {
+ Forground layout importantForAccessibility
- Forground layout importantForAccessibility
-
-
- {importantForAccessibilityValues[this.state.forgroundImportantForAcc]}
+ {
+ importantForAccessibilityValues[
+ this.state.forgroundImportantForAcc
+ ]
+ }
-
);
}
}
var styles = StyleSheet.create({
- embedded: {
+ embedded: {
backgroundColor: 'yellow',
- padding:10,
+ padding: 10,
},
container: {
flex: 1,
backgroundColor: 'white',
padding: 10,
- height:150,
+ height: 150,
},
});
diff --git a/RNTester/js/AccessibilityIOSExample.js b/RNTester/js/AccessibilityIOSExample.js
index dabce101c..60d9ceeed 100644
--- a/RNTester/js/AccessibilityIOSExample.js
+++ b/RNTester/js/AccessibilityIOSExample.js
@@ -4,17 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- AccessibilityInfo,
- Text,
- View,
-} = ReactNative;
+var {AccessibilityInfo, Text, View} = ReactNative;
class AccessibilityIOSExample extends React.Component<{}> {
render() {
@@ -23,37 +21,28 @@ class AccessibilityIOSExample extends React.Component<{}> {
alert('onAccessibilityTap success')}
accessible={true}>
-
- Accessibility normal tap example
-
+ Accessibility normal tap example
- alert('onMagicTap success')}
- accessible={true}>
-
- Accessibility magic tap example
-
+ alert('onMagicTap success')} accessible={true}>
+ Accessibility magic tap example
-
-
- Accessibility label example
-
+
+ Accessibility label example
-
-
- Accessibility traits example
-
+
+ Accessibility traits example
- Text's accessibilityLabel is the raw text itself unless it is set explicitly.
+ Text's accessibilityLabel is the raw text itself unless it is set
+ explicitly.
-
+
This text component's accessibilityLabel is set explicitly.
- This view's children are hidden from the accessibility tree
+
+ This view's children are hidden from the accessibility tree
+
);
@@ -63,16 +52,16 @@ class AccessibilityIOSExample extends React.Component<{}> {
class ScreenReaderStatusExample extends React.Component<{}, $FlowFixMeState> {
state = {
screenReaderEnabled: false,
- }
+ };
componentDidMount() {
AccessibilityInfo.addEventListener(
'change',
- this._handleScreenReaderToggled
+ this._handleScreenReaderToggled,
);
- AccessibilityInfo.fetch().done((isEnabled) => {
+ AccessibilityInfo.fetch().done(isEnabled => {
this.setState({
- screenReaderEnabled: isEnabled
+ screenReaderEnabled: isEnabled,
});
});
}
@@ -80,21 +69,22 @@ class ScreenReaderStatusExample extends React.Component<{}, $FlowFixMeState> {
componentWillUnmount() {
AccessibilityInfo.removeEventListener(
'change',
- this._handleScreenReaderToggled
+ this._handleScreenReaderToggled,
);
}
- _handleScreenReaderToggled = (isEnabled) => {
+ _handleScreenReaderToggled = isEnabled => {
this.setState({
screenReaderEnabled: isEnabled,
});
- }
+ };
render() {
return (
- The screen reader is {this.state.screenReaderEnabled ? 'enabled' : 'disabled'}.
+ The screen reader is{' '}
+ {this.state.screenReaderEnabled ? 'enabled' : 'disabled'}.
);
@@ -102,14 +92,18 @@ class ScreenReaderStatusExample extends React.Component<{}, $FlowFixMeState> {
}
exports.title = 'AccessibilityIOS';
-exports.description = 'Interface to show iOS\' accessibility samples';
+exports.description = "Interface to show iOS' accessibility samples";
exports.examples = [
{
title: 'Accessibility elements',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Check if the screen reader is enabled',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
];
diff --git a/RNTester/js/ActionSheetIOSExample.js b/RNTester/js/ActionSheetIOSExample.js
index 1b04190b2..2c1788864 100644
--- a/RNTester/js/ActionSheetIOSExample.js
+++ b/RNTester/js/ActionSheetIOSExample.js
@@ -4,27 +4,17 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- ActionSheetIOS,
- StyleSheet,
- takeSnapshot,
- Text,
- View,
-} = ReactNative;
+var {ActionSheetIOS, StyleSheet, takeSnapshot, Text, View} = ReactNative;
-var BUTTONS = [
- 'Option 0',
- 'Option 1',
- 'Option 2',
- 'Delete',
- 'Cancel',
-];
+var BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel'];
var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;
@@ -39,22 +29,22 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
Click to show the ActionSheet
-
- Clicked button: {this.state.clicked}
-
+ Clicked button: {this.state.clicked}
);
}
showActionSheet = () => {
- ActionSheetIOS.showActionSheetWithOptions({
- options: BUTTONS,
- cancelButtonIndex: CANCEL_INDEX,
- destructiveButtonIndex: DESTRUCTIVE_INDEX,
- },
- (buttonIndex) => {
- this.setState({ clicked: BUTTONS[buttonIndex] });
- });
+ ActionSheetIOS.showActionSheetWithOptions(
+ {
+ options: BUTTONS,
+ cancelButtonIndex: CANCEL_INDEX,
+ destructiveButtonIndex: DESTRUCTIVE_INDEX,
+ },
+ buttonIndex => {
+ this.setState({clicked: BUTTONS[buttonIndex]});
+ },
+ );
};
}
@@ -69,29 +59,32 @@ class ActionSheetTintExample extends React.Component<{}, $FlowFixMeState> {
Click to show the ActionSheet
-
- Clicked button: {this.state.clicked}
-
+ Clicked button: {this.state.clicked}
);
}
showActionSheet = () => {
- ActionSheetIOS.showActionSheetWithOptions({
- options: BUTTONS,
- cancelButtonIndex: CANCEL_INDEX,
- destructiveButtonIndex: DESTRUCTIVE_INDEX,
- tintColor: 'green',
- },
- (buttonIndex) => {
- this.setState({ clicked: BUTTONS[buttonIndex] });
- });
+ ActionSheetIOS.showActionSheetWithOptions(
+ {
+ options: BUTTONS,
+ cancelButtonIndex: CANCEL_INDEX,
+ destructiveButtonIndex: DESTRUCTIVE_INDEX,
+ tintColor: 'green',
+ },
+ buttonIndex => {
+ this.setState({clicked: BUTTONS[buttonIndex]});
+ },
+ );
};
}
-class ShareActionSheetExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class ShareActionSheetExample extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
state = {
- text: ''
+ text: '',
};
render() {
@@ -100,38 +93,36 @@ class ShareActionSheetExample extends React.Component<$FlowFixMeProps, $FlowFixM
Click to show the Share ActionSheet
-
- {this.state.text}
-
+ {this.state.text}
);
}
showShareActionSheet = () => {
- ActionSheetIOS.showShareActionSheetWithOptions({
- url: this.props.url,
- message: 'message to go with the shared url',
- subject: 'a subject to go in the email heading',
- excludedActivityTypes: [
- 'com.apple.UIKit.activity.PostToTwitter'
- ]
- },
- (error) => alert(error),
- (completed, method) => {
- var text;
- if (completed) {
- text = `Shared via ${method}`;
- } else {
- text = 'You didn\'t share';
- }
- this.setState({text});
- });
+ ActionSheetIOS.showShareActionSheetWithOptions(
+ {
+ url: this.props.url,
+ message: 'message to go with the shared url',
+ subject: 'a subject to go in the email heading',
+ excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
+ },
+ error => alert(error),
+ (completed, method) => {
+ var text;
+ if (completed) {
+ text = `Shared via ${method}`;
+ } else {
+ text = "You didn't share";
+ }
+ this.setState({text});
+ },
+ );
};
}
class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> {
state = {
- text: ''
+ text: '',
};
render() {
@@ -140,34 +131,34 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> {
Click to show the Share ActionSheet
-
- {this.state.text}
-
+ {this.state.text}
);
}
showShareActionSheet = () => {
// Take the snapshot (returns a temp file uri)
- takeSnapshot('window').then((uri) => {
- // Share image data
- ActionSheetIOS.showShareActionSheetWithOptions({
- url: uri,
- excludedActivityTypes: [
- 'com.apple.UIKit.activity.PostToTwitter'
- ]
- },
- (error) => alert(error),
- (completed, method) => {
- var text;
- if (completed) {
- text = `Shared via ${method}`;
- } else {
- text = 'You didn\'t share';
- }
- this.setState({text});
- });
- }).catch((error) => alert(error));
+ takeSnapshot('window')
+ .then(uri => {
+ // Share image data
+ ActionSheetIOS.showShareActionSheetWithOptions(
+ {
+ url: uri,
+ excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
+ },
+ error => alert(error),
+ (completed, method) => {
+ var text;
+ if (completed) {
+ text = `Shared via ${method}`;
+ } else {
+ text = "You didn't share";
+ }
+ this.setState({text});
+ },
+ );
+ })
+ .catch(error => alert(error));
};
}
@@ -175,36 +166,40 @@ var style = StyleSheet.create({
button: {
marginBottom: 10,
fontWeight: '500',
- }
+ },
});
exports.title = 'ActionSheetIOS';
-exports.description = 'Interface to show iOS\' action sheets';
+exports.description = "Interface to show iOS' action sheets";
exports.examples = [
{
title: 'Show Action Sheet',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Show Action Sheet with tinted buttons',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Show Share Action Sheet',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Share Local Image',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Share Screenshot',
render(): React.Element {
return ;
- }
- }
+ },
+ },
];
diff --git a/RNTester/js/ActivityIndicatorExample.js b/RNTester/js/ActivityIndicatorExample.js
index 05c9e06d4..2f81857cf 100644
--- a/RNTester/js/ActivityIndicatorExample.js
+++ b/RNTester/js/ActivityIndicatorExample.js
@@ -4,20 +4,25 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
-import React, { Component } from 'react';
-import { ActivityIndicator, StyleSheet, View } from 'react-native';
+import React, {Component} from 'react';
+import {ActivityIndicator, StyleSheet, View} from 'react-native';
/**
* Optional Flowtype state and timer types definition
*/
-type State = { animating: boolean; };
+type State = {animating: boolean};
type Timer = number;
-class ToggleAnimatingActivityIndicator extends Component<$FlowFixMeProps, State> {
+class ToggleAnimatingActivityIndicator extends Component<
+ $FlowFixMeProps,
+ State,
+> {
_timer: Timer;
constructor(props) {
@@ -59,8 +64,6 @@ class ToggleAnimatingActivityIndicator extends Component<$FlowFixMeProps, State>
}
}
-
-
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '';
@@ -76,22 +79,20 @@ exports.examples = [
color="white"
/>
);
- }
+ },
},
{
title: 'Gray',
render() {
return (
-
+
);
- }
+ },
},
{
title: 'Custom colors',
@@ -104,7 +105,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Large',
@@ -116,38 +117,26 @@ exports.examples = [
color="white"
/>
);
- }
+ },
},
{
title: 'Large, custom colors',
render() {
return (
-
-
-
-
+
+
+
+
);
- }
+ },
},
{
title: 'Start/stop',
render() {
return ;
- }
+ },
},
{
title: 'Custom size',
@@ -158,23 +147,17 @@ exports.examples = [
size="large"
/>
);
- }
+ },
},
{
platform: 'android',
title: 'Custom size (size: 75)',
render() {
- return (
-
- );
- }
+ return ;
+ },
},
];
-
const styles = StyleSheet.create({
centering: {
alignItems: 'center',
diff --git a/RNTester/js/AlertExample.js b/RNTester/js/AlertExample.js
index dee922a66..02382e769 100644
--- a/RNTester/js/AlertExample.js
+++ b/RNTester/js/AlertExample.js
@@ -4,25 +4,21 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Alert,
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
-} = ReactNative;
+var {Alert, StyleSheet, Text, TouchableHighlight, View} = ReactNative;
var RNTesterBlock = require('./RNTesterBlock');
// corporate ipsum > lorem ipsum
-var alertMessage = 'Credibly reintermediate next-generation potentialities after goal-oriented ' +
- 'catalysts for change. Dynamically revolutionize.';
+var alertMessage =
+ 'Credibly reintermediate next-generation potentialities after goal-oriented ' +
+ 'catalysts for change. Dynamically revolutionize.';
/**
* Simple alert examples.
@@ -31,90 +27,88 @@ class SimpleAlertExampleBlock extends React.Component {
render() {
return (
- Alert.alert(
- 'Alert Title',
- alertMessage,
- )}>
+ Alert.alert('Alert Title', alertMessage)}>
Alert with message and default button
- Alert.alert(
- 'Alert Title',
- alertMessage,
- [
+
+ Alert.alert('Alert Title', alertMessage, [
{text: 'OK', onPress: () => console.log('OK Pressed!')},
- ]
- )}>
+ ])
+ }>
Alert with one button
- Alert.alert(
- 'Alert Title',
- alertMessage,
- [
+
+ Alert.alert('Alert Title', alertMessage, [
{text: 'Cancel', onPress: () => console.log('Cancel Pressed!')},
{text: 'OK', onPress: () => console.log('OK Pressed!')},
- ]
- )}>
+ ])
+ }>
Alert with two buttons
- Alert.alert(
- 'Alert Title',
- null,
- [
+
+ Alert.alert('Alert Title', null, [
{text: 'Foo', onPress: () => console.log('Foo Pressed!')},
{text: 'Bar', onPress: () => console.log('Bar Pressed!')},
{text: 'Baz', onPress: () => console.log('Baz Pressed!')},
- ]
- )}>
+ ])
+ }>
Alert with three buttons
- Alert.alert(
- 'Foo Title',
- alertMessage,
- '..............'.split('').map((dot, index) => ({
- text: 'Button ' + index,
- onPress: () => console.log('Pressed ' + index)
- }))
- )}>
+
+ Alert.alert(
+ 'Foo Title',
+ alertMessage,
+ '..............'.split('').map((dot, index) => ({
+ text: 'Button ' + index,
+ onPress: () => console.log('Pressed ' + index),
+ })),
+ )
+ }>
Alert with too many buttons
- Alert.alert(
- 'Alert Title',
- null,
- [
- {text: 'OK', onPress: () => console.log('OK Pressed!')},
- ],
- {
- cancelable: false
- }
- )}>
+
+ Alert.alert(
+ 'Alert Title',
+ null,
+ [{text: 'OK', onPress: () => console.log('OK Pressed!')}],
+ {
+ cancelable: false,
+ },
+ )
+ }>
Alert that cannot be dismissed
- Alert.alert(
- '',
- alertMessage,
- [
+
+ Alert.alert('', alertMessage, [
{text: 'OK', onPress: () => console.log('OK Pressed!')},
- ]
- )}>
+ ])
+ }>
Alert without title
diff --git a/RNTester/js/AlertIOSExample.js b/RNTester/js/AlertIOSExample.js
index 8f4a898a5..4f58c00ad 100644
--- a/RNTester/js/AlertIOSExample.js
+++ b/RNTester/js/AlertIOSExample.js
@@ -4,79 +4,69 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- View,
- Text,
- TouchableHighlight,
- AlertIOS,
-} = ReactNative;
+var {StyleSheet, View, Text, TouchableHighlight, AlertIOS} = ReactNative;
-var { SimpleAlertExampleBlock } = require('./AlertExample');
+var {SimpleAlertExampleBlock} = require('./AlertExample');
exports.framework = 'React';
exports.title = 'AlertIOS';
exports.description = 'iOS alerts and action sheets';
-exports.examples = [{
- title: 'Alerts',
- render() {
- return ;
- }
-},
-{
- title: 'Prompt Options',
- render(): React.Element {
- return ;
- }
-},
-{
- title: 'Prompt Types',
- render() {
- return (
-
- AlertIOS.prompt('Plain Text Entry')}>
-
-
-
- plain-text
-
-
-
-
- AlertIOS.prompt('Secure Text', null, null, 'secure-text')}>
-
-
-
- secure-text
-
-
-
-
- AlertIOS.prompt('Login & Password', null, null, 'login-password')}>
-
-
-
- login-password
-
-
-
-
-
- );
- }
-}];
+exports.examples = [
+ {
+ title: 'Alerts',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Prompt Options',
+ render(): React.Element {
+ return ;
+ },
+ },
+ {
+ title: 'Prompt Types',
+ render() {
+ return (
+
+ AlertIOS.prompt('Plain Text Entry')}>
+
+ plain-text
+
+
+
+ AlertIOS.prompt('Secure Text', null, null, 'secure-text')
+ }>
+
+ secure-text
+
+
+
+ AlertIOS.prompt('Login & Password', null, null, 'login-password')
+ }>
+
+ login-password
+
+
+
+ );
+ },
+ },
+];
class PromptOptions extends React.Component<$FlowFixMeProps, any> {
customButtons: Array
);
}
@@ -37,18 +37,36 @@ class Button extends React.Component<$FlowFixMeProps> {
class NotificationExample extends React.Component<{}> {
UNSAFE_componentWillMount() {
PushNotificationIOS.addEventListener('register', this._onRegistered);
- PushNotificationIOS.addEventListener('registrationError', this._onRegistrationError);
- PushNotificationIOS.addEventListener('notification', this._onRemoteNotification);
- PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification);
+ PushNotificationIOS.addEventListener(
+ 'registrationError',
+ this._onRegistrationError,
+ );
+ PushNotificationIOS.addEventListener(
+ 'notification',
+ this._onRemoteNotification,
+ );
+ PushNotificationIOS.addEventListener(
+ 'localNotification',
+ this._onLocalNotification,
+ );
PushNotificationIOS.requestPermissions();
}
componentWillUnmount() {
PushNotificationIOS.removeEventListener('register', this._onRegistered);
- PushNotificationIOS.removeEventListener('registrationError', this._onRegistrationError);
- PushNotificationIOS.removeEventListener('notification', this._onRemoteNotification);
- PushNotificationIOS.removeEventListener('localNotification', this._onLocalNotification);
+ PushNotificationIOS.removeEventListener(
+ 'registrationError',
+ this._onRegistrationError,
+ );
+ PushNotificationIOS.removeEventListener(
+ 'notification',
+ this._onRemoteNotification,
+ );
+ PushNotificationIOS.removeEventListener(
+ 'localNotification',
+ this._onLocalNotification,
+ );
}
render() {
@@ -86,7 +104,7 @@ class NotificationExample extends React.Component<{}> {
alert: 'Sample local notification',
badge: '+1',
sound: 'default',
- category: 'REACT_NATIVE'
+ category: 'REACT_NATIVE',
},
});
}
@@ -95,10 +113,12 @@ class NotificationExample extends React.Component<{}> {
AlertIOS.alert(
'Registered For Remote Push',
`Device Token: ${deviceToken}`,
- [{
- text: 'Dismiss',
- onPress: null,
- }]
+ [
+ {
+ text: 'Dismiss',
+ onPress: null,
+ },
+ ],
);
}
@@ -106,10 +126,12 @@ class NotificationExample extends React.Component<{}> {
AlertIOS.alert(
'Failed To Register For Remote Push',
`Error (${error.code}): ${error.message}`,
- [{
- text: 'Dismiss',
- onPress: null,
- }]
+ [
+ {
+ text: 'Dismiss',
+ onPress: null,
+ },
+ ],
);
}
@@ -120,29 +142,32 @@ class NotificationExample extends React.Component<{}> {
category: ${notification.getCategory()};\n
content-available: ${notification.getContentAvailable()}.`;
- AlertIOS.alert(
- 'Push Notification Received',
- result,
- [{
+ AlertIOS.alert('Push Notification Received', result, [
+ {
text: 'Dismiss',
onPress: null,
- }]
- );
+ },
+ ]);
}
- _onLocalNotification(notification){
+ _onLocalNotification(notification) {
AlertIOS.alert(
'Local Notification Received',
'Alert message: ' + notification.getMessage(),
- [{
- text: 'Dismiss',
- onPress: null,
- }]
+ [
+ {
+ text: 'Dismiss',
+ onPress: null,
+ },
+ ],
);
}
}
-class NotificationPermissionExample extends React.Component<$FlowFixMeProps, any> {
+class NotificationPermissionExample extends React.Component<
+ $FlowFixMeProps,
+ any,
+> {
constructor(props) {
super(props);
this.state = {permissions: null};
@@ -155,15 +180,13 @@ class NotificationPermissionExample extends React.Component<$FlowFixMeProps, any
onPress={this._showPermissions.bind(this)}
label="Show enabled permissions"
/>
-
- {JSON.stringify(this.state.permissions)}
-
+ {JSON.stringify(this.state.permissions)}
);
}
_showPermissions() {
- PushNotificationIOS.checkPermissions((permissions) => {
+ PushNotificationIOS.checkPermissions(permissions => {
this.setState({permissions});
});
}
@@ -183,32 +206,35 @@ var styles = StyleSheet.create({
exports.title = 'PushNotificationIOS';
exports.description = 'Apple PushNotification and badge value';
exports.examples = [
-{
- title: 'Badge Number',
- render(): React.Element {
- return (
-
-
- );
+ {
+ title: 'Badge Number',
+ render(): React.Element {
+ return (
+
+
+ PushNotificationIOS.setApplicationIconBadgeNumber(42)
+ }
+ label="Set app's icon badge to 42"
+ />
+ PushNotificationIOS.setApplicationIconBadgeNumber(0)}
+ label="Clear app's icon badge"
+ />
+
+ );
+ },
},
-},
-{
- title: 'Push Notifications',
- render(): React.Element {
- return ;
- }
-},
-{
- title: 'Notifications Permissions',
- render(): React.Element {
- return ;
- }
-}];
+ {
+ title: 'Push Notifications',
+ render(): React.Element {
+ return ;
+ },
+ },
+ {
+ title: 'Notifications Permissions',
+ render(): React.Element {
+ return ;
+ },
+ },
+];
diff --git a/RNTester/js/RCTRootViewIOSExample.js b/RNTester/js/RCTRootViewIOSExample.js
index 5eba0e8ca..0314507bc 100644
--- a/RNTester/js/RCTRootViewIOSExample.js
+++ b/RNTester/js/RCTRootViewIOSExample.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -11,22 +12,21 @@
const React = require('react');
const ReactNative = require('react-native');
-const {
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+const {StyleSheet, Text, View} = ReactNative;
const requireNativeComponent = require('requireNativeComponent');
class AppPropertiesUpdateExample extends React.Component<{}> {
render() {
// Do not require this unless we are actually rendering.
- const UpdatePropertiesExampleView = requireNativeComponent('UpdatePropertiesExampleView');
+ const UpdatePropertiesExampleView = requireNativeComponent(
+ 'UpdatePropertiesExampleView',
+ );
return (
- Press the button to update the field below by passing new properties to the RN app.
+ Press the button to update the field below by passing new properties
+ to the RN app.
@@ -41,11 +41,14 @@ class AppPropertiesUpdateExample extends React.Component<{}> {
class RootViewSizeFlexibilityExample extends React.Component<{}> {
render() {
// Do not require this unless we are actually rendering.
- const FlexibleSizeExampleView = requireNativeComponent('FlexibleSizeExampleView');
+ const FlexibleSizeExampleView = requireNativeComponent(
+ 'FlexibleSizeExampleView',
+ );
return (
- Press the button to resize it. On resize, RCTRootViewDelegate is notified. You can use it to handle content size updates.
+ Press the button to resize it. On resize, RCTRootViewDelegate is
+ notified. You can use it to handle content size updates.
@@ -63,30 +66,28 @@ const styles = StyleSheet.create({
backgroundColor: '#F5FCFF',
},
text: {
- marginBottom: 20
+ marginBottom: 20,
},
nativeView: {
height: 140,
- width: 280
- }
+ width: 280,
+ },
});
exports.title = 'RCTRootView';
-exports.description = 'Examples that show useful methods when embedding React Native in a native application';
+exports.description =
+ 'Examples that show useful methods when embedding React Native in a native application';
exports.examples = [
-{
- title: 'Updating app properties in runtime',
- render(): React.Element {
- return (
-
- );
+ {
+ title: 'Updating app properties in runtime',
+ render(): React.Element {
+ return ;
+ },
},
-},
-{
- title: 'RCTRootView\'s size flexibility',
- render(): React.Element {
- return (
-
- );
+ {
+ title: "RCTRootView's size flexibility",
+ render(): React.Element {
+ return ;
+ },
},
-}];
+];
diff --git a/RNTester/js/RNTesterActions.js b/RNTester/js/RNTesterActions.js
index cc89277dc..69fc8b9ea 100644
--- a/RNTester/js/RNTesterActions.js
+++ b/RNTester/js/RNTesterActions.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
export type RNTesterBackAction = {
@@ -21,12 +23,10 @@ export type RNTesterExampleAction = {
openExample: string,
};
-export type RNTesterAction = (
- RNTesterBackAction |
- RNTesterListAction |
- RNTesterExampleAction
-);
-
+export type RNTesterAction =
+ | RNTesterBackAction
+ | RNTesterListAction
+ | RNTesterExampleAction;
function Back(): RNTesterBackAction {
return {
diff --git a/RNTester/js/RNTesterApp.android.js b/RNTester/js/RNTesterApp.android.js
index ad377b85a..42c43b81a 100644
--- a/RNTester/js/RNTesterApp.android.js
+++ b/RNTester/js/RNTesterApp.android.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const AppRegistry = require('AppRegistry');
@@ -29,7 +31,7 @@ const View = require('View');
const nativeImageSource = require('nativeImageSource');
-import type { RNTesterNavigationState } from './RNTesterNavigationReducer';
+import type {RNTesterNavigationState} from './RNTesterNavigationReducer';
UIManager.setLayoutAnimationEnabledExperimental(true);
@@ -44,24 +46,29 @@ const APP_STATE_KEY = 'RNTesterAppState.v2';
const HEADER_LOGO_ICON = nativeImageSource({
android: 'launcher_icon',
width: 132,
- height: 144
+ height: 144,
});
const HEADER_NAV_ICON = nativeImageSource({
android: 'ic_menu_black_24dp',
width: 48,
- height: 48
+ height: 48,
});
class RNTesterApp extends React.Component {
UNSAFE_componentWillMount() {
- BackHandler.addEventListener('hardwareBackPress', this._handleBackButtonPress);
+ BackHandler.addEventListener(
+ 'hardwareBackPress',
+ this._handleBackButtonPress,
+ );
}
componentDidMount() {
- Linking.getInitialURL().then((url) => {
+ Linking.getInitialURL().then(url => {
AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
- const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams);
+ const exampleAction = URIActionMap(
+ this.props.exampleFromAppetizeParams,
+ );
const urlAction = URIActionMap(url);
const launchAction = exampleAction || urlAction;
if (err || !storedString) {
@@ -94,7 +101,9 @@ class RNTesterApp extends React.Component {
onDrawerClose={() => {
this._overrideBackPressForDrawerLayout = false;
}}
- ref={(drawer) => { this.drawer = drawer; }}
+ ref={drawer => {
+ this.drawer = drawer;
+ }}
renderNavigationView={this._renderDrawerContent}
statusBarBackgroundColor="#589c90">
{this._renderApp()}
@@ -116,9 +125,7 @@ class RNTesterApp extends React.Component {
};
_renderApp() {
- const {
- openExample,
- } = this.state;
+ const {openExample} = this.state;
if (openExample) {
const ExampleModule = RNTesterList.Modules[openExample];
@@ -128,7 +135,9 @@ class RNTesterApp extends React.Component {
onExampleExit={() => {
this._handleAction(RNTesterActions.Back());
}}
- ref={(example) => { this._exampleRef = example; }}
+ ref={example => {
+ this._exampleRef = example;
+ }}
/>
);
} else if (ExampleModule) {
@@ -143,7 +152,9 @@ class RNTesterApp extends React.Component {
/>
{ this._exampleRef = example; }}
+ ref={example => {
+ this._exampleRef = example;
+ }}
/>
);
@@ -171,9 +182,8 @@ class RNTesterApp extends React.Component {
this.drawer && this.drawer.closeDrawer();
const newState = RNTesterNavigationReducer(this.state, action);
if (this.state !== newState) {
- this.setState(
- newState,
- () => AsyncStorage.setItem(APP_STATE_KEY, JSON.stringify(this.state))
+ this.setState(newState, () =>
+ AsyncStorage.setItem(APP_STATE_KEY, JSON.stringify(this.state)),
);
return true;
}
diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js
index a72ebb724..7d5b1a1b2 100644
--- a/RNTester/js/RNTesterApp.ios.js
+++ b/RNTester/js/RNTesterApp.ios.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const AsyncStorage = require('AsyncStorage');
@@ -27,12 +29,12 @@ const {
StyleSheet,
Text,
View,
- SafeAreaView
+ SafeAreaView,
} = ReactNative;
-import type { RNTesterExample } from './RNTesterList.ios';
-import type { RNTesterAction } from './RNTesterActions';
-import type { RNTesterNavigationState } from './RNTesterNavigationReducer';
+import type {RNTesterExample} from './RNTesterList.ios';
+import type {RNTesterAction} from './RNTesterActions';
+import type {RNTesterNavigationState} from './RNTesterNavigationReducer';
type Props = {
exampleFromAppetizeParams: string,
@@ -40,15 +42,17 @@ type Props = {
const APP_STATE_KEY = 'RNTesterAppState.v2';
-const Header = ({ onBack, title }: { onBack?: () => mixed, title: string }) => (
+const Header = ({onBack, title}: {onBack?: () => mixed, title: string}) => (
{title}
- {onBack &&
-
- }
+ {onBack && (
+
+
+
+ )}
);
@@ -59,9 +63,11 @@ class RNTesterApp extends React.Component {
}
componentDidMount() {
- Linking.getInitialURL().then((url) => {
+ Linking.getInitialURL().then(url => {
AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => {
- const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams);
+ const exampleAction = URIActionMap(
+ this.props.exampleFromAppetizeParams,
+ );
const urlAction = URIActionMap(url);
const launchAction = exampleAction || urlAction;
if (err || !storedString) {
@@ -78,14 +84,14 @@ class RNTesterApp extends React.Component {
});
});
- Linking.addEventListener('url', (url) => {
+ Linking.addEventListener('url', url => {
this._handleAction(URIActionMap(url));
});
}
_handleBack = () => {
this._handleAction(RNTesterActions.Back());
- }
+ };
_handleAction = (action: ?RNTesterAction) => {
if (!action) {
@@ -93,12 +99,11 @@ class RNTesterApp extends React.Component {
}
const newState = RNTesterNavigationReducer(this.state, action);
if (this.state !== newState) {
- this.setState(
- newState,
- () => AsyncStorage.setItem(APP_STATE_KEY, JSON.stringify(this.state))
+ this.setState(newState, () =>
+ AsyncStorage.setItem(APP_STATE_KEY, JSON.stringify(this.state)),
);
}
- }
+ };
render() {
if (!this.state) {
@@ -107,11 +112,7 @@ class RNTesterApp extends React.Component {
if (this.state.openExample) {
const Component = RNTesterList.Modules[this.state.openExample];
if (Component.external) {
- return (
-
- );
+ return ;
} else {
return (
@@ -120,7 +121,6 @@ class RNTesterApp extends React.Component {
);
}
-
}
return (
@@ -145,10 +145,9 @@ const styles = StyleSheet.create({
},
header: {
height: 40,
- flexDirection: 'row'
- },
- headerLeft: {
+ flexDirection: 'row',
},
+ headerLeft: {},
headerCenter: {
flex: 1,
position: 'absolute',
@@ -166,26 +165,35 @@ const styles = StyleSheet.create({
},
});
-AppRegistry.registerComponent('SetPropertiesExampleApp', () => require('./SetPropertiesExampleApp'));
-AppRegistry.registerComponent('RootViewSizeFlexibilityExampleApp', () => require('./RootViewSizeFlexibilityExampleApp'));
+AppRegistry.registerComponent('SetPropertiesExampleApp', () =>
+ require('./SetPropertiesExampleApp'),
+);
+AppRegistry.registerComponent('RootViewSizeFlexibilityExampleApp', () =>
+ require('./RootViewSizeFlexibilityExampleApp'),
+);
AppRegistry.registerComponent('RNTesterApp', () => RNTesterApp);
// Register suitable examples for snapshot tests
-RNTesterList.ComponentExamples.concat(RNTesterList.APIExamples).forEach((Example: RNTesterExample) => {
- const ExampleModule = Example.module;
- if (ExampleModule.displayName) {
- class Snapshotter extends React.Component<{}> {
- render() {
- return (
-
-
-
- );
+RNTesterList.ComponentExamples.concat(RNTesterList.APIExamples).forEach(
+ (Example: RNTesterExample) => {
+ const ExampleModule = Example.module;
+ if (ExampleModule.displayName) {
+ class Snapshotter extends React.Component<{}> {
+ render() {
+ return (
+
+
+
+ );
+ }
}
- }
- AppRegistry.registerComponent(ExampleModule.displayName, () => Snapshotter);
- }
-});
+ AppRegistry.registerComponent(
+ ExampleModule.displayName,
+ () => Snapshotter,
+ );
+ }
+ },
+);
module.exports = RNTesterApp;
diff --git a/RNTester/js/RNTesterBlock.js b/RNTester/js/RNTesterBlock.js
index fa3c44f78..591b26b68 100644
--- a/RNTester/js/RNTesterBlock.js
+++ b/RNTester/js/RNTesterBlock.js
@@ -4,23 +4,24 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var PropTypes = require('prop-types');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, Text, View} = ReactNative;
-class RNTesterBlock extends React.Component<{
- title?: string,
- description?: string,
-}, $FlowFixMeState> {
+class RNTesterBlock extends React.Component<
+ {
+ title?: string,
+ description?: string,
+ },
+ $FlowFixMeState,
+> {
static propTypes = {
title: PropTypes.string,
description: PropTypes.string,
@@ -31,24 +32,22 @@ class RNTesterBlock extends React.Component<{
render() {
var description;
if (this.props.description) {
- description =
-
- {this.props.description}
- ;
+ description = (
+ {this.props.description}
+ );
}
return (
-
- {this.props.title}
-
+ {this.props.title}
{description}
{
// $FlowFixMe found when converting React.createClass to ES6
- this.props.children}
+ this.props.children
+ }
);
@@ -93,7 +92,7 @@ var styles = StyleSheet.create({
},
children: {
margin: 10,
- }
+ },
});
module.exports = RNTesterBlock;
diff --git a/RNTester/js/RNTesterButton.js b/RNTester/js/RNTesterButton.js
index 9ac5f6e8e..57ac204b2 100644
--- a/RNTester/js/RNTesterButton.js
+++ b/RNTester/js/RNTesterButton.js
@@ -4,18 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var PropTypes = require('prop-types');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- TouchableHighlight,
-} = ReactNative;
+var {StyleSheet, Text, TouchableHighlight} = ReactNative;
class RNTesterButton extends React.Component<{onPress?: Function}> {
static propTypes = {
@@ -31,7 +29,8 @@ class RNTesterButton extends React.Component<{onPress?: Function}> {
{
// $FlowFixMe found when converting React.createClass to ES6
- this.props.children}
+ this.props.children
+ }
);
diff --git a/RNTester/js/RNTesterExampleContainer.js b/RNTester/js/RNTesterExampleContainer.js
index 02e010771..0b3e3d233 100644
--- a/RNTester/js/RNTesterExampleContainer.js
+++ b/RNTester/js/RNTesterExampleContainer.js
@@ -4,13 +4,13 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
const React = require('react');
-const {
- Platform,
-} = require('react-native');
+const {Platform} = require('react-native');
const RNTesterBlock = require('./RNTesterBlock');
const RNTesterPage = require('./RNTesterPage');
@@ -25,10 +25,7 @@ class RNTesterExampleContainer extends React.Component {
title += ' (' + platform + ' only)';
}
return (
-
+
{example.render()}
);
diff --git a/RNTester/js/RNTesterExampleList.js b/RNTester/js/RNTesterExampleList.js
index c7d974c48..d031caef4 100644
--- a/RNTester/js/RNTesterExampleList.js
+++ b/RNTester/js/RNTesterExampleList.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const Platform = require('Platform');
@@ -53,34 +55,29 @@ class RowComponent extends React.PureComponent<{
return (
-
- {item.module.title}
-
-
- {item.module.description}
-
+ {item.module.title}
+ {item.module.description}
);
}
}
-const renderSectionHeader = ({section}) =>
-
- {section.title}
- ;
+const renderSectionHeader = ({section}) => (
+ {section.title}
+);
class RNTesterExampleList extends React.Component {
render() {
const filterText = this.props.persister.state.filter;
const filterRegex = new RegExp(String(filterText), 'i');
- const filter = (example) =>
+ const filter = example =>
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.68 was deployed. To see the error delete this
* comment and run Flow. */
this.props.disableSearch ||
- filterRegex.test(example.module.title) &&
- (!Platform.isTVOS || example.supportsTVOS);
+ (filterRegex.test(example.module.title) &&
+ (!Platform.isTVOS || example.supportsTVOS));
const sections = [
{
@@ -138,10 +135,12 @@ class RNTesterExampleList extends React.Component {
}
return (
{
this.props.onNavigate(RNTesterActions.ExampleList());
@@ -185,10 +184,13 @@ const ItemSeparator = ({highlighted}) => (
);
-RNTesterExampleList = RNTesterStatePersister.createContainer(RNTesterExampleList, {
- cacheKeySuffix: () => 'mainList',
- getInitialState: () => ({filter: ''}),
-});
+RNTesterExampleList = RNTesterStatePersister.createContainer(
+ RNTesterExampleList,
+ {
+ cacheKeySuffix: () => 'mainList',
+ getInitialState: () => ({filter: ''}),
+ },
+);
const styles = StyleSheet.create({
listContainer: {
diff --git a/RNTester/js/RNTesterList.android.js b/RNTester/js/RNTesterList.android.js
index d038354b2..8e8f6b791 100644
--- a/RNTester/js/RNTesterList.android.js
+++ b/RNTester/js/RNTesterList.android.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
export type RNTesterExample = {
@@ -84,11 +86,11 @@ const ComponentExamples: Array = [
},
{
key: 'SwipeableFlatListExample',
- module: require('./SwipeableFlatListExample')
+ module: require('./SwipeableFlatListExample'),
},
{
key: 'SwipeableListViewExample',
- module: require('./SwipeableListViewExample')
+ module: require('./SwipeableListViewExample'),
},
{
key: 'SwitchExample',
diff --git a/RNTester/js/RNTesterList.ios.js b/RNTester/js/RNTesterList.ios.js
index 812abde4f..f7a62efaa 100644
--- a/RNTester/js/RNTesterList.ios.js
+++ b/RNTester/js/RNTesterList.ios.js
@@ -4,14 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
export type RNTesterExample = {
key: string,
module: Object,
- supportsTVOS: boolean
+ supportsTVOS: boolean,
};
const ComponentExamples: Array = [
diff --git a/RNTester/js/RNTesterNavigationReducer.js b/RNTester/js/RNTesterNavigationReducer.js
index 60c21a710..7dc222eee 100644
--- a/RNTester/js/RNTesterNavigationReducer.js
+++ b/RNTester/js/RNTesterNavigationReducer.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// $FlowFixMe : This is a platform-forked component, and flow seems to only run on iOS?
@@ -17,16 +19,13 @@ export type RNTesterNavigationState = {
function RNTesterNavigationReducer(
state: ?RNTesterNavigationState,
- action: any
+ action: any,
): RNTesterNavigationState {
-
if (
// Default value is to see example list
!state ||
-
// Handle the explicit list action
action.type === 'RNTesterListAction' ||
-
// Handle requests to go back to the list when an example is open
(state.openExample && action.type === 'RNTesterBackAction')
) {
@@ -37,7 +36,6 @@ function RNTesterNavigationReducer(
}
if (action.type === 'RNTesterExampleAction') {
-
// Make sure we see the module before returning the new state
const ExampleModule = RNTesterList.Modules[action.openExample];
diff --git a/RNTester/js/RNTesterPage.js b/RNTester/js/RNTesterPage.js
index 4af103ea8..580bd9598 100644
--- a/RNTester/js/RNTesterPage.js
+++ b/RNTester/js/RNTesterPage.js
@@ -4,18 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var PropTypes = require('prop-types');
var React = require('react');
var ReactNative = require('react-native');
-var {
- ScrollView,
- StyleSheet,
- View,
-} = ReactNative;
+var {ScrollView, StyleSheet, View} = ReactNative;
var RNTesterTitle = require('./RNTesterTitle');
@@ -43,20 +41,19 @@ class RNTesterPage extends React.Component<{
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an
* error found when Flow v0.68 was deployed. To see the error delete this
* comment and run Flow. */
- var title = this.props.title ?
- :
- null;
+ var title = this.props.title ? (
+
+ ) : null;
var spacer = this.props.noSpacer ? null : ;
return (
{title}
-
- {
- // $FlowFixMe found when converting React.createClass to ES6
- this.props.children}
- {spacer}
+
+ {
+ // $FlowFixMe found when converting React.createClass to ES6
+ this.props.children
+ }
+ {spacer}
);
diff --git a/RNTester/js/RNTesterSettingSwitchRow.js b/RNTester/js/RNTesterSettingSwitchRow.js
index 01cca6336..423ccf23b 100644
--- a/RNTester/js/RNTesterSettingSwitchRow.js
+++ b/RNTester/js/RNTesterSettingSwitchRow.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('React');
@@ -15,7 +17,10 @@ const Text = require('Text');
const RNTesterStatePersister = require('./RNTesterStatePersister');
const View = require('View');
-class RNTesterSettingSwitchRow extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class RNTesterSettingSwitchRow extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
UNSAFE_componentWillReceiveProps(newProps) {
const {onEnable, onDisable, persister} = this.props;
if (newProps.persister.state !== persister.state) {
@@ -29,7 +34,7 @@ class RNTesterSettingSwitchRow extends React.Component<$FlowFixMeProps, $FlowFix
{label}
{
+ onValueChange={value => {
persister.setState(() => value);
}}
/>
@@ -44,8 +49,11 @@ const styles = StyleSheet.create({
justifyContent: 'space-between',
},
});
-RNTesterSettingSwitchRow = RNTesterStatePersister.createContainer(RNTesterSettingSwitchRow, {
- cacheKeySuffix: ({label}) => 'Switch:' + label,
- getInitialState: ({initialValue}) => initialValue,
-});
+RNTesterSettingSwitchRow = RNTesterStatePersister.createContainer(
+ RNTesterSettingSwitchRow,
+ {
+ cacheKeySuffix: ({label}) => 'Switch:' + label,
+ getInitialState: ({initialValue}) => initialValue,
+ },
+);
module.exports = RNTesterSettingSwitchRow;
diff --git a/RNTester/js/RNTesterStatePersister.js b/RNTester/js/RNTesterStatePersister.js
index 455f42922..fb697e7d7 100644
--- a/RNTester/js/RNTesterStatePersister.js
+++ b/RNTester/js/RNTesterStatePersister.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const AsyncStorage = require('AsyncStorage');
@@ -34,13 +36,19 @@ function createContainer(
version?: string,
},
): React.ComponentType {
- return class ComponentWithPersistedState extends React.Component {
+ return class ComponentWithPersistedState extends React.Component<
+ Props,
+ $FlowFixMeState,
+ > {
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment
* suppresses an error when upgrading Flow's support for React. To see the
* error delete this comment and run Flow. */
- static displayName = `RNTesterStatePersister(${Component.displayName || Component.name})`;
+ static displayName = `RNTesterStatePersister(${Component.displayName ||
+ Component.name})`;
state = {value: spec.getInitialState(this.props)};
- _cacheKey = `RNTester:${spec.version || 'v1'}:${spec.cacheKeySuffix(this.props)}`;
+ _cacheKey = `RNTester:${spec.version || 'v1'}:${spec.cacheKeySuffix(
+ this.props,
+ )}`;
componentDidMount() {
AsyncStorage.getItem(this._cacheKey, (err, value) => {
if (!err && value) {
@@ -49,7 +57,7 @@ function createContainer(
});
}
_passSetState = (stateLamda: (state: State) => State): void => {
- this.setState((state) => {
+ this.setState(state => {
const value = stateLamda(state.value);
AsyncStorage.setItem(this._cacheKey, JSON.stringify(value));
return {value};
diff --git a/RNTester/js/RNTesterTitle.js b/RNTester/js/RNTesterTitle.js
index 17687d98b..39d36a3a0 100644
--- a/RNTester/js/RNTesterTitle.js
+++ b/RNTester/js/RNTesterTitle.js
@@ -4,25 +4,21 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, Text, View} = ReactNative;
class RNTesterTitle extends React.Component<$FlowFixMeProps> {
render() {
return (
-
- {this.props.title}
-
+ {this.props.title}
);
}
diff --git a/RNTester/js/RefreshControlExample.js b/RNTester/js/RefreshControlExample.js
index 055a85c5f..bb69fff63 100644
--- a/RNTester/js/RefreshControlExample.js
+++ b/RNTester/js/RefreshControlExample.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
const React = require('react');
@@ -42,7 +44,7 @@ class Row extends React.Component {
render() {
return (
-
+
{this.props.data.text + ' (' + this.props.data.clicks + ' clicks)'}
@@ -60,11 +62,13 @@ class RefreshControlExample extends React.Component {
state = {
isRefreshing: false,
loaded: 0,
- rowData: Array.from(new Array(20)).map(
- (val, i) => ({text: 'Initial row ' + i, clicks: 0})),
+ rowData: Array.from(new Array(20)).map((val, i) => ({
+ text: 'Initial row ' + i,
+ clicks: 0,
+ })),
};
- _onClick = (row) => {
+ _onClick = row => {
row.clicks++;
this.setState({
rowData: this.state.rowData,
@@ -73,7 +77,7 @@ class RefreshControlExample extends React.Component {
render() {
const rows = this.state.rowData.map((row, ii) => {
- return ;
+ return
;
});
return (
{
// prepend 10 items
const rowData = Array.from(new Array(10))
- .map((val, i) => ({
- text: 'Loaded row ' + (+this.state.loaded + i),
- clicks: 0,
- }))
- .concat(this.state.rowData);
+ .map((val, i) => ({
+ text: 'Loaded row ' + (+this.state.loaded + i),
+ clicks: 0,
+ }))
+ .concat(this.state.rowData);
this.setState({
loaded: this.state.loaded + 10,
diff --git a/RNTester/js/RootViewSizeFlexibilityExampleApp.js b/RNTester/js/RootViewSizeFlexibilityExampleApp.js
index c08a2ec57..bfcce23e6 100644
--- a/RNTester/js/RootViewSizeFlexibilityExampleApp.js
+++ b/RNTester/js/RootViewSizeFlexibilityExampleApp.js
@@ -4,39 +4,39 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
const ReactNative = require('react-native');
-const {
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
-} = ReactNative;
+const {StyleSheet, Text, TouchableHighlight, View} = ReactNative;
-class RootViewSizeFlexibilityExampleApp extends React.Component<{toggled: boolean}, any> {
+class RootViewSizeFlexibilityExampleApp extends React.Component<
+ {toggled: boolean},
+ any,
+> {
constructor(props: {toggled: boolean}) {
super(props);
- this.state = { toggled: false };
+ this.state = {toggled: false};
}
_onPressButton() {
- this.setState({ toggled: !this.state.toggled });
+ this.setState({toggled: !this.state.toggled});
}
render() {
- const viewStyle = this.state.toggled ? styles.bigContainer : styles.smallContainer;
+ const viewStyle = this.state.toggled
+ ? styles.bigContainer
+ : styles.smallContainer;
return (
-
- React Native Button
-
+ React Native Button
@@ -62,7 +62,7 @@ const styles = StyleSheet.create({
},
whiteText: {
color: 'white',
- }
+ },
});
module.exports = RootViewSizeFlexibilityExampleApp;
diff --git a/RNTester/js/ScrollViewSimpleExample.js b/RNTester/js/ScrollViewSimpleExample.js
index a4fc25fe1..85c414747 100644
--- a/RNTester/js/ScrollViewSimpleExample.js
+++ b/RNTester/js/ScrollViewSimpleExample.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- ScrollView,
- StyleSheet,
- Text,
- TouchableOpacity
-} = ReactNative;
+var {ScrollView, StyleSheet, Text, TouchableOpacity} = ReactNative;
var NUM_ITEMS = 20;
@@ -26,11 +23,11 @@ class ScrollViewSimpleExample extends React.Component<{}> {
makeItems = (nItems: number, styles): Array => {
var items = [];
for (var i = 0; i < nItems; i++) {
- items[i] = (
-
- {'Item ' + i}
-
- );
+ items[i] = (
+
+ {'Item ' + i}
+
+ );
}
return items;
};
@@ -40,7 +37,10 @@ class ScrollViewSimpleExample extends React.Component<{}> {
var items = this.makeItems(NUM_ITEMS, styles.itemWrapper);
items[4] = (
- {this.makeItems(NUM_ITEMS, [styles.itemWrapper, styles.horizontalItemWrapper])}
+ {this.makeItems(NUM_ITEMS, [
+ styles.itemWrapper,
+ styles.horizontalItemWrapper,
+ ])}
);
items.push(
@@ -48,20 +48,17 @@ class ScrollViewSimpleExample extends React.Component<{}> {
key={'scrollViewSnap'}
horizontal
snapToInterval={210.0}
- pagingEnabled
- >
+ pagingEnabled>
{this.makeItems(NUM_ITEMS, [
styles.itemWrapper,
styles.horizontalItemWrapper,
styles.horizontalPagingItemWrapper,
])}
-
+ ,
);
var verticalScrollView = (
-
- {items}
-
+ {items}
);
return verticalScrollView;
@@ -82,7 +79,7 @@ var styles = StyleSheet.create({
margin: 5,
},
horizontalItemWrapper: {
- padding: 50
+ padding: 50,
},
horizontalPagingItemWrapper: {
width: 200,
diff --git a/RNTester/js/SectionListExample.js b/RNTester/js/SectionListExample.js
index 541025185..5d3f73f70 100644
--- a/RNTester/js/SectionListExample.js
+++ b/RNTester/js/SectionListExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
@@ -60,7 +62,11 @@ const renderSectionFooter = ({section}) => (
);
const CustomSeparatorComponent = ({highlighted, text}) => (
-
+
{text}
);
@@ -80,39 +86,38 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
_scrollPos = new Animated.Value(0);
_scrollSinkY = Animated.event(
- [{nativeEvent: { contentOffset: { y: this._scrollPos } }}],
+ [{nativeEvent: {contentOffset: {y: this._scrollPos}}}],
{useNativeDriver: true},
);
_sectionListRef: any;
- _captureRef = (ref) => { this._sectionListRef = ref; };
+ _captureRef = ref => {
+ this._sectionListRef = ref;
+ };
_scrollToLocation(sectionIndex: number, itemIndex: number) {
- this._sectionListRef
- .getNode()
- .scrollToLocation({ sectionIndex, itemIndex });
+ this._sectionListRef.getNode().scrollToLocation({sectionIndex, itemIndex});
}
render() {
const filterRegex = new RegExp(String(this.state.filterText), 'i');
- const filter = (item) => (
- filterRegex.test(item.text) || filterRegex.test(item.title)
- );
+ const filter = item =>
+ filterRegex.test(item.text) || filterRegex.test(item.title);
const filteredData = this.state.data.filter(filter);
const filteredSectionData = [];
let startIndex = 0;
const endIndex = filteredData.length - 1;
for (let ii = 10; ii <= endIndex + 10; ii += 10) {
filteredSectionData.push({
- key: `${filteredData[startIndex].key} - ${filteredData[Math.min(ii - 1, endIndex)].key}`,
+ key: `${filteredData[startIndex].key} - ${
+ filteredData[Math.min(ii - 1, endIndex)].key
+ }`,
data: filteredData.slice(startIndex, ii),
});
startIndex = ii;
}
return (
-
+
{
@@ -130,9 +135,18 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
scroll to:
- this._scrollToLocation(2, 1)}/>
- this._scrollToLocation(3, 6)}/>
- this._scrollToLocation(6, 3)}/>
+ this._scrollToLocation(2, 1)}
+ />
+ this._scrollToLocation(3, 6)}
+ />
+ this._scrollToLocation(6, 3)}
+ />
@@ -140,12 +154,12 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
ref={this._captureRef}
ListHeaderComponent={HeaderComponent}
ListFooterComponent={FooterComponent}
- SectionSeparatorComponent={(info) =>
+ SectionSeparatorComponent={info => (
- }
- ItemSeparatorComponent={(info) =>
+ )}
+ ItemSeparatorComponent={info => (
- }
+ )}
debug={this.state.debug}
inverted={this.state.inverted}
enableVirtualization={this.state.virtualized}
@@ -166,14 +180,28 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
renderItem: renderStackedItem,
key: 's1',
data: [
- {title: 'Item In Header Section', text: 'Section s1', key: 'header item'},
+ {
+ title: 'Item In Header Section',
+ text: 'Section s1',
+ key: 'header item',
+ },
],
},
{
key: 's2',
data: [
- {noImage: true, title: '1st item', text: 'Section s2', key: 'noimage0'},
- {noImage: true, title: '2nd item', text: 'Section s2', key: 'noimage1'},
+ {
+ noImage: true,
+ title: '1st item',
+ text: 'Section s2',
+ key: 'noimage0',
+ },
+ {
+ noImage: true,
+ title: '2nd item',
+ text: 'Section s2',
+ key: 'noimage1',
+ },
],
},
...filteredSectionData,
@@ -202,14 +230,19 @@ class SectionListExample extends React.PureComponent<{}, $FlowFixMeState> {
isViewable: boolean,
item: {columns: Array<*>},
index: ?number,
- section?: any
- }>},
- ) => {
+ section?: any,
+ }>,
+ }) => {
// Impressions can be logged here
if (this.state.logViewable) {
- infoLog('onViewableItemsChanged: ', info.changed.map((v: Object) => (
- {...v, item: '...', section: v.section.key}
- )));
+ infoLog(
+ 'onViewableItemsChanged: ',
+ info.changed.map((v: Object) => ({
+ ...v,
+ item: '...',
+ section: v.section.key,
+ })),
+ );
}
};
diff --git a/RNTester/js/SegmentedControlIOSExample.js b/RNTester/js/SegmentedControlIOSExample.js
index c0098b5fa..6dd003769 100644
--- a/RNTester/js/SegmentedControlIOSExample.js
+++ b/RNTester/js/SegmentedControlIOSExample.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- SegmentedControlIOS,
- Text,
- View,
- StyleSheet
-} = ReactNative;
+var {SegmentedControlIOS, Text, View, StyleSheet} = ReactNative;
class BasicSegmentedControlExample extends React.Component<{}> {
render() {
@@ -25,7 +22,9 @@ class BasicSegmentedControlExample extends React.Component<{}> {
-
+
);
@@ -61,7 +60,11 @@ class DisabledSegmentedControlExample extends React.Component<{}> {
return (
-
+
);
@@ -73,48 +76,56 @@ class ColorSegmentedControlExample extends React.Component<{}> {
return (
-
+
-
+
);
}
}
-class EventSegmentedControlExample extends React.Component<{}, $FlowFixMeState> {
+class EventSegmentedControlExample extends React.Component<
+ {},
+ $FlowFixMeState,
+> {
state = {
values: ['One', 'Two', 'Three'],
value: 'Not selected',
- selectedIndex: undefined
+ selectedIndex: undefined,
};
render() {
return (
-
- Value: {this.state.value}
-
-
- Index: {this.state.selectedIndex}
-
+ Value: {this.state.value}
+ Index: {this.state.selectedIndex}
+ onValueChange={this._onValueChange}
+ />
);
}
- _onChange = (event) => {
+ _onChange = event => {
this.setState({
selectedIndex: event.nativeEvent.selectedSegmentIndex,
});
};
- _onValueChange = (value) => {
+ _onValueChange = value => {
this.setState({
value: value,
});
@@ -136,26 +147,38 @@ exports.description = 'Native segmented control';
exports.examples = [
{
title: 'Segmented controls can have values',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Segmented controls can have a pre-selected value',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Segmented controls can be momentary',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Segmented controls can be disabled',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Custom colors can be provided',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Change events can be detected',
- render(): React.Element { return ; }
- }
+ render(): React.Element {
+ return ;
+ },
+ },
];
diff --git a/RNTester/js/SetPropertiesExampleApp.js b/RNTester/js/SetPropertiesExampleApp.js
index 95034438b..2b8e3fe5b 100644
--- a/RNTester/js/SetPropertiesExampleApp.js
+++ b/RNTester/js/SetPropertiesExampleApp.js
@@ -4,36 +4,31 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
const ReactNative = require('react-native');
-const {
- Text,
- View,
-} = ReactNative;
+const {Text, View} = ReactNative;
class SetPropertiesExampleApp extends React.Component<$FlowFixMeProps> {
-
render() {
const wrapperStyle = {
backgroundColor: this.props.color,
flex: 1,
alignItems: 'center',
- justifyContent: 'center'
+ justifyContent: 'center',
};
return (
-
- Embedded React Native view
-
+ Embedded React Native view
);
}
-
}
module.exports = SetPropertiesExampleApp;
diff --git a/RNTester/js/ShareExample.js b/RNTester/js/ShareExample.js
index 7df3edd36..ac3aa22ee 100644
--- a/RNTester/js/ShareExample.js
+++ b/RNTester/js/ShareExample.js
@@ -4,29 +4,27 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- View,
- Text,
- TouchableHighlight,
- Share,
-} = ReactNative;
+var {StyleSheet, View, Text, TouchableHighlight, Share} = ReactNative;
exports.framework = 'React';
exports.title = 'Share';
exports.description = 'Share data with other Apps.';
-exports.examples = [{
- title: 'Share Text Content',
- render() {
- return ;
- }
-}];
+exports.examples = [
+ {
+ title: 'Share Text Content',
+ render() {
+ return ;
+ },
+ },
+];
class ShareMessageExample extends React.Component<$FlowFixMeProps, any> {
_shareMessage: Function;
@@ -41,21 +39,19 @@ class ShareMessageExample extends React.Component<$FlowFixMeProps, any> {
this._showResult = this._showResult.bind(this);
this.state = {
- result: ''
+ result: '',
};
}
render() {
return (
-
+
Click to share message
-
+
Click to share message, URL and title
@@ -67,33 +63,37 @@ class ShareMessageExample extends React.Component<$FlowFixMeProps, any> {
_shareMessage() {
Share.share({
- message: 'React Native | A framework for building native apps using React'
+ message:
+ 'React Native | A framework for building native apps using React',
})
- .then(this._showResult)
- .catch((error) => this.setState({result: 'error: ' + error.message}));
+ .then(this._showResult)
+ .catch(error => this.setState({result: 'error: ' + error.message}));
}
_shareText() {
- Share.share({
- message: 'A framework for building native apps using React',
- url: 'http://facebook.github.io/react-native/',
- title: 'React Native'
- }, {
- subject: 'A subject to go in the email heading',
- dialogTitle: 'Share React Native website',
- excludedActivityTypes: [
- 'com.apple.UIKit.activity.PostToTwitter'
- ],
- tintColor: 'green'
- })
- .then(this._showResult)
- .catch((error) => this.setState({result: 'error: ' + error.message}));
+ Share.share(
+ {
+ message: 'A framework for building native apps using React',
+ url: 'http://facebook.github.io/react-native/',
+ title: 'React Native',
+ },
+ {
+ subject: 'A subject to go in the email heading',
+ dialogTitle: 'Share React Native website',
+ excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
+ tintColor: 'green',
+ },
+ )
+ .then(this._showResult)
+ .catch(error => this.setState({result: 'error: ' + error.message}));
}
_showResult(result) {
if (result.action === Share.sharedAction) {
if (result.activityType) {
- this.setState({result: 'shared with an activityType: ' + result.activityType});
+ this.setState({
+ result: 'shared with an activityType: ' + result.activityType,
+ });
} else {
this.setState({result: 'shared'});
}
@@ -103,7 +103,6 @@ class ShareMessageExample extends React.Component<$FlowFixMeProps, any> {
}
}
-
var styles = StyleSheet.create({
wrapper: {
borderRadius: 5,
diff --git a/RNTester/js/SliderExample.js b/RNTester/js/SliderExample.js
index b05877572..a6d951033 100644
--- a/RNTester/js/SliderExample.js
+++ b/RNTester/js/SliderExample.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Slider,
- Text,
- StyleSheet,
- View,
-} = ReactNative;
+var {Slider, Text, StyleSheet, View} = ReactNative;
class SliderExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
static defaultProps = {
@@ -29,18 +26,22 @@ class SliderExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
render() {
return (
-
+
{this.state.value && +this.state.value.toFixed(3)}
this.setState({value: value})} />
+ onValueChange={value => this.setState({value: value})}
+ />
);
}
}
-class SlidingCompleteExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class SlidingCompleteExample extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
state = {
slideCompletionValue: 0,
slideCompletionCount: 0,
@@ -51,11 +52,16 @@ class SlidingCompleteExample extends React.Component<$FlowFixMeProps, $FlowFixMe
this.setState({
+ onSlidingComplete={value =>
+ this.setState({
slideCompletionValue: value,
- slideCompletionCount: this.state.slideCompletionCount + 1})} />
+ slideCompletionCount: this.state.slideCompletionCount + 1,
+ })
+ }
+ />
- Completions: {this.state.slideCompletionCount} Value: {this.state.slideCompletionValue}
+ Completions: {this.state.slideCompletionCount} Value:{' '}
+ {this.state.slideCompletionValue}
);
@@ -83,38 +89,31 @@ exports.examples = [
title: 'Default settings',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Initial value: 0.5',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'minimumValue: -1, maximumValue: 2',
render(): React.Element {
- return (
-
- );
- }
+ return ;
+ },
},
{
title: 'step: 0.25',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'onSlidingComplete',
render(): React.Element {
- return (
-
- );
- }
+ return ;
+ },
},
{
title: 'Custom min/max track tint color',
@@ -126,28 +125,28 @@ exports.examples = [
value={0.5}
/>
);
- }
+ },
},
{
title: 'Custom thumb color',
platform: 'android',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Custom thumb image',
platform: 'ios',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Custom track image',
platform: 'ios',
render(): React.Element {
return ;
- }
+ },
},
{
title: 'Custom min/max track image',
@@ -159,6 +158,6 @@ exports.examples = [
maximumTrackImage={require('./slider-right.png')}
/>
);
- }
+ },
},
];
diff --git a/RNTester/js/StatusBarExample.js b/RNTester/js/StatusBarExample.js
index b9949c17c..324756711 100644
--- a/RNTester/js/StatusBarExample.js
+++ b/RNTester/js/StatusBarExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
@@ -23,22 +25,11 @@ exports.framework = 'React';
exports.title = '';
exports.description = 'Component for controlling the status bar';
-const colors = [
- '#ff0000',
- '#00ff00',
- '#0000ff',
- 'rgba(0, 0, 0, 0.4)',
-];
+const colors = ['#ff0000', '#00ff00', '#0000ff', 'rgba(0, 0, 0, 0.4)'];
-const barStyles = [
- 'default',
- 'light-content',
-];
+const barStyles = ['default', 'light-content'];
-const showHideTransitions = [
- 'fade',
- 'slide',
-];
+const showHideTransitions = ['fade', 'slide'];
function getValue(values: Array, index: number): T {
return values[index % values.length];
@@ -64,7 +55,10 @@ class StatusBarHiddenExample extends React.Component<{}, $FlowFixMeState> {
_onChangeTransition = () => {
this._showHideTransitionIndex++;
this.setState({
- showHideTransition: getValue(showHideTransitions, this._showHideTransitionIndex),
+ showHideTransition: getValue(
+ showHideTransitions,
+ this._showHideTransitionIndex,
+ ),
});
};
@@ -87,7 +81,9 @@ class StatusBarHiddenExample extends React.Component<{}, $FlowFixMeState> {
style={styles.wrapper}
onPress={this._onChangeAnimated}>
- animated (ios only): {this.state.animated ? 'true' : 'false'}
+
+ animated (ios only): {this.state.animated ? 'true' : 'false'}
+
{
onPress={this._onChangeTransition}>
- showHideTransition (ios only):
- '{getValue(showHideTransitions, this._showHideTransitionIndex)}'
+ showHideTransition (ios only): '{getValue(
+ showHideTransitions,
+ this._showHideTransitionIndex,
+ )}'
@@ -149,14 +147,18 @@ class StatusBarStyleExample extends React.Component<{}, $FlowFixMeState> {
}
}
-class StatusBarNetworkActivityExample extends React.Component<{}, $FlowFixMeState> {
+class StatusBarNetworkActivityExample extends React.Component<
+ {},
+ $FlowFixMeState,
+> {
state = {
networkActivityIndicatorVisible: false,
};
_onChangeNetworkIndicatorVisible = () => {
this.setState({
- networkActivityIndicatorVisible: !this.state.networkActivityIndicatorVisible,
+ networkActivityIndicatorVisible: !this.state
+ .networkActivityIndicatorVisible,
});
};
@@ -164,7 +166,9 @@ class StatusBarNetworkActivityExample extends React.Component<{}, $FlowFixMeStat
return (
{
+class StatusBarBackgroundColorExample extends React.Component<
+ {},
+ $FlowFixMeState,
+> {
state = {
animated: true,
backgroundColor: getValue(colors, 0),
@@ -238,14 +245,14 @@ class StatusBarTranslucentExample extends React.Component<{}, $FlowFixMeState> {
render() {
return (
-
+
- translucent: {this.state.translucent ? 'true' : 'false'}
+
+ translucent: {this.state.translucent ? 'true' : 'false'}
+
@@ -363,7 +370,10 @@ class StatusBarStaticAndroidExample extends React.Component<{}> {
StatusBar.setBackgroundColor('rgba(0, 0, 0, 0.4)', true);
}}>
- setTranslucent(true) and setBackgroundColor('rgba(0, 0, 0, 0.4)', true)
+
+ setTranslucent(true) and setBackgroundColor('rgba(0, 0, 0, 0.4)',
+ true)
+
{
StatusBar.setBackgroundColor('black', true);
}}>
- setTranslucent(false) and setBackgroundColor('black', true)
+
+ setTranslucent(false) and setBackgroundColor('black', true)
+
@@ -381,7 +393,6 @@ class StatusBarStaticAndroidExample extends React.Component<{}> {
}
}
-
class ModalExample extends React.Component<{}, $FlowFixMeState> {
state = {
modalVisible: false,
@@ -423,58 +434,67 @@ class ModalExample extends React.Component<{}, $FlowFixMeState> {
}
}
-const examples = [{
- title: 'StatusBar hidden',
- render() {
- return ;
+const examples = [
+ {
+ title: 'StatusBar hidden',
+ render() {
+ return ;
+ },
},
-}, {
- title: 'StatusBar style',
- render() {
- return ;
+ {
+ title: 'StatusBar style',
+ render() {
+ return ;
+ },
+ platform: 'ios',
},
- platform: 'ios',
-}, {
- title: 'StatusBar network activity indicator',
- render() {
- return ;
+ {
+ title: 'StatusBar network activity indicator',
+ render() {
+ return ;
+ },
+ platform: 'ios',
},
- platform: 'ios',
-}, {
- title: 'StatusBar background color',
- render() {
- return ;
+ {
+ title: 'StatusBar background color',
+ render() {
+ return ;
+ },
+ platform: 'android',
},
- platform: 'android',
-}, {
- title: 'StatusBar translucent',
- render() {
- return ;
+ {
+ title: 'StatusBar translucent',
+ render() {
+ return ;
+ },
+ platform: 'android',
},
- platform: 'android',
-}, {
- title: 'StatusBar static API',
- render() {
- return ;
+ {
+ title: 'StatusBar static API',
+ render() {
+ return ;
+ },
+ platform: 'ios',
},
- platform: 'ios',
-}, {
- title: 'StatusBar static API',
- render() {
- return ;
+ {
+ title: 'StatusBar static API',
+ render() {
+ return ;
+ },
+ platform: 'android',
},
- platform: 'android',
-}, {
- title: 'StatusBar dimensions',
- render() {
- return (
-
- Height (Android only): {StatusBar.currentHeight} pts
-
- );
+ {
+ title: 'StatusBar dimensions',
+ render() {
+ return (
+
+ Height (Android only): {StatusBar.currentHeight} pts
+
+ );
+ },
+ platform: 'android',
},
- platform: 'android',
-}];
+];
exports.examples = examples;
@@ -483,7 +503,7 @@ var styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
padding: 20,
- backgroundColor: '#f5fcff'
+ backgroundColor: '#f5fcff',
},
innerContainer: {
borderRadius: 10,
diff --git a/RNTester/js/SwipeableListViewExample.js b/RNTester/js/SwipeableListViewExample.js
index db9163396..1fec55d93 100644
--- a/RNTester/js/SwipeableListViewExample.js
+++ b/RNTester/js/SwipeableListViewExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
@@ -27,7 +29,7 @@ var SwipeableListViewSimpleExample = createReactClass({
displayName: 'SwipeableListViewSimpleExample',
statics: {
title: '',
- description: 'Performant, scrollable, swipeable list of data.'
+ description: 'Performant, scrollable, swipeable list of data.',
},
getInitialState: function() {
@@ -52,15 +54,24 @@ var SwipeableListViewSimpleExample = createReactClass({
{
- return (
- {
- Alert.alert('Tips', 'You could do something with this row: ' + rowData.text);
- }}>
- Remove
-
- );
+ renderQuickActions={(
+ rowData: Object,
+ sectionID: string,
+ rowID: string,
+ ) => {
+ return (
+
+ {
+ Alert.alert(
+ 'Tips',
+ 'You could do something with this row: ' + rowData.text,
+ );
+ }}>
+ Remove
+
+
+ );
}}
renderRow={this._renderRow}
renderSeparator={this._renderSeperator}
@@ -69,7 +80,12 @@ var SwipeableListViewSimpleExample = createReactClass({
);
},
- _renderRow: function(rowData: Object, sectionID: number, rowID: number, highlightRow: (sectionID: number, rowID: number) => void) {
+ _renderRow: function(
+ rowData: Object,
+ sectionID: number,
+ rowID: number,
+ highlightRow: (sectionID: number, rowID: number) => void,
+ ) {
var rowHash = Math.abs(hashCode(rowData.id));
var imgSource = THUMB_URLS[rowHash % THUMB_URLS.length];
return (
@@ -109,13 +125,20 @@ var SwipeableListViewSimpleExample = createReactClass({
dataBlob['Section 0'] = {};
for (var ii = 0; ii < 100; ii++) {
var pressedText = pressData[ii] ? ' (pressed)' : '';
- dataBlob[sectionIDs[0]]['Row ' + ii] = {id: 'Row ' + ii, text: 'Row ' + ii + pressedText};
+ dataBlob[sectionIDs[0]]['Row ' + ii] = {
+ id: 'Row ' + ii,
+ text: 'Row ' + ii + pressedText,
+ };
rowIDs[0].push('Row ' + ii);
}
return [dataBlob, sectionIDs, rowIDs];
},
- _renderSeperator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
+ _renderSeperator: function(
+ sectionID: number,
+ rowID: number,
+ adjacentRowHighlighted: boolean,
+ ) {
return (
);
- }
+ },
});
var THUMB_URLS = [
@@ -141,14 +164,15 @@ var THUMB_URLS = [
require('./Thumbnails/poke.png'),
require('./Thumbnails/superlike.png'),
require('./Thumbnails/victory.png'),
- ];
-var LOREM_IPSUM = 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';
+];
+var LOREM_IPSUM =
+ 'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';
/* eslint no-bitwise: 0 */
var hashCode = function(str) {
var hash = 15;
for (var ii = str.length - 1; ii >= 0; ii--) {
- hash = ((hash << 5) - hash) + str.charCodeAt(ii);
+ hash = (hash << 5) - hash + str.charCodeAt(ii);
}
return hash;
};
diff --git a/RNTester/js/SwitchExample.js b/RNTester/js/SwitchExample.js
index e040c76a1..a8116ff24 100644
--- a/RNTester/js/SwitchExample.js
+++ b/RNTester/js/SwitchExample.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Platform,
- Switch,
- Text,
- View
-} = ReactNative;
+var {Platform, Switch, Text, View} = ReactNative;
class BasicSwitchExample extends React.Component<{}, $FlowFixMeState> {
state = {
@@ -27,12 +24,14 @@ class BasicSwitchExample extends React.Component<{}, $FlowFixMeState> {
return (
this.setState({falseSwitchIsOn: value})}
+ onValueChange={value => this.setState({falseSwitchIsOn: value})}
style={{marginBottom: 10}}
- value={this.state.falseSwitchIsOn} />
+ value={this.state.falseSwitchIsOn}
+ />
this.setState({trueSwitchIsOn: value})}
- value={this.state.trueSwitchIsOn} />
+ onValueChange={value => this.setState({trueSwitchIsOn: value})}
+ value={this.state.trueSwitchIsOn}
+ />
);
}
@@ -42,13 +41,8 @@ class DisabledSwitchExample extends React.Component<{}> {
render() {
return (
-
-
+
+
);
}
@@ -64,18 +58,20 @@ class ColorSwitchExample extends React.Component<{}, $FlowFixMeState> {
return (
this.setState({colorFalseSwitchIsOn: value})}
+ onValueChange={value => this.setState({colorFalseSwitchIsOn: value})}
onTintColor="#00ff00"
style={{marginBottom: 10}}
thumbTintColor="#0000ff"
tintColor="#ff0000"
- value={this.state.colorFalseSwitchIsOn} />
+ value={this.state.colorFalseSwitchIsOn}
+ />
this.setState({colorTrueSwitchIsOn: value})}
+ onValueChange={value => this.setState({colorTrueSwitchIsOn: value})}
onTintColor="#00ff00"
thumbTintColor="#0000ff"
tintColor="#ff0000"
- value={this.state.colorTrueSwitchIsOn} />
+ value={this.state.colorTrueSwitchIsOn}
+ />
);
}
@@ -89,27 +85,35 @@ class EventSwitchExample extends React.Component<{}, $FlowFixMeState> {
render() {
return (
-
+
this.setState({eventSwitchIsOn: value})}
+ onValueChange={value => this.setState({eventSwitchIsOn: value})}
style={{marginBottom: 10}}
- value={this.state.eventSwitchIsOn} />
+ value={this.state.eventSwitchIsOn}
+ />
this.setState({eventSwitchIsOn: value})}
+ onValueChange={value => this.setState({eventSwitchIsOn: value})}
style={{marginBottom: 10}}
- value={this.state.eventSwitchIsOn} />
+ value={this.state.eventSwitchIsOn}
+ />
{this.state.eventSwitchIsOn ? 'On' : 'Off'}
this.setState({eventSwitchRegressionIsOn: value})}
+ onValueChange={value =>
+ this.setState({eventSwitchRegressionIsOn: value})
+ }
style={{marginBottom: 10}}
- value={this.state.eventSwitchRegressionIsOn} />
+ value={this.state.eventSwitchRegressionIsOn}
+ />
this.setState({eventSwitchRegressionIsOn: value})}
+ onValueChange={value =>
+ this.setState({eventSwitchRegressionIsOn: value})
+ }
style={{marginBottom: 10}}
- value={this.state.eventSwitchRegressionIsOn} />
+ value={this.state.eventSwitchRegressionIsOn}
+ />
{this.state.eventSwitchRegressionIsOn ? 'On' : 'Off'}
@@ -120,24 +124,34 @@ class EventSwitchExample extends React.Component<{}, $FlowFixMeState> {
var examples = [
{
title: 'Switches can be set to true or false',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Switches can be disabled',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Change events can be detected',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Switches are controlled components',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Custom colors can be provided',
- render(): React.Element { return ; }
- }
+ render(): React.Element {
+ return ;
+ },
+ },
];
exports.title = '';
diff --git a/RNTester/js/TVEventHandlerExample.js b/RNTester/js/TVEventHandlerExample.js
index 840678632..177614e7c 100644
--- a/RNTester/js/TVEventHandlerExample.js
+++ b/RNTester/js/TVEventHandlerExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
@@ -23,18 +25,25 @@ var {
exports.framework = 'React';
exports.title = 'TVEventHandler example';
exports.description = 'iOS alerts and action sheets';
-exports.examples = [{
- title: 'TVEventHandler',
- render() {return ;}
-}];
+exports.examples = [
+ {
+ title: 'TVEventHandler',
+ render() {
+ return ;
+ },
+ },
+];
-class TVEventHandlerView extends React.Component<$FlowFixMeProps, {
- lastEventType: string
-}> {
+class TVEventHandlerView extends React.Component<
+ $FlowFixMeProps,
+ {
+ lastEventType: string,
+ },
+> {
constructor(props) {
super(props);
this.state = {
- lastEventType: ''
+ lastEventType: '',
};
}
@@ -44,7 +53,7 @@ class TVEventHandlerView extends React.Component<$FlowFixMeProps, {
this._tvEventHandler = new TVEventHandler();
this._tvEventHandler.enable(this, function(cmp, evt) {
cmp.setState({
- lastEventType: evt.eventType
+ lastEventType: evt.eventType,
});
});
}
@@ -65,26 +74,23 @@ class TVEventHandlerView extends React.Component<$FlowFixMeProps, {
}
render() {
-
if (Platform.isTVOS) {
return (
{}}>
-
- This example enables an instance of TVEventHandler to show the last event detected from the Apple TV Siri remote or from a keyboard.
-
+
+ This example enables an instance of TVEventHandler to show the
+ last event detected from the Apple TV Siri remote or from a
+ keyboard.
+
-
- {this.state.lastEventType}
-
+ {this.state.lastEventType}
);
} else {
return (
-
- This example is intended to be run on Apple TV.
-
+ This example is intended to be run on Apple TV.
);
}
diff --git a/RNTester/js/TabBarIOSBarStyleExample.js b/RNTester/js/TabBarIOSBarStyleExample.js
index 972235698..d6a035aed 100644
--- a/RNTester/js/TabBarIOSBarStyleExample.js
+++ b/RNTester/js/TabBarIOSBarStyleExample.js
@@ -16,6 +16,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ * @format
* @flow
*/
@@ -23,14 +24,10 @@
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- TabBarIOS,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, TabBarIOS, Text, View} = ReactNative;
-var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
+var base64Icon =
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
class TabBarIOSBarStyleExample extends React.Component<{}> {
static title = ' - Custom Bar Style';
@@ -40,10 +37,7 @@ class TabBarIOSBarStyleExample extends React.Component<{}> {
render() {
return (
-
+
Single page
diff --git a/RNTester/js/TabBarIOSExample.js b/RNTester/js/TabBarIOSExample.js
index 12906b0e1..38fcbc64f 100644
--- a/RNTester/js/TabBarIOSExample.js
+++ b/RNTester/js/TabBarIOSExample.js
@@ -4,20 +4,18 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- TabBarIOS,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, TabBarIOS, Text, View} = ReactNative;
-var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
+var base64Icon =
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
class TabBarExample extends React.Component<{}, $FlowFixMeState> {
static title = '';
@@ -34,7 +32,9 @@ class TabBarExample extends React.Component<{}, $FlowFixMeState> {
return (
{pageText}
- {num} re-renders of the {pageText}
+
+ {num} re-renders of the {pageText}
+
);
};
@@ -79,7 +79,7 @@ class TabBarExample extends React.Component<{}, $FlowFixMeState> {
onPress={() => {
this.setState({
selectedTab: 'greenTab',
- presses: this.state.presses + 1
+ presses: this.state.presses + 1,
});
}}>
{this._renderContent('#21551C', 'Green Tab', this.state.presses)}
diff --git a/RNTester/js/TextExample.android.js b/RNTester/js/TextExample.android.js
index 6f824e011..e38a92702 100644
--- a/RNTester/js/TextExample.android.js
+++ b/RNTester/js/TextExample.android.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Image,
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {Image, StyleSheet, Text, View} = ReactNative;
var RNTesterBlock = require('./RNTesterBlock');
var RNTesterPage = require('./RNTesterPage');
@@ -34,25 +31,31 @@ class AttributeToggler extends React.Component<{}, $FlowFixMeState> {
toggleWeight = () => {
this.setState({
- fontWeight: this.state.fontWeight === 'bold' ? 'normal' : 'bold'
+ fontWeight: this.state.fontWeight === 'bold' ? 'normal' : 'bold',
});
};
increaseSize = () => {
this.setState({
- fontSize: this.state.fontSize + 1
+ fontSize: this.state.fontSize + 1,
});
};
render() {
- var curStyle = {fontWeight: this.state.fontWeight, fontSize: this.state.fontSize};
+ var curStyle = {
+ fontWeight: this.state.fontWeight,
+ fontSize: this.state.fontSize,
+ };
return (
Tap the controls below to change attributes.
- See how it will even work on this nested text
+
+ See how it will even work on{' '}
+ this nested text
+
Toggle Weight
@@ -75,8 +78,8 @@ class TextExample extends React.Component<{}> {
- The text should wrap if it goes on multiple lines.
- See, this is going to the next line.
+ The text should wrap if it goes on multiple lines. See, this is
+ going to the next line.
@@ -85,21 +88,15 @@ class TextExample extends React.Component<{}> {
-
- Sans-Serif
-
+ Sans-Serif
Sans-Serif Bold
-
- Serif
-
+ Serif
Serif Bold
-
- Monospace
-
+ Monospace
Monospace Bold (After 5.0)
@@ -107,49 +104,63 @@ class TextExample extends React.Component<{}> {
-
- Roboto Regular
-
+ Roboto Regular
Roboto Italic
Roboto Bold
-
+
Roboto Bold Italic
-
- Roboto Light
-
-
+ Roboto Light
+
Roboto Light Italic
Roboto Thin (After 4.2)
-
+
Roboto Thin Italic (After 4.2)
Roboto Condensed
-
- Roboto Condensed Italic
-
-
- Roboto Condensed Bold
-
-
+ }}>
+ Roboto Condensed Italic
+
+
+ Roboto Condensed Bold
+
+
Roboto Condensed Bold Italic
Roboto Medium (After 5.0)
-
+
Roboto Medium Italic (After 5.0)
@@ -158,10 +169,13 @@ class TextExample extends React.Component<{}> {
-
- NotoSerif Regular
-
-
+ NotoSerif Regular
+
NotoSerif Bold Italic
@@ -172,36 +186,20 @@ class TextExample extends React.Component<{}> {
-
- Size 23
-
-
- Size 8
-
+ Size 23
+ Size 8
-
- Red color
-
-
- Blue color
-
+ Red color
+ Blue color
-
- Move fast and be bold
-
-
- Move fast and be bold
-
+ Move fast and be bold
+ Move fast and be bold
-
- Move fast and be bold
-
-
- Move fast and be bold
-
+ Move fast and be bold
+ Move fast and be bold
@@ -209,20 +207,25 @@ class TextExample extends React.Component<{}> {
-
- Solid underline
-
-
- None textDecoration
-
-
+ Solid underline
+ None textDecoration
+
Solid line-through
Both underline and line-through
- Mixed text with underline and line-through text nodes
+ Mixed text with{' '}
+ underline and{' '}
+
+ line-through
+ {' '}
+ text nodes
@@ -249,11 +252,17 @@ class TextExample extends React.Component<{}> {
- console.log('2nd')}>
+ console.log('2nd')}>
(and bold
- console.log('3rd')}>
+ console.log('3rd')}>
(and tiny bold italic blue
- console.log('4th')}>
+ console.log('4th')}>
(and tiny normal blue)
)
@@ -262,19 +271,29 @@ class TextExample extends React.Component<{}> {
)
- console.log('1st')}>
+ console.log('1st')}>
(Serif
- console.log('2nd')}>
+ console.log('2nd')}>
(Serif Bold Italic
console.log('3rd')}>
(Monospace Normal
console.log('4th')}>
(Sans-Serif Bold
- console.log('5th')}>
+ console.log('5th')}>
(and Sans-Serif Normal)
)
@@ -290,20 +309,19 @@ class TextExample extends React.Component<{}> {
-
- auto (default) - english LTR
-
-
- أحب اللغة العربية auto (default) - arabic RTL
-
+ auto (default) - english LTR
+ أحب اللغة العربية auto (default) - arabic RTL
- left left left left left left left left left left left left left left left
+ left left left left left left left left left left left left left
+ left left
- center center center center center center center center center center center
+ center center center center center center center center center
+ center center
- right right right right right right right right right right right right right
+ right right right right right right right right right right right
+ right right
@@ -332,19 +350,19 @@ class TextExample extends React.Component<{}> {
- A {'generated'} {' '} {'string'} and some spaces
+ A {'generated'} {'string'} and some spaces
- Holisticly formulate inexpensive ideas before best-of-breed benefits. Continually expedite magnetic potentialities rather than client-focused interfaces.
+ Holisticly formulate inexpensive ideas before best-of-breed
+ benefits. Continually expedite
+ magnetic potentialities rather than client-focused interfaces.
-
- letterSpacing = 0
-
+ letterSpacing = 0
letterSpacing = 2
@@ -352,14 +370,25 @@ class TextExample extends React.Component<{}> {
letterSpacing = 9
-
+
With size and background color
letterSpacing = -1
-
+
[letterSpacing = 3]
[Nested letterSpacing = 0]
@@ -380,11 +409,14 @@ class TextExample extends React.Component<{}> {
Red background,
- {' '}blue background,
+ {' '}
+ blue background,
- {' '}inherited blue background,
+ {' '}
+ inherited blue background,
- {' '}nested green background.
+ {' '}
+ nested green background.
@@ -407,24 +439,32 @@ class TextExample extends React.Component<{}> {
Default containerBackgroundColor (inherited) + backgroundColor wash
-
+
{"containerBackgroundColor: 'transparent' + backgroundColor wash"}
- Maximum of one line no matter now much I write here. If I keep writing it{"'"}ll just truncate after one line
+ Maximum of one line no matter now much I write here. If I keep
+ writing it{"'"}ll just truncate after one line
- Maximum of two lines no matter now much I write here. If I keep writing it{"'"}ll just truncate after two lines
+ Maximum of two lines no matter now much I write here. If I keep
+ writing it{"'"}ll just truncate after two lines
- No maximum lines specified no matter now much I write here. If I keep writing it{"'"}ll just keep going and going
+ No maximum lines specified no matter now much I write here. If I
+ keep writing it{"'"}ll just keep going and going
- This text is selectable if you click-and-hold, and will offer the native Android selection menus.
+ This text is selectable if you click-and-hold, and will offer the
+ native Android selection menus.
@@ -434,11 +474,18 @@ class TextExample extends React.Component<{}> {
- This text contains an inline image . Neat, huh?
+ This text contains an inline image{' '}
+ . Neat, huh?
-
+
Demo text shadow
@@ -457,21 +504,32 @@ class TextExample extends React.Component<{}> {
-
+
-
- Ey
-
+ Ey
Default
-
+
Ey
includeFontPadding: false
- By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.
+
+ By default Android will put extra space above text to allow for
+ upper-case accents or other ascenders. With some fonts, this can
+ make text look slightly misaligned when centered vertically.
+
);
@@ -481,7 +539,7 @@ class TextExample extends React.Component<{}> {
var styles = StyleSheet.create({
backgroundColorText: {
left: 5,
- backgroundColor: 'rgba(100, 100, 100, 0.3)'
+ backgroundColor: 'rgba(100, 100, 100, 0.3)',
},
includeFontPaddingText: {
fontSize: 120,
@@ -490,7 +548,7 @@ var styles = StyleSheet.create({
color: '#000000',
textAlignVertical: 'center',
alignSelf: 'center',
- }
+ },
});
module.exports = TextExample;
diff --git a/RNTester/js/TextExample.ios.js b/RNTester/js/TextExample.ios.js
index 968e0a42c..6fdd942d4 100644
--- a/RNTester/js/TextExample.ios.js
+++ b/RNTester/js/TextExample.ios.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const Platform = require('Platform');
@@ -225,10 +227,16 @@ class TextBaseLineLayoutExample extends React.Component<*, *> {
render() {
var texts = [];
for (var i = 9; i >= 0; i--) {
- texts.push({i});
+ texts.push(
+
+ {i}
+ ,
+ );
}
- const marker = ;
+ const marker = (
+
+ );
const subtitleStyle = {fontSize: 16, marginTop: 8, fontWeight: 'bold'};
return (
@@ -236,9 +244,7 @@ class TextBaseLineLayoutExample extends React.Component<*, *> {
{'Nested s:'}
{marker}
-
- {texts}
-
+ {texts}
{marker}
@@ -254,7 +260,12 @@ class TextBaseLineLayoutExample extends React.Component<*, *> {
{marker}
Some text.
-
+
{marker}
Text inside View.
{marker}
@@ -266,9 +277,7 @@ class TextBaseLineLayoutExample extends React.Component<*, *> {
{':'}
{marker}
-
- {texts}
-
+ {texts}
{marker}
@@ -575,14 +584,25 @@ exports.examples = [
letterSpacing = 9
-
+
With size and background color
letterSpacing = -1
-
+
[letterSpacing = 3]
[Nested letterSpacing = 0]
@@ -600,7 +620,7 @@ exports.examples = [
render: function() {
return (
- A {'generated'} {' '} {'string'} and some spaces
+ A {'generated'} {'string'} and some spaces
);
},
@@ -719,8 +739,9 @@ exports.examples = [
- You can disable scaling for your Text component by passing {'"'}allowFontScaling={'{'}false{'}"'}{' '}
- prop.
+ You can disable scaling for your Text component by passing {'"'}allowFontScaling={
+ '{'
+ }false{'}"'} prop.
This text will not scale.
@@ -830,11 +851,15 @@ exports.examples = [
This text has a view
which has
- another text inside.
+
+ another text inside.
+
And moreover, it has another view
- with another text inside!
+
+ with another text inside!
+
@@ -856,42 +881,43 @@ exports.examples = [
},
},
{
- title: 'Text `alignItems: \'baseline\'` style',
+ title: "Text `alignItems: 'baseline'` style",
render: function() {
return ;
- }
+ },
},
{
title: 'Transform',
render: function() {
return (
-
+
This text should be uppercased.
-
+
This TEXT SHOULD be lowercased.
-
+
This text should be CAPITALIZED.
-
- Mixed:{' '}
-
- uppercase{' '}
-
-
- LoWeRcAsE{' '}
-
-
+
+ Mixed: uppercase
+ LoWeRcAsE
+
capitalize each word
- Should be "ABC":
- abc
+
+ Should be "ABC":
+
+ abc
+
- Should be "AbC":
- abc
+
+ Should be "AbC":
+
+ abc
+
);
diff --git a/RNTester/js/TextInputExample.android.js b/RNTester/js/TextInputExample.android.js
index f0b3403d6..30cee2eb2 100644
--- a/RNTester/js/TextInputExample.android.js
+++ b/RNTester/js/TextInputExample.android.js
@@ -4,20 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Text,
- TextInput,
- View,
- StyleSheet,
- Slider,
- Switch,
-} = ReactNative;
+var {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;
class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
state = {
@@ -27,8 +22,8 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
prev3Text: '',
};
- updateText = (text) => {
- this.setState((state) => {
+ updateText = text => {
+ this.setState(state => {
return {
curText: text,
prevText: state.curText,
@@ -48,25 +43,28 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
multiline
onFocus={() => this.updateText('onFocus')}
onBlur={() => this.updateText('onBlur')}
- onChange={(event) => this.updateText(
- 'onChange text: ' + event.nativeEvent.text
- )}
- onContentSizeChange={(event) => this.updateText(
- 'onContentSizeChange size: ' + event.nativeEvent.contentSize
- )}
- onEndEditing={(event) => this.updateText(
- 'onEndEditing text: ' + event.nativeEvent.text
- )}
- onSubmitEditing={(event) => this.updateText(
- 'onSubmitEditing text: ' + event.nativeEvent.text
- )}
- onKeyPress={(event) => this.updateText(
- 'onKeyPress key: ' + event.nativeEvent.key
- )}
+ onChange={event =>
+ this.updateText('onChange text: ' + event.nativeEvent.text)
+ }
+ onContentSizeChange={event =>
+ this.updateText(
+ 'onContentSizeChange size: ' + event.nativeEvent.contentSize,
+ )
+ }
+ onEndEditing={event =>
+ this.updateText('onEndEditing text: ' + event.nativeEvent.text)
+ }
+ onSubmitEditing={event =>
+ this.updateText('onSubmitEditing text: ' + event.nativeEvent.text)
+ }
+ onKeyPress={event =>
+ this.updateText('onKeyPress key: ' + event.nativeEvent.key)
+ }
style={styles.singleLine}
/>
- {this.state.curText}{'\n'}
+ {this.state.curText}
+ {'\n'}
(prev: {this.state.prevText}){'\n'}
(prev2: {this.state.prev2Text}){'\n'}
(prev3: {this.state.prev3Text})
@@ -90,7 +88,7 @@ class RewriteExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
{
+ onChangeText={text => {
text = text.replace(/ /g, '_');
this.setState({text});
}}
@@ -105,19 +103,23 @@ class RewriteExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
}
}
-class TokenizedTextExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class TokenizedTextExample extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
constructor(props) {
super(props);
this.state = {text: 'Hello #World'};
}
render() {
-
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
- let token, index, parts = [];
+ let token,
+ index,
+ parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
@@ -136,9 +138,13 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, $FlowFixMeSt
parts.push(_text);
//highlight hashtags
- parts = parts.map((text) => {
+ parts = parts.map(text => {
if (/^#/.test(text)) {
- return {text};
+ return (
+
+ {text}
+
+ );
} else {
return text;
}
@@ -149,7 +155,7 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, $FlowFixMeSt
{
+ onChangeText={text => {
this.setState({text});
}}>
{parts}
@@ -160,7 +166,7 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, $FlowFixMeSt
}
class BlurOnSubmitExample extends React.Component<{}> {
- focusNextField = (nextField) => {
+ focusNextField = nextField => {
this.refs[nextField].focus();
};
@@ -213,7 +219,10 @@ class BlurOnSubmitExample extends React.Component<{}> {
}
}
-class ToggleDefaultPaddingExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class ToggleDefaultPaddingExample extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
constructor(props) {
super(props);
this.state = {hasPadding: false};
@@ -221,8 +230,9 @@ class ToggleDefaultPaddingExample extends React.Component<$FlowFixMeProps, $Flow
render() {
return (
-
- this.setState({hasPadding: !this.state.hasPadding})}>
+
+ this.setState({hasPadding: !this.state.hasPadding})}>
Toggle padding
@@ -232,20 +242,23 @@ class ToggleDefaultPaddingExample extends React.Component<$FlowFixMeProps, $Flow
type SelectionExampleState = {
selection: {
- start: number;
- end: number;
- };
- value: string;
+ start: number,
+ end: number,
+ },
+ value: string,
};
-class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExampleState> {
+class SelectionExample extends React.Component<
+ $FlowFixMeProps,
+ SelectionExampleState,
+> {
_textInput: any;
constructor(props) {
super(props);
this.state = {
selection: {start: 0, end: 0},
- value: props.value
+ value: props.value,
};
}
@@ -283,7 +296,7 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
this.setState({value})}
+ onChangeText={value => this.setState({value})}
onSelectionChange={this.onSelectionChange.bind(this)}
ref={textInput => (this._textInput = textInput)}
selection={this.state.selection}
@@ -291,24 +304,16 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
value={this.state.value}
/>
-
- selection = {JSON.stringify(this.state.selection)}
-
+ selection = {JSON.stringify(this.state.selection)}
Place at Start (0, 0)
Place at End ({length}, {length})
-
- Place at Random
-
-
- Select All
-
-
- Select Random
-
+ Place at Random
+ Select All
+ Select Random
);
@@ -316,7 +321,6 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
}
class AutogrowingTextInputExample extends React.Component<{}> {
-
constructor(props) {
super(props);
@@ -347,19 +351,21 @@ class AutogrowingTextInputExample extends React.Component<{}> {
minimumValue={0}
maximumValue={100}
step={10}
- onValueChange={(value) => this.setState({width: value})}
+ onValueChange={value => this.setState({width: value})}
/>
Multiline:
this.setState({multiline: value})}
+ onValueChange={value => this.setState({multiline: value})}
/>
TextInput:
this.setState({text: value})}
- onContentSizeChange={(event) => this.setState({contentSize: event.nativeEvent.contentSize})}
+ onChangeText={value => this.setState({text: value})}
+ onContentSizeChange={event =>
+ this.setState({contentSize: event.nativeEvent.contentSize})
+ }
{...props}
/>
Plain text value representation:
@@ -405,24 +411,19 @@ exports.examples = [
accessibilityLabel="I am the accessibility label for text input"
/>
);
- }
+ },
},
{
title: "Live Re-Write ( -> '_')",
render: function() {
return ;
- }
+ },
},
{
title: 'Auto-capitalize',
render: function() {
- var autoCapitalizeTypes = [
- 'none',
- 'sentences',
- 'words',
- 'characters',
- ];
- var examples = autoCapitalizeTypes.map((type) => {
+ var autoCapitalizeTypes = ['none', 'sentences', 'words', 'characters'];
+ var examples = autoCapitalizeTypes.map(type => {
return (
{examples};
- }
+ },
},
{
title: 'Auto-correct',
@@ -452,18 +453,13 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Keyboard types',
render: function() {
- var keyboardTypes = [
- 'default',
- 'email-address',
- 'numeric',
- 'phone-pad',
- ];
- var examples = keyboardTypes.map((type) => {
+ var keyboardTypes = ['default', 'email-address', 'numeric', 'phone-pad'];
+ var examples = keyboardTypes.map(type => {
return (
{examples};
- }
+ },
},
{
title: 'Blur on submit',
- render: function(): React.Element { return ; },
+ render: function(): React.Element {
+ return ;
+ },
},
{
title: 'Event handling',
- render: function(): React.Element { return ; },
+ render: function(): React.Element {
+ return ;
+ },
},
{
title: 'Colors and text inputs',
@@ -517,7 +517,10 @@ exports.examples = [
/>
+ style={[
+ styles.singleLine,
+ {backgroundColor: 'rgba(100, 100, 100, 0.3)'},
+ ]}>
Darker backgroundColor
@@ -525,10 +528,11 @@ exports.examples = [
+ style={styles.singleLine}
+ />
);
- }
+ },
},
{
title: 'Text input, themes and heights',
@@ -539,7 +543,7 @@ exports.examples = [
style={[styles.singleLineWithHeightTextInput]}
/>
);
- }
+ },
},
{
title: 'fontFamily, fontWeight and fontStyle',
@@ -551,11 +555,17 @@ exports.examples = [
placeholder="Custom fonts like Sans-Serif are supported"
/>
);
- }
+ },
},
{
title: 'letterSpacing',
@@ -589,7 +599,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Passwords',
@@ -609,19 +619,19 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Editable',
render: function() {
return (
+ defaultValue="Can't touch this! (>'-')> ^(' - ')^ <('-'<) (>'-')> ^(' - ')^"
+ editable={false}
+ style={styles.singleLine}
+ />
);
- }
+ },
},
{
title: 'Multiline',
@@ -633,24 +643,36 @@ exports.examples = [
placeholder="multiline, aligned top-left"
placeholderTextColor="red"
multiline={true}
- style={[styles.multiline, {textAlign: 'left', textAlignVertical: 'top'}]}
+ style={[
+ styles.multiline,
+ {textAlign: 'left', textAlignVertical: 'top'},
+ ]}
/>
- multiline with children, aligned bottom-right
+ style={[
+ styles.multiline,
+ {color: 'blue'},
+ {textAlign: 'right', textAlignVertical: 'bottom'},
+ ]}>
+
+ multiline with children, aligned bottom-right
+
);
- }
+ },
},
{
title: 'Fixed number of lines',
@@ -658,17 +680,19 @@ exports.examples = [
render: function() {
return (
-
-
);
- }
+ },
},
{
title: 'Auto-expanding',
@@ -679,8 +703,7 @@ exports.examples = [
enablesReturnKeyAutomatically={true}
returnKeyType="done"
multiline={true}
- style={{maxHeight: 400, minHeight: 20, backgroundColor: '#eeeeee'}}
- >
+ style={{maxHeight: 400, minHeight: 20, backgroundColor: '#eeeeee'}}>
generic generic generic
small small small small small small
@@ -693,13 +716,13 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Attributed text',
render: function() {
return ;
- }
+ },
},
{
title: 'Return key',
@@ -713,11 +736,8 @@ exports.examples = [
'previous',
'next',
];
- var returnKeyLabels = [
- 'Compile',
- 'React Native',
- ];
- var examples = returnKeyTypes.map((type) => {
+ var returnKeyLabels = ['Compile', 'React Native'];
+ var examples = returnKeyTypes.map(type => {
return (
);
});
- var types = returnKeyLabels.map((type) => {
+ var types = returnKeyLabels.map(type => {
return (
);
});
- return {examples}{types};
- }
+ return (
+
+ {examples}
+ {types}
+
+ );
+ },
},
{
title: 'Inline Images',
@@ -762,11 +787,13 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Toggle Default Padding',
- render: function(): React.Element { return ; },
+ render: function(): React.Element {
+ return ;
+ },
},
{
title: 'Text selection & cursor placement',
@@ -784,6 +811,6 @@ exports.examples = [
/>
);
- }
+ },
},
];
diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js
index 704278796..0d5326477 100644
--- a/RNTester/js/TextInputExample.ios.js
+++ b/RNTester/js/TextInputExample.ios.js
@@ -4,22 +4,17 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const Button = require('Button');
const InputAccessoryView = require('InputAccessoryView');
var React = require('react');
var ReactNative = require('react-native');
-var {
- Text,
- TextInput,
- View,
- StyleSheet,
- Slider,
- Switch,
-} = ReactNative;
+var {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;
class WithLabel extends React.Component<$FlowFixMeProps> {
render() {
@@ -42,8 +37,8 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
prev3Text: '',
};
- updateText = (text) => {
- this.setState((state) => {
+ updateText = text => {
+ this.setState(state => {
return {
curText: text,
prevText: state.curText,
@@ -62,27 +57,31 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
autoCorrect={false}
onFocus={() => this.updateText('onFocus')}
onBlur={() => this.updateText('onBlur')}
- onChange={(event) => this.updateText(
- 'onChange text: ' + event.nativeEvent.text
- )}
- onEndEditing={(event) => this.updateText(
- 'onEndEditing text: ' + event.nativeEvent.text
- )}
- onSubmitEditing={(event) => this.updateText(
- 'onSubmitEditing text: ' + event.nativeEvent.text
- )}
- onSelectionChange={(event) => this.updateText(
- 'onSelectionChange range: ' +
- event.nativeEvent.selection.start + ',' +
- event.nativeEvent.selection.end
- )}
- onKeyPress={(event) => {
+ onChange={event =>
+ this.updateText('onChange text: ' + event.nativeEvent.text)
+ }
+ onEndEditing={event =>
+ this.updateText('onEndEditing text: ' + event.nativeEvent.text)
+ }
+ onSubmitEditing={event =>
+ this.updateText('onSubmitEditing text: ' + event.nativeEvent.text)
+ }
+ onSelectionChange={event =>
+ this.updateText(
+ 'onSelectionChange range: ' +
+ event.nativeEvent.selection.start +
+ ',' +
+ event.nativeEvent.selection.end,
+ )
+ }
+ onKeyPress={event => {
this.updateText('onKeyPress key: ' + event.nativeEvent.key);
}}
style={styles.default}
/>
- {this.state.curText}{'\n'}
+ {this.state.curText}
+ {'\n'}
(prev: {this.state.prevText}){'\n'}
(prev2: {this.state.prev2Text}){'\n'}
(prev3: {this.state.prev3Text})
@@ -135,7 +134,7 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> {
{
+ onChangeText={text => {
text = text.replace(/ /g, '_');
this.setState({text});
}}
@@ -150,7 +149,10 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> {
}
}
-class RewriteExampleInvalidCharacters extends React.Component<$FlowFixMeProps, any> {
+class RewriteExampleInvalidCharacters extends React.Component<
+ $FlowFixMeProps,
+ any,
+> {
constructor(props) {
super(props);
this.state = {text: ''};
@@ -160,7 +162,7 @@ class RewriteExampleInvalidCharacters extends React.Component<$FlowFixMeProps, a
{
+ onChangeText={text => {
this.setState({text: text.replace(/\s/g, '')});
}}
style={styles.default}
@@ -177,13 +179,14 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, any> {
this.state = {text: 'Hello #World'};
}
render() {
-
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
- let token, index, parts = [];
+ let token,
+ index,
+ parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
@@ -202,9 +205,13 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, any> {
parts.push(_text);
//highlight hashtags
- parts = parts.map((text) => {
+ parts = parts.map(text => {
if (/^#/.test(text)) {
- return {text};
+ return (
+
+ {text}
+
+ );
} else {
return text;
}
@@ -215,7 +222,7 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, any> {
{
+ onChangeText={text => {
this.setState({text});
}}>
{parts}
@@ -226,7 +233,7 @@ class TokenizedTextExample extends React.Component<$FlowFixMeProps, any> {
}
class BlurOnSubmitExample extends React.Component<{}> {
- focusNextField = (nextField) => {
+ focusNextField = nextField => {
this.refs[nextField].focus();
};
@@ -282,20 +289,23 @@ class BlurOnSubmitExample extends React.Component<{}> {
type SelectionExampleState = {
selection: {
- start: number;
- end?: number;
- };
- value: string;
+ start: number,
+ end?: number,
+ },
+ value: string,
};
-class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExampleState> {
+class SelectionExample extends React.Component<
+ $FlowFixMeProps,
+ SelectionExampleState,
+> {
_textInput: any;
constructor(props) {
super(props);
this.state = {
selection: {start: 0, end: 0},
- value: props.value
+ value: props.value,
};
}
@@ -314,7 +324,9 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
}
selectRandom() {
- var positions = [this.getRandomPosition(), this.getRandomPosition()].sort((a, b) => a - b);
+ var positions = [this.getRandomPosition(), this.getRandomPosition()].sort(
+ (a, b) => a - b,
+ );
this.select(...positions);
}
@@ -333,7 +345,7 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
this.setState({value})}
+ onChangeText={value => this.setState({value})}
onSelectionChange={this.onSelectionChange.bind(this)}
ref={textInput => (this._textInput = textInput)}
selection={this.state.selection}
@@ -341,31 +353,26 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample
value={this.state.value}
/>
-
- selection = {JSON.stringify(this.state.selection)}
-
+ selection = {JSON.stringify(this.state.selection)}
Place at Start (0, 0)
Place at End ({length}, {length})
-
- Place at Random
-
-
- Select All
-
-
- Select Random
-
+ Place at Random
+ Select All
+ Select Random
);
}
}
-class AutogrowingTextInputExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
+class AutogrowingTextInputExample extends React.Component<
+ $FlowFixMeProps,
+ $FlowFixMeState,
+> {
constructor(props) {
super(props);
@@ -396,20 +403,22 @@ class AutogrowingTextInputExample extends React.Component<$FlowFixMeProps, $Flow
minimumValue={0}
maximumValue={100}
step={10}
- onValueChange={(value) => this.setState({width: value})}
+ onValueChange={value => this.setState({width: value})}
/>
Multiline:
this.setState({multiline: value})}
+ onValueChange={value => this.setState({multiline: value})}
/>
TextInput:
this.setState({text: value})}
- onContentSizeChange={(event) => this.setState({contentSize: event.nativeEvent.contentSize})}
+ onChangeText={value => this.setState({text: value})}
+ onContentSizeChange={event =>
+ this.setState({contentSize: event.nativeEvent.contentSize})
+ }
{...props}
/>
Plain text value representation:
@@ -501,25 +510,25 @@ exports.examples = [
accessibilityLabel="I am the accessibility label for text input"
/>
);
- }
+ },
},
{
title: "Live Re-Write ( -> '_') + maxLength",
render: function() {
return ;
- }
+ },
},
{
title: 'Live Re-Write (no spaces allowed)',
render: function() {
return ;
- }
+ },
},
{
title: 'Keyboard Accessory View',
render: function() {
return ;
- }
+ },
},
{
title: 'Auto-capitalize',
@@ -527,32 +536,20 @@ exports.examples = [
return (
-
+
-
+
-
+
-
+
);
- }
+ },
},
{
title: 'Auto-correct',
@@ -567,7 +564,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Nested content and `value` property',
@@ -582,7 +579,10 @@ exports.examples = [
-
+
(first raw text node)
(internal raw text node)
(last raw text node)
@@ -590,7 +590,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Keyboard types',
@@ -609,39 +609,29 @@ exports.examples = [
'web-search',
'numeric',
];
- var examples = keyboardTypes.map((type) => {
+ var examples = keyboardTypes.map(type => {
return (
-
+
);
});
return {examples};
- }
+ },
},
{
title: 'Keyboard appearance',
render: function() {
- var keyboardAppearance = [
- 'default',
- 'light',
- 'dark',
- ];
- var examples = keyboardAppearance.map((type) => {
+ var keyboardAppearance = ['default', 'light', 'dark'];
+ var examples = keyboardAppearance.map(type => {
return (
-
+
);
});
return {examples};
- }
+ },
},
{
title: 'Return key types',
@@ -659,18 +649,15 @@ exports.examples = [
'done',
'emergency-call',
];
- var examples = returnKeyTypes.map((type) => {
+ var examples = returnKeyTypes.map(type => {
return (
-
+
);
});
return {examples};
- }
+ },
},
{
title: 'Enable return key automatically',
@@ -678,11 +665,14 @@ exports.examples = [
return (
-
+
);
- }
+ },
},
{
title: 'Secure text entry',
@@ -690,15 +680,21 @@ exports.examples = [
return (
-
+
);
- }
+ },
},
{
title: 'Event handling',
- render: function(): React.Element { return ; },
+ render: function(): React.Element {
+ return ;
+ },
},
{
title: 'Colored input text',
@@ -715,7 +711,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Colored highlight/cursor for text input',
@@ -734,24 +730,18 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Clear button mode',
- render: function () {
+ render: function() {
return (
-
+
-
+
-
+
);
- }
+ },
},
{
title: 'Clear and select',
@@ -810,11 +797,13 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Blur on submit',
- render: function(): React.Element { return ; },
+ render: function(): React.Element {
+ return ;
+ },
},
{
title: 'Multiline blur on submit',
@@ -831,7 +820,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Multiline',
@@ -874,7 +863,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'TextInput Intrinsic Size',
@@ -914,7 +903,7 @@ exports.examples = [
borderBottomRightRadius: 20,
padding: 10,
paddingTop: 20,
- maxHeight: 100
+ maxHeight: 100,
}}
testID="multiline_textinput"
multiline={true}
@@ -941,7 +930,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Auto-expanding',
@@ -958,7 +947,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'Auto-expanding',
@@ -969,11 +958,14 @@ exports.examples = [
enablesReturnKeyAutomatically={true}
returnKeyType="done"
multiline={true}
- style={{maxHeight: 400, minHeight: 20, paddingTop: 0, backgroundColor: '#eeeeee', color: 'blue'}}
- >
-
- huge
-
+ style={{
+ maxHeight: 400,
+ minHeight: 20,
+ paddingTop: 0,
+ backgroundColor: '#eeeeee',
+ color: 'blue',
+ }}>
+ huge
generic generic generic
small small small small small small
@@ -986,13 +978,13 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Attributed text',
render: function() {
return ;
- }
+ },
},
{
title: 'Text selection & cursor placement',
@@ -1010,7 +1002,7 @@ exports.examples = [
/>
);
- }
+ },
},
{
title: 'TextInput maxLength',
@@ -1018,10 +1010,7 @@ exports.examples = [
return (
-
+
);
- }
+ },
},
];
diff --git a/RNTester/js/TimePickerAndroidExample.js b/RNTester/js/TimePickerAndroidExample.js
index 517f67466..a72bcdafb 100644
--- a/RNTester/js/TimePickerAndroidExample.js
+++ b/RNTester/js/TimePickerAndroidExample.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
var React = require('react');
@@ -116,4 +118,3 @@ var styles = StyleSheet.create({
});
module.exports = TimePickerAndroidExample;
-
diff --git a/RNTester/js/TimerExample.js b/RNTester/js/TimerExample.js
index a56fd5ad3..3b930c800 100644
--- a/RNTester/js/TimerExample.js
+++ b/RNTester/js/TimerExample.js
@@ -4,20 +4,16 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
-var {
- AlertIOS,
- Platform,
- ToastAndroid,
- Text,
- View,
-} = ReactNative;
+var {AlertIOS, Platform, ToastAndroid, Text, View} = ReactNative;
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
@@ -30,7 +26,7 @@ var performanceNow = require('fbjs/lib/performanceNow');
function burnCPU(milliseconds) {
const start = performanceNow();
- while (performanceNow() < (start + milliseconds)) {}
+ while (performanceNow() < start + milliseconds) {}
}
class RequestIdleCallbackTester extends React.Component<{}, $FlowFixMeState> {
@@ -73,35 +69,45 @@ class RequestIdleCallbackTester extends React.Component<{}, $FlowFixMeState> {
);
}
- _run = (shouldBurnCPU) => {
+ _run = shouldBurnCPU => {
cancelIdleCallback(this._idleTimer);
- this._idleTimer = requestIdleCallback((deadline) => {
+ this._idleTimer = requestIdleCallback(deadline => {
let message = '';
if (shouldBurnCPU) {
burnCPU(10);
message = 'Burned CPU for 10ms,';
}
- this.setState({message: `${message} ${deadline.timeRemaining()}ms remaining in frame`});
+ this.setState({
+ message: `${message} ${deadline.timeRemaining()}ms remaining in frame`,
+ });
});
};
_runWithTimeout = () => {
cancelIdleCallback(this._idleTimer);
- this._idleTimer = requestIdleCallback((deadline) => {
- this.setState({
- message: `${deadline.timeRemaining()}ms remaining in frame, it did timeout: ${deadline.didTimeout ? 'yes' : 'no'}`
- });
- }, { timeout: 100 });
+ this._idleTimer = requestIdleCallback(
+ deadline => {
+ this.setState({
+ message: `${deadline.timeRemaining()}ms remaining in frame, it did timeout: ${
+ deadline.didTimeout ? 'yes' : 'no'
+ }`,
+ });
+ },
+ {timeout: 100},
+ );
burnCPU(100);
};
_runBackground = () => {
cancelIdleCallback(this._idleTimer);
- const handler = (deadline) => {
+ const handler = deadline => {
while (deadline.timeRemaining() > 5) {
burnCPU(5);
- this.setState({message: `Burned CPU for 5ms ${this._iters++} times, ${deadline.timeRemaining()}ms remaining in frame`});
+ this.setState({
+ message: `Burned CPU for 5ms ${this
+ ._iters++} times, ${deadline.timeRemaining()}ms remaining in frame`,
+ });
}
this._idleTimer = requestIdleCallback(handler);
@@ -122,8 +128,8 @@ var TimerTester = createReactClass({
_ii: 0,
_iters: 0,
_start: 0,
- _timerFn: (null : ?(() => any)),
- _handle: (null : any),
+ _timerFn: (null: ?() => any),
+ _handle: (null: any),
render: function() {
var args = 'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : '');
@@ -160,9 +166,18 @@ var TimerTester = createReactClass({
}
if (this._ii >= this._iters && !this._handle) {
var d = new Date();
- var e = (d.getTime() - this._start);
- var msg = 'Finished ' + this._ii + ' ' + this.props.type + ' calls.\n' +
- 'Elapsed time: ' + e + ' ms\n' + (e / this._ii) + ' ms / iter';
+ var e = d.getTime() - this._start;
+ var msg =
+ 'Finished ' +
+ this._ii +
+ ' ' +
+ this.props.type +
+ ' calls.\n' +
+ 'Elapsed time: ' +
+ e +
+ ' ms\n' +
+ e / this._ii +
+ ' ms / iter';
console.log(msg);
if (Platform.OS === 'ios') {
AlertIOS.alert(msg);
@@ -170,7 +185,9 @@ var TimerTester = createReactClass({
ToastAndroid.show(msg, ToastAndroid.SHORT);
}
this._start = 0;
- this.forceUpdate(() => { this._ii = 0; });
+ this.forceUpdate(() => {
+ this._ii = 0;
+ });
return;
}
this._ii++;
@@ -194,13 +211,15 @@ var TimerTester = createReactClass({
exports.framework = 'React';
exports.title = 'Timers, TimerMixin';
-exports.description = 'The TimerMixin provides timer functions for executing ' +
+exports.description =
+ 'The TimerMixin provides timer functions for executing ' +
'code in the future that are safely cleaned up when the component unmounts.';
exports.examples = [
{
title: 'this.setTimeout(fn, t)',
- description: 'Execute function fn t milliseconds in the future. If ' +
+ description:
+ 'Execute function fn t milliseconds in the future. If ' +
't === 0, it will be enqueued immediately in the next event loop. ' +
'Larger values will fire on the closest frame.',
render: function() {
@@ -248,7 +267,8 @@ exports.examples = [
},
{
title: 'this.setInterval(fn, t)',
- description: 'Execute function fn every t milliseconds until cancelled ' +
+ description:
+ 'Execute function fn every t milliseconds until cancelled ' +
'or component is unmounted.',
render: function(): React.Element {
class IntervalExample extends React.Component<{}, $FlowFixMeState> {
@@ -271,7 +291,7 @@ exports.examples = [
return (
- this.refs.interval.clear() }>
+ this.refs.interval.clear()}>
Clear interval
diff --git a/RNTester/js/ToastAndroidExample.android.js b/RNTester/js/ToastAndroidExample.android.js
index 6ca7b9c4f..7274fa969 100644
--- a/RNTester/js/ToastAndroidExample.android.js
+++ b/RNTester/js/ToastAndroidExample.android.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -11,12 +12,7 @@
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- ToastAndroid,
- TouchableWithoutFeedback,
-} = ReactNative;
+var {StyleSheet, Text, ToastAndroid, TouchableWithoutFeedback} = ReactNative;
var RNTesterBlock = require('RNTesterBlock');
var RNTesterPage = require('RNTesterPage');
@@ -32,14 +28,22 @@ class ToastExample extends React.Component<{}, $FlowFixMeState> {
- ToastAndroid.show('This is a toast with short duration', ToastAndroid.SHORT)}>
+ ToastAndroid.show(
+ 'This is a toast with short duration',
+ ToastAndroid.SHORT,
+ )
+ }>
Click me.
- ToastAndroid.show('This is a toast with long duration', ToastAndroid.LONG)}>
+ ToastAndroid.show(
+ 'This is a toast with long duration',
+ ToastAndroid.LONG,
+ )
+ }>
Click me.
diff --git a/RNTester/js/ToolbarAndroidExample.android.js b/RNTester/js/ToolbarAndroidExample.android.js
index 7a1710569..4043c054f 100644
--- a/RNTester/js/ToolbarAndroidExample.android.js
+++ b/RNTester/js/ToolbarAndroidExample.android.js
@@ -4,19 +4,17 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var nativeImageSource = require('nativeImageSource');
-var {
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, Text, View} = ReactNative;
var RNTesterBlock = require('./RNTesterBlock');
var RNTesterPage = require('./RNTesterPage');
@@ -45,13 +43,14 @@ class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> {
navIcon={nativeImageSource({
android: 'ic_menu_black_24dp',
width: 48,
- height: 48
+ height: 48,
})}
onActionSelected={this._onActionSelected}
onIconClicked={() => this.setState({actionText: 'Icon clicked'})}
style={styles.toolbar}
subtitle={this.state.actionText}
- title="Toolbar" />
+ title="Toolbar"
+ />
{this.state.actionText}
@@ -59,14 +58,16 @@ class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> {
logo={nativeImageSource({
android: 'launcher_icon',
width: 132,
- height: 144
+ height: 144,
})}
style={styles.toolbar}>
-
+
this.setState({'toolbarSwitch': value})} />
- {'\'Tis but a switch'}
+ onValueChange={value => this.setState({toolbarSwitch: value})}
+ />
+ {"'Tis but a switch"}
@@ -74,7 +75,8 @@ class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> {
+ subtitle="There be no icon here"
+ />
{
logo={nativeImageSource({
android: 'launcher_icon',
width: 132,
- height: 144
+ height: 144,
})}
navIcon={nativeImageSource({
android: 'ic_menu_black_24dp',
width: 48,
- height: 48
+ height: 48,
})}
- style={styles.toolbar} />
+ style={styles.toolbar}
+ />
this.setState({colorProps: {}})}
title="Wow, such toolbar"
style={styles.toolbar}
subtitle="Much native"
- {...this.state.colorProps} />
+ {...this.state.colorProps}
+ />
- Touch the icon to reset the custom colors to the default (theme-provided) ones.
+ Touch the icon to reset the custom colors to the default
+ (theme-provided) ones.
+ style={styles.toolbar}
+ />
+ style={styles.toolbar}
+ />
);
}
- _onActionSelected = (position) => {
+ _onActionSelected = position => {
this.setState({
actionText: 'Selected ' + toolbarActions[position].title,
});
@@ -133,17 +142,25 @@ class ToolbarAndroidExample extends React.Component<{}, $FlowFixMeState> {
}
var toolbarActions = [
- {title: 'Create', icon: nativeImageSource({
- android: 'ic_create_black_48dp',
- width: 96,
- height: 96
- }), show: 'always'},
+ {
+ title: 'Create',
+ icon: nativeImageSource({
+ android: 'ic_create_black_48dp',
+ width: 96,
+ height: 96,
+ }),
+ show: 'always',
+ },
{title: 'Filter'},
- {title: 'Settings', icon: nativeImageSource({
- android: 'ic_settings_black_48dp',
- width: 96,
- height: 96
- }), show: 'always'},
+ {
+ title: 'Settings',
+ icon: nativeImageSource({
+ android: 'ic_settings_black_48dp',
+ width: 96,
+ height: 96,
+ }),
+ show: 'always',
+ },
];
var styles = StyleSheet.create({
diff --git a/RNTester/js/ToolbarAndroidExample.ios.js b/RNTester/js/ToolbarAndroidExample.ios.js
index 5e8c57f7a..25bf7dba0 100644
--- a/RNTester/js/ToolbarAndroidExample.ios.js
+++ b/RNTester/js/ToolbarAndroidExample.ios.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// Not applicable to iOS.
diff --git a/RNTester/js/TouchableExample.js b/RNTester/js/TouchableExample.js
index 069dff9d2..3ce3faa45 100644
--- a/RNTester/js/TouchableExample.js
+++ b/RNTester/js/TouchableExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
@@ -24,115 +26,130 @@ var {
const NativeModules = require('NativeModules');
-const forceTouchAvailable = (NativeModules.PlatformConstants &&
- NativeModules.PlatformConstants.forceTouchAvailable) || false;
+const forceTouchAvailable =
+ (NativeModules.PlatformConstants &&
+ NativeModules.PlatformConstants.forceTouchAvailable) ||
+ false;
exports.displayName = (undefined: ?string);
exports.description = 'Touchable and onPress examples.';
exports.title = ' and onPress';
exports.examples = [
-{
- title: '',
- description: 'TouchableHighlight works by adding an extra view with a ' +
- 'black background under the single child view. This works best when the ' +
- 'child view is fully opaque, although it can be made to work as a simple ' +
- 'background color change as well with the activeOpacity and ' +
- 'underlayColor props.',
- render: function() {
- return (
-
-
- console.log('stock THW image - highlight')}>
-
-
- console.log('custom THW text - highlight')}>
-
-
- Tap Here For Custom Highlight!
-
-
-
+ {
+ title: '',
+ description:
+ 'TouchableHighlight works by adding an extra view with a ' +
+ 'black background under the single child view. This works best when the ' +
+ 'child view is fully opaque, although it can be made to work as a simple ' +
+ 'background color change as well with the activeOpacity and ' +
+ 'underlayColor props.',
+ render: function() {
+ return (
+
+
+ console.log('stock THW image - highlight')}>
+
+
+ console.log('custom THW text - highlight')}>
+
+ Tap Here For Custom Highlight!
+
+
+
-
- );
+ );
+ },
},
- }, {
- title: 'TouchableNativeFeedback with Animated child',
- description: 'TouchableNativeFeedback can have an AnimatedComponent as a' +
- 'direct child.',
- platform: 'android',
- render: function() {
- const mScale = new Animated.Value(1);
- Animated.timing(mScale, {toValue: 0.3, duration: 1000}).start();
- const style = {
- backgroundColor: 'rgb(180, 64, 119)',
- width: 200,
- height: 100,
- transform: [{scale: mScale}]
- };
- return (
-
-
-
-
-
+ {
+ title: 'TouchableNativeFeedback with Animated child',
+ description:
+ 'TouchableNativeFeedback can have an AnimatedComponent as a' +
+ 'direct child.',
+ platform: 'android',
+ render: function() {
+ const mScale = new Animated.Value(1);
+ Animated.timing(mScale, {toValue: 0.3, duration: 1000}).start();
+ const style = {
+ backgroundColor: 'rgb(180, 64, 119)',
+ width: 200,
+ height: 100,
+ transform: [{scale: mScale}],
+ };
+ return (
+
+
+
+
+
+
-
- );
+ );
+ },
},
-}, {
- title: ' with highlight',
- render: function(): React.Element {
- return ;
+ {
+ title: ' with highlight',
+ render: function(): React.Element {
+ return ;
+ },
},
-}, {
- title: 'Touchable feedback events',
- description: ' components accept onPress, onPressIn, ' +
- 'onPressOut, and onLongPress as props.',
- render: function(): React.Element {
- return ;
+ {
+ title: 'Touchable feedback events',
+ description:
+ ' components accept onPress, onPressIn, ' +
+ 'onPressOut, and onLongPress as props.',
+ render: function(): React.Element {
+ return ;
+ },
},
-}, {
- title: 'Touchable delay for events',
- description: ' components also accept delayPressIn, ' +
- 'delayPressOut, and delayLongPress as props. These props impact the ' +
- 'timing of feedback events.',
- render: function(): React.Element {
- return ;
+ {
+ title: 'Touchable delay for events',
+ description:
+ ' components also accept delayPressIn, ' +
+ 'delayPressOut, and delayLongPress as props. These props impact the ' +
+ 'timing of feedback events.',
+ render: function(): React.Element {
+ return ;
+ },
},
-}, {
- title: '3D Touch / Force Touch',
- description: 'iPhone 6s and 6s plus support 3D touch, which adds a force property to touches',
- render: function(): React.Element {
- return ;
+ {
+ title: '3D Touch / Force Touch',
+ description:
+ 'iPhone 6s and 6s plus support 3D touch, which adds a force property to touches',
+ render: function(): React.Element {
+ return ;
+ },
+ platform: 'ios',
},
- platform: 'ios',
-}, {
- title: 'Touchable Hit Slop',
- description: ' components accept hitSlop prop which extends the touch area ' +
- 'without changing the view bounds.',
- render: function(): React.Element {
- return ;
- },
-}, {
- title: 'Disabled Touchable*',
- description: ' components accept disabled prop which prevents ' +
- 'any interaction with component',
- render: function(): React.Element {
- return ;
- },
- }];
+ {
+ title: 'Touchable Hit Slop',
+ description:
+ ' components accept hitSlop prop which extends the touch area ' +
+ 'without changing the view bounds.',
+ render: function(): React.Element {
+ return ;
+ },
+ },
+ {
+ title: 'Disabled Touchable*',
+ description:
+ ' components accept disabled prop which prevents ' +
+ 'any interaction with component',
+ render: function(): React.Element {
+ return ;
+ },
+ },
+];
class TextOnPressBox extends React.Component<{}, $FlowFixMeState> {
state = {
@@ -155,15 +172,11 @@ class TextOnPressBox extends React.Component<{}, $FlowFixMeState> {
return (
-
+
Text has built-in onPress handling
-
- {textLog}
-
+ {textLog}
);
@@ -189,19 +202,19 @@ class TouchableFeedbackEvents extends React.Component<{}, $FlowFixMeState> {
onPressIn={() => this._appendEvent('pressIn')}
onPressOut={() => this._appendEvent('pressOut')}
onLongPress={() => this._appendEvent('longPress')}>
-
- Press Me
-
+ Press Me
-
+
{this.state.eventLog.map((e, ii) => {e})}
);
}
- _appendEvent = (eventName) => {
+ _appendEvent = eventName => {
var limit = 6;
var eventLog = this.state.eventLog.slice(0, limit - 1);
eventLog.unshift(eventName);
@@ -228,19 +241,19 @@ class TouchableDelayEvents extends React.Component<{}, $FlowFixMeState> {
onPressOut={() => this._appendEvent('pressOut - 1000ms delay')}
delayLongPress={800}
onLongPress={() => this._appendEvent('longPress - 800ms delay')}>
-
- Press Me
-
+ Press Me
-
+
{this.state.eventLog.map((e, ii) => {e})}
);
}
- _appendEvent = (eventName) => {
+ _appendEvent = eventName => {
var limit = 6;
var eventLog = this.state.eventLog.slice(0, limit - 1);
eventLog.unshift(eventName);
@@ -254,9 +267,9 @@ class ForceTouchExample extends React.Component<{}, $FlowFixMeState> {
};
_renderConsoleText = () => {
- return forceTouchAvailable ?
- 'Force: ' + this.state.force.toFixed(3) :
- '3D Touch is not available on this device';
+ return forceTouchAvailable
+ ? 'Force: ' + this.state.force.toFixed(3)
+ : '3D Touch is not available on this device';
};
render() {
@@ -270,11 +283,11 @@ class ForceTouchExample extends React.Component<{}, $FlowFixMeState> {
style={styles.wrapper}
testID="touchable_3dtouch_button"
onStartShouldSetResponder={() => true}
- onResponderMove={(event) => this.setState({force: event.nativeEvent.force})}
- onResponderRelease={(event) => this.setState({force: 0})}>
-
- Press Me
-
+ onResponderMove={event =>
+ this.setState({force: event.nativeEvent.force})
+ }
+ onResponderRelease={event => this.setState({force: 0})}>
+ Press Me
@@ -309,15 +322,11 @@ class TouchableHitSlop extends React.Component<{}, $FlowFixMeState> {
style={styles.hitSlopWrapper}
hitSlop={{top: 30, bottom: 30, left: 60, right: 60}}
testID="touchable_hit_slop_button">
-
- Press Outside This View
-
+ Press Outside This View
-
+
-
- {log}
-
+ {log}
);
@@ -343,9 +352,7 @@ class TouchableDisabled extends React.Component<{}> {
underlayColor="rgb(210, 230, 255)"
style={[styles.row, styles.block]}
onPress={() => console.log('custom THW text - highlight')}>
-
- Disabled TouchableHighlight
-
+ Disabled TouchableHighlight
{
underlayColor="rgb(210, 230, 255)"
style={[styles.row, styles.block]}
onPress={() => console.log('custom THW text - highlight')}>
-
- Enabled TouchableHighlight
-
+ Enabled TouchableHighlight
- {Platform.OS === 'android' &&
+ {Platform.OS === 'android' && (
console.log('custom TNF has been clicked')}
@@ -370,21 +375,22 @@ class TouchableDisabled extends React.Component<{}> {
- }
+ )}
- {Platform.OS === 'android' &&
+ {Platform.OS === 'android' && (
console.log('custom TNF has been clicked')}
background={TouchableNativeFeedback.SelectableBackground()}>
-
+
Disabled TouchableNativeFeedback
- }
+ )}
);
}
diff --git a/RNTester/js/TransformExample.js b/RNTester/js/TransformExample.js
index 4271e074a..8af5fc55d 100644
--- a/RNTester/js/TransformExample.js
+++ b/RNTester/js/TransformExample.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- Animated,
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {Animated, StyleSheet, Text, View} = ReactNative;
class Flip extends React.Component<{}, $FlowFixMeState> {
state = {
@@ -37,33 +34,42 @@ class Flip extends React.Component<{}, $FlowFixMeState> {
render() {
return (
-
-
- This text is flipping great.
-
+
+ This text is flipping great.
-
-
- On the flip side...
-
+
+ On the flip side...
);
@@ -110,9 +116,7 @@ var styles = StyleSheet.create({
height: 50,
position: 'absolute',
top: 0,
- transform: [
- {rotate: '30deg'},
- ],
+ transform: [{rotate: '30deg'}],
width: 50,
},
box3step2: {
@@ -122,11 +126,7 @@ var styles = StyleSheet.create({
opacity: 0.5,
position: 'absolute',
top: 0,
- transform: [
- {rotate: '30deg'},
- {scaleX: 2},
- {scaleY: 2},
- ],
+ transform: [{rotate: '30deg'}, {scaleX: 2}, {scaleY: 2}],
width: 50,
},
box3step3: {
@@ -151,11 +151,7 @@ var styles = StyleSheet.create({
height: 50,
position: 'absolute',
top: 0,
- transform: [
- {translate: [200, 350]},
- {scale: 2.5},
- {rotate: '-0.2rad'},
- ],
+ transform: [{translate: [200, 350]}, {scale: 2.5}, {rotate: '-0.2rad'}],
width: 100,
},
box5: {
@@ -167,11 +163,7 @@ var styles = StyleSheet.create({
width: 50,
},
box5Transform: {
- transform: [
- {translate: [-50, 35]},
- {rotate: '50deg'},
- {scale: 2},
- ],
+ transform: [{translate: [-50, 35]}, {rotate: '50deg'}, {scale: 2}],
},
flipCardContainer: {
marginVertical: 40,
@@ -191,7 +183,7 @@ var styles = StyleSheet.create({
fontSize: 20,
color: 'white',
fontWeight: 'bold',
- }
+ },
});
exports.title = 'Transforms';
@@ -200,29 +192,33 @@ exports.examples = [
{
title: 'Perspective, Rotate, Animation',
description: 'perspective: 850, rotateX: Animated.timing(0 -> 360)',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Translate, Rotate, Scale',
- description: "translateX: 100, translateY: 50, rotate: '30deg', scaleX: 2, scaleY: 2",
+ description:
+ "translateX: 100, translateY: 50, rotate: '30deg', scaleX: 2, scaleY: 2",
render() {
return (
);
- }
+ },
},
{
title: 'Scale, Translate, Rotate, ',
- description: "scaleX: 2, scaleY: 2, translateX: 100, translateY: 50, rotate: '30deg'",
+ description:
+ "scaleX: 2, scaleY: 2, translateX: 100, translateY: 50, rotate: '30deg'",
render() {
return (
);
- }
+ },
},
{
title: 'Rotate',
@@ -233,7 +229,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Rotate, Scale',
@@ -244,18 +240,19 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Rotate, Scale, Translate ',
- description: "rotate: '30deg', scaleX: 2, scaleY: 2, translateX: 100, translateY: 50",
+ description:
+ "rotate: '30deg', scaleX: 2, scaleY: 2, translateX: 100, translateY: 50",
render() {
return (
);
- }
+ },
},
{
title: 'Translate, Scale, Rotate',
@@ -266,7 +263,7 @@ exports.examples = [
);
- }
+ },
},
{
title: 'Translate, Rotate, Scale',
@@ -277,6 +274,6 @@ exports.examples = [
);
- }
- }
+ },
+ },
];
diff --git a/RNTester/js/TransparentHitTestExample.js b/RNTester/js/TransparentHitTestExample.js
index e1baa0096..7ba595bee 100644
--- a/RNTester/js/TransparentHitTestExample.js
+++ b/RNTester/js/TransparentHitTestExample.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -11,11 +12,7 @@
var React = require('react');
var ReactNative = require('react-native');
-var {
- Text,
- View,
- TouchableOpacity,
-} = ReactNative;
+var {Text, View, TouchableOpacity} = ReactNative;
class TransparentHitTestExample extends React.Component<{}> {
render() {
@@ -25,14 +22,17 @@ class TransparentHitTestExample extends React.Component<{}> {
HELLO!
-
+
);
}
@@ -44,6 +44,8 @@ exports.description = 'Transparent view receiving touch events';
exports.examples = [
{
title: 'TransparentHitTestExample',
- render(): React.Element { return ; }
- }
+ render(): React.Element {
+ return ;
+ },
+ },
];
diff --git a/RNTester/js/URIActionMap.js b/RNTester/js/URIActionMap.js
index f303fa21a..cf33d0104 100644
--- a/RNTester/js/URIActionMap.js
+++ b/RNTester/js/URIActionMap.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const ReactNative = require('react-native');
@@ -13,11 +15,9 @@ const RNTesterActions = require('./RNTesterActions');
// $FlowFixMe : This is a platform-forked component, and flow seems to only run on iOS?
const RNTesterList = require('./RNTesterList');
-const {
- Alert,
-} = ReactNative;
+const {Alert} = ReactNative;
-import type { RNTesterAction } from './RNTesterActions';
+import type {RNTesterAction} from './RNTesterActions';
function PathActionMap(path: string): ?RNTesterAction {
// Warning! Hacky parsing for example code. Use a library for this!
diff --git a/RNTester/js/VibrationExample.js b/RNTester/js/VibrationExample.js
index a21379990..ed12bd1e5 100644
--- a/RNTester/js/VibrationExample.js
+++ b/RNTester/js/VibrationExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
diff --git a/RNTester/js/VibrationIOSExample.js b/RNTester/js/VibrationIOSExample.js
index 5f642519d..59e96b673 100644
--- a/RNTester/js/VibrationIOSExample.js
+++ b/RNTester/js/VibrationIOSExample.js
@@ -4,37 +4,35 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- View,
- Text,
- TouchableHighlight,
- VibrationIOS
-} = ReactNative;
+var {StyleSheet, View, Text, TouchableHighlight, VibrationIOS} = ReactNative;
exports.framework = 'React';
exports.title = 'VibrationIOS';
exports.description = 'Vibration API for iOS';
-exports.examples = [{
- title: 'VibrationIOS.vibrate()',
- render() {
- return (
- VibrationIOS.vibrate()}>
-
- Vibrate
-
-
- );
+exports.examples = [
+ {
+ title: 'VibrationIOS.vibrate()',
+ render() {
+ return (
+ VibrationIOS.vibrate()}>
+
+ Vibrate
+
+
+ );
+ },
},
-}];
+];
var styles = StyleSheet.create({
wrapper: {
diff --git a/RNTester/js/ViewExample.js b/RNTester/js/ViewExample.js
index 5d643a12f..1cc4ad686 100644
--- a/RNTester/js/ViewExample.js
+++ b/RNTester/js/ViewExample.js
@@ -4,17 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- View,
-} = ReactNative;
+var {StyleSheet, Text, View} = ReactNative;
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var styles = StyleSheet.create({
@@ -33,32 +31,30 @@ var styles = StyleSheet.create({
class ViewBorderStyleExample extends React.Component<{}, $FlowFixMeState> {
state = {
- showBorder: true
+ showBorder: true,
};
render() {
return (
-
-
- Dashed border style
-
+
+ Dashed border style
-
-
- Dotted border style
-
+
+ Dotted border style
@@ -72,7 +68,7 @@ class ViewBorderStyleExample extends React.Component<{}, $FlowFixMeState> {
class ZIndexExample extends React.Component<{}, $FlowFixMeState> {
state = {
- flipped: false
+ flipped: false,
};
render() {
@@ -81,28 +77,32 @@ class ZIndexExample extends React.Component<{}, $FlowFixMeState> {
Tap to flip sorting order
-
+
ZIndex {indices[0]}
-
+
ZIndex {indices[1]}
-
+
ZIndex {indices[2]}
-
+
ZIndex {indices[3]}
@@ -116,7 +116,8 @@ class ZIndexExample extends React.Component<{}, $FlowFixMeState> {
}
exports.title = '';
-exports.description = 'Basic building block of all UI, examples that ' +
+exports.description =
+ 'Basic building block of all UI, examples that ' +
'demonstrate some of the many styles available.';
exports.displayName = 'ViewExample';
@@ -126,13 +127,12 @@ exports.examples = [
render: function() {
return (
-
- Blue background
-
+ Blue background
);
},
- }, {
+ },
+ {
title: 'Border',
render: function() {
return (
@@ -141,7 +141,8 @@ exports.examples = [
);
},
- }, {
+ },
+ {
title: 'Padding/Margin',
render: function() {
return (
@@ -152,43 +153,48 @@ exports.examples = [
5px margin
-
-
- 5px margin and padding,
-
-
- widthAutonomous=true
-
+
+ 5px margin and padding,
+ widthAutonomous=true
);
},
- }, {
+ },
+ {
title: 'Border Radius',
render: function() {
return (
- Too much use of `borderRadius` (especially large radii) on
- anything which is scrolling may result in dropped frames.
- Use sparingly.
+ Too much use of `borderRadius` (especially large radii) on anything
+ which is scrolling may result in dropped frames. Use sparingly.
);
},
- }, {
+ },
+ {
title: 'Border Style',
render: function() {
return ;
},
- }, {
+ },
+ {
title: 'Circle with Border Radius',
render: function() {
return (
-
+
);
},
- }, {
+ },
+ {
title: 'Overflow',
render: function() {
return (
@@ -206,7 +212,8 @@ exports.examples = [
Overflow hidden
-
+
Overflow visible
@@ -214,22 +221,38 @@ exports.examples = [
);
},
- }, {
+ },
+ {
title: 'Opacity',
render: function() {
return (
- Opacity 0
- Opacity 0.1
- Opacity 0.3
- Opacity 0.5
- Opacity 0.7
- Opacity 0.9
- Opacity 1
+
+ Opacity 0
+
+
+ Opacity 0.1
+
+
+ Opacity 0.3
+
+
+ Opacity 0.5
+
+
+ Opacity 0.7
+
+
+ Opacity 0.9
+
+
+ Opacity 1
+
);
},
- }, {
+ },
+ {
title: 'ZIndex',
render: function() {
return ;
diff --git a/RNTester/js/ViewPagerAndroidExample.android.js b/RNTester/js/ViewPagerAndroidExample.android.js
index 1c5da99ba..1eb60ad3d 100644
--- a/RNTester/js/ViewPagerAndroidExample.android.js
+++ b/RNTester/js/ViewPagerAndroidExample.android.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
var React = require('react');
@@ -19,7 +21,7 @@ var {
ViewPagerAndroid,
} = ReactNative;
-import type { ViewPagerScrollState } from 'ViewPagerAndroid';
+import type {ViewPagerScrollState} from 'ViewPagerAndroid';
var PAGES = 5;
var BGCOLOR = ['#fdc08e', '#fff6b9', '#99d1b7', '#dde5fe', '#f79273'];
@@ -45,13 +47,9 @@ class LikeCount extends React.Component {
return (
-
- {thumbsUp + ' Like'}
-
+ {thumbsUp + ' Like'}
-
- {this.state.likes + ' likes'}
-
+ {this.state.likes + ' likes'}
);
}
@@ -67,7 +65,11 @@ class Button extends React.Component {
render() {
return (
-
+
{this.props.text}
@@ -77,11 +79,12 @@ class Button extends React.Component {
class ProgressBar extends React.Component {
render() {
- var fractionalPosition = (this.props.progress.position + this.props.progress.offset);
- var progressBarSize = (fractionalPosition / (PAGES - 1)) * this.props.size;
+ var fractionalPosition =
+ this.props.progress.position + this.props.progress.offset;
+ var progressBarSize = fractionalPosition / (PAGES - 1) * this.props.size;
return (
-
+
);
}
@@ -101,24 +104,24 @@ class ViewPagerAndroidExample extends React.Component {
},
};
- onPageSelected = (e) => {
+ onPageSelected = e => {
this.setState({page: e.nativeEvent.position});
};
- onPageScroll = (e) => {
+ onPageScroll = e => {
this.setState({progress: e.nativeEvent});
};
- onPageScrollStateChanged = (state : ViewPagerScrollState) => {
+ onPageScrollStateChanged = (state: ViewPagerScrollState) => {
this.setState({scrollState: state});
};
- move = (delta) => {
+ move = delta => {
var page = this.state.page + delta;
this.go(page);
};
- go = (page) => {
+ go = page => {
if (this.state.animationsAreEnabled) {
this.viewPager.setPage(page);
} else {
@@ -143,10 +146,10 @@ class ViewPagerAndroidExample extends React.Component {
source={{uri: IMAGE_URIS[i % BGCOLOR.length]}}
/>
-
+ ,
);
}
- var { page, animationsAreEnabled } = this.state;
+ var {page, animationsAreEnabled} = this.state;
return (
{ this.viewPager = viewPager; }}>
+ ref={viewPager => {
+ this.viewPager = viewPager;
+ }}>
{pages}
this.setState({scrollEnabled: !this.state.scrollEnabled})}
+ text={
+ this.state.scrollEnabled ? 'Scroll Enabled' : 'Scroll Disabled'
+ }
+ onPress={() =>
+ this.setState({scrollEnabled: !this.state.scrollEnabled})
+ }
/>
- { animationsAreEnabled ?
+ {animationsAreEnabled ? (
this.setState({animationsAreEnabled: false})}
- /> :
+ />
+ ) : (
this.setState({animationsAreEnabled: true})}
- /> }
- ScrollState[ {this.state.scrollState} ]
+ />
+ )}
+
+ ScrollState[ {this.state.scrollState} ]
+
- 0} onPress={() => this.go(0)}/>
- 0} onPress={() => this.move(-1)}/>
- Page {page + 1} / {PAGES}
-
- this.move(1)}/>
- this.go(PAGES - 1)}/>
+ 0} onPress={() => this.go(0)} />
+ 0}
+ onPress={() => this.move(-1)}
+ />
+
+ Page {page + 1} / {PAGES}
+
+
+ this.move(1)}
+ />
+ this.go(PAGES - 1)}
+ />
);
diff --git a/RNTester/js/WebViewExample.js b/RNTester/js/WebViewExample.js
index 84b99001e..fdb0abb61 100644
--- a/RNTester/js/WebViewExample.js
+++ b/RNTester/js/WebViewExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
@@ -17,7 +19,7 @@ var {
TouchableWithoutFeedback,
TouchableOpacity,
View,
- WebView
+ WebView,
} = ReactNative;
var HEADER = '#3b5998';
@@ -41,7 +43,7 @@ class WebViewExample extends React.Component<{}, $FlowFixMeState> {
inputText = '';
- handleTextInputChange = (event) => {
+ handleTextInputChange = event => {
var url = event.nativeEvent.text;
if (!/^[a-zA-Z-_]+:/.test(url)) {
url = 'http://' + url;
@@ -57,17 +59,21 @@ class WebViewExample extends React.Component<{}, $FlowFixMeState> {
-
- {'<'}
-
+ style={
+ this.state.backButtonEnabled
+ ? styles.navButton
+ : styles.disabledButton
+ }>
+ {'<'}
-
- {'>'}
-
+ style={
+ this.state.forwardButtonEnabled
+ ? styles.navButton
+ : styles.disabledButton
+ }>
+ {'>'}
{
/>
-
- Go!
-
+ Go!
@@ -118,23 +122,23 @@ class WebViewExample extends React.Component<{}, $FlowFixMeState> {
this.refs[WEBVIEW_REF].reload();
};
- onShouldStartLoadWithRequest = (event) => {
+ onShouldStartLoadWithRequest = event => {
// Implement any custom loading logic here, don't forget to return!
return true;
};
- onNavigationStateChange = (navState) => {
+ onNavigationStateChange = navState => {
this.setState({
backButtonEnabled: navState.canGoBack,
forwardButtonEnabled: navState.canGoForward,
url: navState.url,
status: navState.title,
loading: navState.loading,
- scalesPageToFit: true
+ scalesPageToFit: true,
});
};
- onSubmitEditing = (event) => {
+ onSubmitEditing = event => {
this.pressGoButton();
};
@@ -187,17 +191,19 @@ class ScaledWebView extends React.Component<{}, $FlowFixMeState> {
scalesPageToFit={this.state.scalingEnabled}
/>
- { this.state.scalingEnabled ?
- this.setState({scalingEnabled: false})}
- /> :
- this.setState({scalingEnabled: true})}
- /> }
+ {this.state.scalingEnabled ? (
+ this.setState({scalingEnabled: false})}
+ />
+ ) : (
+ this.setState({scalingEnabled: true})}
+ />
+ )}
);
@@ -205,39 +211,48 @@ class ScaledWebView extends React.Component<{}, $FlowFixMeState> {
}
class MessagingTest extends React.Component<{}, $FlowFixMeState> {
- webview = null
+ webview = null;
state = {
messagesReceivedFromWebView: 0,
message: '',
- }
+ };
- onMessage = e => this.setState({
- messagesReceivedFromWebView: this.state.messagesReceivedFromWebView + 1,
- message: e.nativeEvent.data,
- })
+ onMessage = e =>
+ this.setState({
+ messagesReceivedFromWebView: this.state.messagesReceivedFromWebView + 1,
+ message: e.nativeEvent.data,
+ });
postMessage = () => {
if (this.webview) {
this.webview.postMessage('"Hello" from React Native!');
}
- }
+ };
render(): React.Node {
const {messagesReceivedFromWebView, message} = this.state;
return (
-
+
- Messages received from web view: {messagesReceivedFromWebView}
+
+ Messages received from web view: {messagesReceivedFromWebView}
+
{message || '(No message)'}
-
+
{ this.webview = webview; }}
+ ref={webview => {
+ this.webview = webview;
+ }}
style={{
backgroundColor: BGWASH,
height: 100,
@@ -259,12 +274,14 @@ class InjectJS extends React.Component<{}> {
if (this.webview) {
this.webview.injectJavaScript(script);
}
- }
+ };
render() {
return (
{ this.webview = webview; }}
+ ref={webview => {
+ this.webview = webview;
+ }}
style={{
backgroundColor: BGWASH,
height: 300,
@@ -275,12 +292,11 @@ class InjectJS extends React.Component<{}> {
-
+
);
}
}
-
var styles = StyleSheet.create({
container: {
flex: 1,
@@ -401,11 +417,15 @@ exports.description = 'Base component to display web content';
exports.examples = [
{
title: 'Simple Browser',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Scale Page to Fit',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Bundled HTML',
@@ -421,7 +441,7 @@ exports.examples = [
scalesPageToFit={true}
/>
);
- }
+ },
},
{
title: 'Static HTML',
@@ -436,7 +456,7 @@ exports.examples = [
scalesPageToFit={true}
/>
);
- }
+ },
},
{
title: 'POST Test',
@@ -450,19 +470,23 @@ exports.examples = [
source={{
uri: 'http://www.posttestserver.com/post.php',
method: 'POST',
- body: 'foo=bar&bar=foo'
+ body: 'foo=bar&bar=foo',
}}
scalesPageToFit={false}
/>
);
- }
+ },
},
{
title: 'Messaging Test',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
{
title: 'Inject JavaScript',
- render(): React.Element { return ; }
+ render(): React.Element {
+ return ;
+ },
},
];
diff --git a/RNTester/js/XHRExample.js b/RNTester/js/XHRExample.js
index fc7cb8c21..5cec37c1d 100644
--- a/RNTester/js/XHRExample.js
+++ b/RNTester/js/XHRExample.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
@@ -20,41 +22,50 @@ var XHRExampleCookies = require('./XHRExampleCookies');
exports.framework = 'React';
exports.title = 'XMLHttpRequest';
-exports.description = 'Example that demonstrates upload and download ' +
+exports.description =
+ 'Example that demonstrates upload and download ' +
'requests using XMLHttpRequest.';
-exports.examples = [{
- title: 'File Download',
- render() {
- return ;
- }
-}, {
- title: 'multipart/form-data Upload',
- render() {
- return ;
- }
-}, {
- title: 'multipart/form-data Upload',
- render() {
- return ;
- }
-}, {
- title: 'Fetch Test',
- render() {
- return ;
- }
-}, {
- title: 'Headers',
- render() {
- return ;
- }
-}, {
- title: 'Time Out Test',
- render() {
- return ;
- }
-}, {
- title: 'Cookies',
- render() {
- return ;
- }
-}];
+exports.examples = [
+ {
+ title: 'File Download',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'multipart/form-data Upload',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'multipart/form-data Upload',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Fetch Test',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Headers',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Time Out Test',
+ render() {
+ return ;
+ },
+ },
+ {
+ title: 'Cookies',
+ render() {
+ return ;
+ },
+ },
+];
diff --git a/RNTester/js/XHRExampleBinaryUpload.js b/RNTester/js/XHRExampleBinaryUpload.js
index efe96dea0..1321522cc 100644
--- a/RNTester/js/XHRExampleBinaryUpload.js
+++ b/RNTester/js/XHRExampleBinaryUpload.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
@@ -47,30 +49,22 @@ That is my proper element.
--Faust, JW Goethe
`;
-
class XHRExampleBinaryUpload extends React.Component<{}, $FlowFixMeState> {
-
static handlePostTestServerUpload(xhr: XMLHttpRequest) {
if (xhr.status !== 200) {
Alert.alert(
'Upload failed',
- 'Expected HTTP 200 OK response, got ' + xhr.status
+ 'Expected HTTP 200 OK response, got ' + xhr.status,
);
return;
}
if (!xhr.responseText) {
- Alert.alert(
- 'Upload failed',
- 'No response payload.'
- );
+ Alert.alert('Upload failed', 'No response payload.');
return;
}
var index = xhr.responseText.indexOf('http://www.posttestserver.com/');
if (index === -1) {
- Alert.alert(
- 'Upload failed',
- 'Invalid response payload.'
- );
+ Alert.alert('Upload failed', 'Invalid response payload.');
return;
}
var url = xhr.responseText.slice(index).split('\n')[0];
@@ -117,8 +111,8 @@ class XHRExampleBinaryUpload extends React.Component<{}, $FlowFixMeState> {
Upload 255 bytes as...
this.setState({type})}>
- {Object.keys(BINARY_TYPES).map((type) => (
+ onValueChange={type => this.setState({type})}>
+ {Object.keys(BINARY_TYPES).map(type => (
))}
@@ -132,7 +126,6 @@ class XHRExampleBinaryUpload extends React.Component<{}, $FlowFixMeState> {
);
}
-
}
const styles = StyleSheet.create({
diff --git a/RNTester/js/XHRExampleCookies.js b/RNTester/js/XHRExampleCookies.js
index 2050f555e..6008e7a1a 100644
--- a/RNTester/js/XHRExampleCookies.js
+++ b/RNTester/js/XHRExampleCookies.js
@@ -4,19 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
- WebView,
-} = ReactNative;
+var {StyleSheet, Text, TouchableHighlight, View, WebView} = ReactNative;
var RCTNetworking = require('RCTNetworking');
@@ -36,7 +32,7 @@ class XHRExampleCookies extends React.Component {
setCookie(domain: string) {
var {a, b} = this.state;
var url = `https://${domain}/cookies/set?a=${a}&b=${b}`;
- fetch(url).then((response) => {
+ fetch(url).then(response => {
this.setStatus(`Cookies a=${a}, b=${b} set`);
this.refreshWebview();
});
@@ -49,18 +45,22 @@ class XHRExampleCookies extends React.Component {
}
getCookies(domain: string) {
- fetch(`https://${domain}/cookies`).then((response) => {
- return response.json();
- }).then((data) => {
- this.setStatus(`Got cookies ${JSON.stringify(data.cookies)} from server`);
- this.refreshWebview();
- });
+ fetch(`https://${domain}/cookies`)
+ .then(response => {
+ return response.json();
+ })
+ .then(data => {
+ this.setStatus(
+ `Got cookies ${JSON.stringify(data.cookies)} from server`,
+ );
+ this.refreshWebview();
+ });
this.setStatus('Getting cookies...');
}
clearCookies() {
- RCTNetworking.clearCookies((cleared) => {
+ RCTNetworking.clearCookies(cleared => {
this.setStatus('Cookies cleared, had cookies=' + cleared.toString());
this.refreshWebview();
});
diff --git a/RNTester/js/XHRExampleDownload.js b/RNTester/js/XHRExampleDownload.js
index 2ffe801fb..3cc4b34c5 100644
--- a/RNTester/js/XHRExampleDownload.js
+++ b/RNTester/js/XHRExampleDownload.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
@@ -40,11 +42,7 @@ class ProgressBar extends React.Component<$FlowFixMeProps> {
/>
);
}
- return (
-
- );
+ return ;
}
}
@@ -77,8 +75,10 @@ class XHRExampleDownload extends React.Component<{}, Object> {
const onreadystatechange = () => {
if (xhr.readyState === xhr.HEADERS_RECEIVED) {
- const contentLength =
- parseInt(xhr.getResponseHeader('Content-Length'), 10);
+ const contentLength = parseInt(
+ xhr.getResponseHeader('Content-Length'),
+ 10,
+ );
this.setState({
contentLength,
responseLength: 0,
@@ -89,7 +89,7 @@ class XHRExampleDownload extends React.Component<{}, Object> {
});
}
};
- const onprogress = (event) => {
+ const onprogress = event => {
this.setState({
progressTotal: event.total,
progressLoaded: event.loaded,
@@ -112,17 +112,19 @@ class XHRExampleDownload extends React.Component<{}, Object> {
return;
}
if (xhr.status === 200) {
- let responseType =
- `Response is a string, ${xhr.response.length} characters long.`;
+ let responseType = `Response is a string, ${
+ xhr.response.length
+ } characters long.`;
if (xhr.response instanceof ArrayBuffer) {
- responseType =
- `Response is an ArrayBuffer, ${xhr.response.byteLength} bytes long.`;
+ responseType = `Response is an ArrayBuffer, ${
+ xhr.response.byteLength
+ } bytes long.`;
}
Alert.alert('Download complete!', responseType);
} else if (xhr.status !== 0) {
Alert.alert(
'Error',
- `Server returned HTTP status of ${xhr.status}: ${xhr.responseText}`
+ `Server returned HTTP status of ${xhr.status}: ${xhr.responseText}`,
);
} else {
Alert.alert('Error', xhr.responseText);
@@ -134,7 +136,7 @@ class XHRExampleDownload extends React.Component<{}, Object> {
xhr.send();
this.setState({downloading: true});
- }
+ };
componentWillUnmount() {
this.cancelled = true;
@@ -149,9 +151,7 @@ class XHRExampleDownload extends React.Component<{}, Object> {
) : (
-
+
Download 5MB Text File
@@ -161,30 +161,26 @@ class XHRExampleDownload extends React.Component<{}, Object> {
let readystate = null;
let progress = null;
if (this.state.readystateHandler && !this.state.arraybuffer) {
- const { responseLength, contentLength } = this.state;
+ const {responseLength, contentLength} = this.state;
readystate = (
- responseText:{' '}
- {roundKilo(responseLength)}/{roundKilo(contentLength)}k chars
+ responseText: {roundKilo(responseLength)}/{roundKilo(contentLength)}k
+ chars
-
+
);
}
if (this.state.progressHandler) {
- const { progressLoaded, progressTotal } = this.state;
+ const {progressLoaded, progressTotal} = this.state;
progress = (
- onprogress:{' '}
- {roundKilo(progressLoaded)}/{roundKilo(progressTotal)} KB
+ onprogress: {roundKilo(progressLoaded)}/{roundKilo(progressTotal)}{' '}
+ KB
-
+
);
}
@@ -195,21 +191,23 @@ class XHRExampleDownload extends React.Component<{}, Object> {
onreadystatechange handler
this.setState({readystateHandler}))}
+ onValueChange={readystateHandler =>
+ this.setState({readystateHandler})
+ }
/>
onprogress handler
this.setState({progressHandler}))}
+ onValueChange={progressHandler => this.setState({progressHandler})}
/>
download as arraybuffer
this.setState({arraybuffer}))}
+ onValueChange={arraybuffer => this.setState({arraybuffer})}
/>
{button}
diff --git a/RNTester/js/XHRExampleFetch.js b/RNTester/js/XHRExampleFetch.js
index c4915ce56..72f1f7e43 100644
--- a/RNTester/js/XHRExampleFetch.js
+++ b/RNTester/js/XHRExampleFetch.js
@@ -4,20 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- TextInput,
- View,
- Platform,
-} = ReactNative;
-
+var {StyleSheet, Text, TextInput, View, Platform} = ReactNative;
class XHRExampleFetch extends React.Component {
responseURL: ?string;
@@ -26,20 +21,22 @@ class XHRExampleFetch extends React.Component {
constructor(props: any) {
super(props);
this.state = {
- responseText: null,
+ responseText: null,
};
this.responseURL = null;
this.responseHeaders = null;
}
submit(uri: String) {
- fetch(uri).then((response) => {
- this.responseURL = response.url;
- this.responseHeaders = response.headers;
- return response.text();
- }).then((body) => {
- this.setState({responseText: body});
- });
+ fetch(uri)
+ .then(response => {
+ this.responseURL = response.url;
+ this.responseHeaders = response.headers;
+ return response.text();
+ })
+ .then(body => {
+ this.setState({responseText: body});
+ });
}
_renderHeaders() {
@@ -52,13 +49,16 @@ class XHRExampleFetch extends React.Component {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = this.responseHeaders.get(key);
- responseHeaders.push({key}: {value});
+ responseHeaders.push(
+
+ {key}: {value}
+ ,
+ );
}
return responseHeaders;
}
render() {
-
var responseURL = this.responseURL ? (
Server response URL:
@@ -91,7 +91,7 @@ class XHRExampleFetch extends React.Component {
{
+ onSubmitEditing={event => {
this.submit(event.nativeEvent.text);
}}
style={styles.textInput}
diff --git a/RNTester/js/XHRExampleFormData.js b/RNTester/js/XHRExampleFormData.js
index 8c0080ea1..bc2e43b07 100644
--- a/RNTester/js/XHRExampleFormData.js
+++ b/RNTester/js/XHRExampleFormData.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
@@ -48,30 +50,25 @@ class XHRExampleFormData extends React.Component {
}
_fetchRandomPhoto = () => {
- CameraRoll.getPhotos(
- {first: PAGE_SIZE}
- ).then(
- (data) => {
- if (!this._isMounted) {
- return;
- }
- var edges = data.edges;
- var edge = edges[Math.floor(Math.random() * edges.length)];
- var randomPhoto = edge && edge.node && edge.node.image;
- if (randomPhoto) {
- let {width, height} = randomPhoto;
- width *= 0.25;
- height *= 0.25;
- ImageEditor.cropImage(
- randomPhoto.uri,
- {offset: {x: 0, y: 0}, size: {width, height}},
- (uri) => this.setState({randomPhoto: {uri}}),
- (error) => undefined
- );
- }
- },
- (error) => undefined
- );
+ CameraRoll.getPhotos({first: PAGE_SIZE}).then(data => {
+ if (!this._isMounted) {
+ return;
+ }
+ var edges = data.edges;
+ var edge = edges[Math.floor(Math.random() * edges.length)];
+ var randomPhoto = edge && edge.node && edge.node.image;
+ if (randomPhoto) {
+ let {width, height} = randomPhoto;
+ width *= 0.25;
+ height *= 0.25;
+ ImageEditor.cropImage(
+ randomPhoto.uri,
+ {offset: {x: 0, y: 0}, size: {width, height}},
+ uri => this.setState({randomPhoto: {uri}}),
+ error => undefined,
+ );
+ }
+ }, error => undefined);
};
_addTextParam = () => {
@@ -107,10 +104,10 @@ class XHRExampleFormData extends React.Component {
name: 'image.jpg',
});
}
- this.state.textParams.forEach(
- (param) => formdata.append(param.name, param.value)
+ this.state.textParams.forEach(param =>
+ formdata.append(param.name, param.value),
);
- xhr.upload.onprogress = (event) => {
+ xhr.upload.onprogress = event => {
if (event.lengthComputable) {
this.setState({uploadProgress: event.loaded / event.total});
}
@@ -124,10 +121,7 @@ class XHRExampleFormData extends React.Component {
var image = null;
if (this.state.randomPhoto) {
image = (
-
+
);
}
var textItems = this.state.textParams.map((item, index) => (
@@ -170,8 +164,9 @@ class XHRExampleFormData extends React.Component {
- Random photo from your library
- (
+ Random photo from your library (
update
)
@@ -185,9 +180,7 @@ class XHRExampleFormData extends React.Component {
Add a text param
-
- {uploadButton}
-
+ {uploadButton}
);
}
diff --git a/RNTester/js/XHRExampleHeaders.js b/RNTester/js/XHRExampleHeaders.js
index b3dc69edc..6fb4e28db 100644
--- a/RNTester/js/XHRExampleHeaders.js
+++ b/RNTester/js/XHRExampleHeaders.js
@@ -4,21 +4,17 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @noflow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
-} = ReactNative;
+var {StyleSheet, Text, TouchableHighlight, View} = ReactNative;
class XHRExampleHeaders extends React.Component {
-
xhr: XMLHttpRequest;
cancelled: boolean;
@@ -46,11 +42,15 @@ class XHRExampleHeaders extends React.Component {
if (xhr.status === 200) {
this.setState({
status: 'Download complete!',
- headers: xhr.getAllResponseHeaders()
+ headers: xhr.getAllResponseHeaders(),
});
} else if (xhr.status !== 0) {
this.setState({
- status: 'Error: Server returned HTTP status of ' + xhr.status + ' ' + xhr.responseText,
+ status:
+ 'Error: Server returned HTTP status of ' +
+ xhr.status +
+ ' ' +
+ xhr.responseText,
});
} else {
this.setState({
@@ -59,7 +59,10 @@ class XHRExampleHeaders extends React.Component {
}
}
};
- xhr.open('GET', 'https://httpbin.org/response-headers?header1=value&header2=value1&header2=value2');
+ xhr.open(
+ 'GET',
+ 'https://httpbin.org/response-headers?header1=value&header2=value1&header2=value2',
+ );
xhr.send();
this.xhr = xhr;
@@ -72,21 +75,22 @@ class XHRExampleHeaders extends React.Component {
}
render() {
- var button = this.state.status === 'Downloading...' ? (
-
-
- ...
+ var button =
+ this.state.status === 'Downloading...' ? (
+
+
+ ...
+
-
- ) : (
-
-
- Get headers
-
-
- );
+ ) : (
+
+
+ Get headers
+
+
+ );
return (
diff --git a/RNTester/js/XHRExampleOnTimeOut.js b/RNTester/js/XHRExampleOnTimeOut.js
index 1afb39904..57a918b53 100644
--- a/RNTester/js/XHRExampleOnTimeOut.js
+++ b/RNTester/js/XHRExampleOnTimeOut.js
@@ -4,18 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
var React = require('react');
var ReactNative = require('react-native');
-var {
- StyleSheet,
- Text,
- TouchableHighlight,
- View,
-} = ReactNative;
+var {StyleSheet, Text, TouchableHighlight, View} = ReactNative;
class XHRExampleOnTimeOut extends React.Component {
xhr: XMLHttpRequest;
@@ -24,7 +21,7 @@ class XHRExampleOnTimeOut extends React.Component {
super(props);
this.state = {
status: '',
- loading: false
+ loading: false,
};
}
@@ -33,7 +30,7 @@ class XHRExampleOnTimeOut extends React.Component {
var xhr = this.xhr || new XMLHttpRequest();
- xhr.onerror = ()=> {
+ xhr.onerror = () => {
console.log('Status ', xhr.status);
console.log('Error ', xhr.responseText);
};
@@ -41,7 +38,7 @@ class XHRExampleOnTimeOut extends React.Component {
xhr.ontimeout = () => {
this.setState({
status: xhr.responseText,
- loading: false
+ loading: false,
});
};
@@ -74,7 +71,7 @@ class XHRExampleOnTimeOut extends React.Component {
style={styles.wrapper}
onPress={this.loadTimeOutRequest.bind(this)}>
- Make Time Out Request
+ Make Time Out Request
);
diff --git a/RNTester/js/createExamplePage.js b/RNTester/js/createExamplePage.js
index 1ae3733b9..eba5a4952 100644
--- a/RNTester/js/createExamplePage.js
+++ b/RNTester/js/createExamplePage.js
@@ -4,19 +4,22 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
const React = require('react');
const RNTesterExampleContainer = require('./RNTesterExampleContainer');
-import type { ExampleModule } from 'ExampleTypes';
-
-var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
- : React.ComponentType {
+import type {ExampleModule} from 'ExampleTypes';
+var createExamplePage = function(
+ title: ?string,
+ exampleModule: ExampleModule,
+): React.ComponentType {
class ExamplePage extends React.Component<{}> {
render() {
return ;
diff --git a/ReactAndroid/src/androidTest/js/Asserts.js b/ReactAndroid/src/androidTest/js/Asserts.js
index 95fd89f27..467065d0e 100644
--- a/ReactAndroid/src/androidTest/js/Asserts.js
+++ b/ReactAndroid/src/androidTest/js/Asserts.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -15,8 +16,14 @@ var Asserts = {
if (expected !== actual) {
Assert.fail(
msg ||
- 'Expected: ' + expected + ', received: ' + actual + '\n' +
- 'at ' + (new Error()).stack);
+ 'Expected: ' +
+ expected +
+ ', received: ' +
+ actual +
+ '\n' +
+ 'at ' +
+ new Error().stack,
+ );
} else {
Assert.success();
}
diff --git a/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js b/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js
index b0e5571b2..497fc48e3 100644
--- a/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js
+++ b/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
diff --git a/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js b/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
index 4ba296cc7..b15808cde 100644
--- a/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
+++ b/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -16,7 +17,7 @@ var View = require('View');
class DatePickerDialogTestApp extends React.Component {
render() {
- return ();
+ return ;
}
}
@@ -31,14 +32,14 @@ var DatePickerDialogTestModule = {
RecordingModule.recordDismissed();
}
},
- ({code, message}) => RecordingModule.recordError()
+ ({code, message}) => RecordingModule.recordError(),
);
},
};
BatchedBridge.registerCallableModule(
'DatePickerDialogTestModule',
- DatePickerDialogTestModule
+ DatePickerDialogTestModule,
);
module.exports = DatePickerDialogTestModule;
diff --git a/ReactAndroid/src/androidTest/js/InitialPropsTestApp.js b/ReactAndroid/src/androidTest/js/InitialPropsTestApp.js
index 002ebf0cc..c031fde60 100644
--- a/ReactAndroid/src/androidTest/js/InitialPropsTestApp.js
+++ b/ReactAndroid/src/androidTest/js/InitialPropsTestApp.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
diff --git a/ReactAndroid/src/androidTest/js/JSResponderTestApp.js b/ReactAndroid/src/androidTest/js/JSResponderTestApp.js
index d6e7f878d..ff5180186 100644
--- a/ReactAndroid/src/androidTest/js/JSResponderTestApp.js
+++ b/ReactAndroid/src/androidTest/js/JSResponderTestApp.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
var React = require('React');
@@ -56,7 +58,7 @@ var styles = StyleSheet.create({
},
row: {
height: 30,
- }
+ },
});
module.exports = JSResponderTestApp;
diff --git a/ReactAndroid/src/androidTest/js/LayoutEventsTestApp.js b/ReactAndroid/src/androidTest/js/LayoutEventsTestApp.js
index 153089437..df25944f1 100644
--- a/ReactAndroid/src/androidTest/js/LayoutEventsTestApp.js
+++ b/ReactAndroid/src/androidTest/js/LayoutEventsTestApp.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -14,14 +15,13 @@ var View = require('View');
var RecordingModule = require('NativeModules').Recording;
const LAYOUT_SPECS = [
- [10, 10, 100, 100],
- [10, 10, 50, 50],
- [0, 0, 50, 50],
- [0, 0, 50, 50],
+ [10, 10, 100, 100],
+ [10, 10, 50, 50],
+ [0, 0, 50, 50],
+ [0, 0, 50, 50],
];
class LayoutEventsTestApp extends React.Component {
-
constructor() {
super();
this.state = {
@@ -30,9 +30,11 @@ class LayoutEventsTestApp extends React.Component {
this.numParentLayouts = 0;
}
- handleOnLayout = (e) => {
+ handleOnLayout = e => {
var layout = e.nativeEvent.layout;
- RecordingModule.record(layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height);
+ RecordingModule.record(
+ layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height,
+ );
if (this.state.specNumber >= LAYOUT_SPECS.length) {
// This will cause the test to fail
@@ -44,7 +46,7 @@ class LayoutEventsTestApp extends React.Component {
}
};
- handleParentOnLayout = (e) => {
+ handleParentOnLayout = e => {
if (this.numParentLayouts > 0) {
// This will cause the test to fail - the parent's layout doesn't change
// so we should only get the event once.
@@ -57,13 +59,19 @@ class LayoutEventsTestApp extends React.Component {
const layout = LAYOUT_SPECS[this.state.specNumber];
return (
+ onLayout={this.handleParentOnLayout}
+ testID="parent"
+ style={{left: 0, top: 0, width: 500, height: 500}}>
+ onLayout={this.handleOnLayout}
+ testID="container"
+ style={{
+ left: layout[0],
+ top: layout[1],
+ width: layout[2],
+ height: layout[3],
+ }}
+ />
);
}
diff --git a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js
index baf4f7bc0..03e156b6f 100644
--- a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js
+++ b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -19,29 +20,29 @@ var assertEquals = require('Asserts').assertEquals;
var styles = StyleSheet.create({
A: {
- 'width': 500,
- 'height': 500,
+ width: 500,
+ height: 500,
},
B: {
backgroundColor: 'rgb(255, 0, 0)',
- 'left': 50,
- 'top': 80,
- 'width': 200,
- 'height': 300,
+ left: 50,
+ top: 80,
+ width: 200,
+ height: 300,
},
C: {
backgroundColor: 'rgb(0, 255, 0)',
- 'left': 100,
- 'top': 70,
- 'width': 50,
- 'height': 150,
+ left: 100,
+ top: 70,
+ width: 50,
+ height: 150,
},
D: {
backgroundColor: 'rgb(0, 0, 255)',
- 'left': 400,
- 'top': 100,
- 'width': 50,
- 'height': 200,
+ left: 400,
+ top: 100,
+ width: 50,
+ height: 200,
},
});
@@ -90,114 +91,124 @@ var MeasureLayoutTestModule = {
});
},
verifyMeasureLayoutCRelativeToA: function() {
- UIManager.measureLayout(
- C,
- A,
- shouldNotCallThisCallback,
- function (x, y, width, height) {
- assertEquals(50, width);
- assertEquals(150, height);
- assertEquals(150, x);
- assertEquals(150, y);
- });
+ UIManager.measureLayout(C, A, shouldNotCallThisCallback, function(
+ x,
+ y,
+ width,
+ height,
+ ) {
+ assertEquals(50, width);
+ assertEquals(150, height);
+ assertEquals(150, x);
+ assertEquals(150, y);
+ });
},
verifyMeasureLayoutCRelativeToB: function() {
- UIManager.measureLayout(
- C,
- B,
- shouldNotCallThisCallback,
- function (x, y, width, height) {
- assertEquals(50, width);
- assertEquals(150, height);
- assertEquals(100, x);
- assertEquals(70, y);
- });
+ UIManager.measureLayout(C, B, shouldNotCallThisCallback, function(
+ x,
+ y,
+ width,
+ height,
+ ) {
+ assertEquals(50, width);
+ assertEquals(150, height);
+ assertEquals(100, x);
+ assertEquals(70, y);
+ });
},
verifyMeasureLayoutCRelativeToSelf: function() {
- UIManager.measureLayout(
- C,
- C,
- shouldNotCallThisCallback,
- function (x, y, width, height) {
- assertEquals(50, width);
- assertEquals(150, height);
- assertEquals(0, x);
- assertEquals(0, y);
- });
+ UIManager.measureLayout(C, C, shouldNotCallThisCallback, function(
+ x,
+ y,
+ width,
+ height,
+ ) {
+ assertEquals(50, width);
+ assertEquals(150, height);
+ assertEquals(0, x);
+ assertEquals(0, y);
+ });
},
verifyMeasureLayoutRelativeToParentOnViewA: function() {
UIManager.measureLayoutRelativeToParent(
A,
shouldNotCallThisCallback,
- function (x, y, width, height) {
+ function(x, y, width, height) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
assertEquals(0, y);
- });
+ },
+ );
},
verifyMeasureLayoutRelativeToParentOnViewB: function() {
UIManager.measureLayoutRelativeToParent(
B,
shouldNotCallThisCallback,
- function (x, y, width, height) {
+ function(x, y, width, height) {
assertEquals(200, width);
assertEquals(300, height);
assertEquals(50, x);
assertEquals(80, y);
- });
+ },
+ );
},
verifyMeasureLayoutRelativeToParentOnViewC: function() {
UIManager.measureLayoutRelativeToParent(
C,
shouldNotCallThisCallback,
- function (x, y, width, height) {
+ function(x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
assertEquals(70, y);
- });
+ },
+ );
},
verifyMeasureLayoutDRelativeToB: function() {
UIManager.measureLayout(
D,
B,
- function () {
+ function() {
assertEquals(true, true);
},
- shouldNotCallThisCallback);
+ shouldNotCallThisCallback,
+ );
},
verifyMeasureLayoutNonExistentTag: function() {
UIManager.measureLayout(
192,
A,
- function () {
+ function() {
assertEquals(true, true);
},
- shouldNotCallThisCallback);
+ shouldNotCallThisCallback,
+ );
},
verifyMeasureLayoutNonExistentAncestor: function() {
UIManager.measureLayout(
B,
192,
- function () {
+ function() {
assertEquals(true, true);
},
- shouldNotCallThisCallback);
+ shouldNotCallThisCallback,
+ );
},
verifyMeasureLayoutRelativeToParentNonExistentTag: function() {
UIManager.measureLayoutRelativeToParent(
192,
- function () {
+ function() {
assertEquals(true, true);
},
- shouldNotCallThisCallback);
+ shouldNotCallThisCallback,
+ );
},
};
BatchedBridge.registerCallableModule(
'MeasureLayoutTestModule',
- MeasureLayoutTestModule
+ MeasureLayoutTestModule,
);
module.exports = MeasureLayoutTestModule;
diff --git a/ReactAndroid/src/androidTest/js/MultitouchHandlingTestAppModule.js b/ReactAndroid/src/androidTest/js/MultitouchHandlingTestAppModule.js
index 0c591483f..58f6a4605 100644
--- a/ReactAndroid/src/androidTest/js/MultitouchHandlingTestAppModule.js
+++ b/ReactAndroid/src/androidTest/js/MultitouchHandlingTestAppModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -15,16 +16,16 @@ var TouchEventUtils = require('fbjs/lib/TouchEventUtils');
var View = require('View');
class TouchTestApp extends React.Component {
- handleStartShouldSetResponder = (e) => {
+ handleStartShouldSetResponder = e => {
return true;
};
- handleOnResponderMove = (e) => {
+ handleOnResponderMove = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
Recording.record('move;' + e.touches.length);
};
- handleResponderStart = (e) => {
+ handleResponderStart = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('start;' + e.touches.length);
@@ -33,7 +34,7 @@ class TouchTestApp extends React.Component {
}
};
- handleResponderEnd = (e) => {
+ handleResponderEnd = e => {
e = TouchEventUtils.extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('end;' + e.touches.length);
diff --git a/ReactAndroid/src/androidTest/js/NativeIdTestModule.js b/ReactAndroid/src/androidTest/js/NativeIdTestModule.js
index be457b3c5..eb791c356 100644
--- a/ReactAndroid/src/androidTest/js/NativeIdTestModule.js
+++ b/ReactAndroid/src/androidTest/js/NativeIdTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -28,18 +29,16 @@ const View = require('View');
*/
class NativeIdTestApp extends React.Component<{}> {
render() {
- const uri = 'data:image/gif;base64,' +
- 'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
- 'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
- 'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
- 'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
- 'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7';
+ const uri =
+ 'data:image/gif;base64,' +
+ 'R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapy' +
+ 'uvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/' +
+ 'TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5' +
+ 'iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97V' +
+ 'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7';
return (
-
+
text
diff --git a/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js b/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js
index 237dacba2..97210eccb 100644
--- a/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js
+++ b/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -62,7 +63,7 @@ class PickerAndroidTestApp extends React.Component {
);
}
- onValueChange = (value) => {
+ onValueChange = value => {
this.setState({selected: value});
RecordingModule.recordSelection(value);
};
@@ -83,7 +84,7 @@ var PickerAndroidTestModule = {
BatchedBridge.registerCallableModule(
'PickerAndroidTestModule',
- PickerAndroidTestModule
+ PickerAndroidTestModule,
);
module.exports = PickerAndroidTestModule;
diff --git a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js
index a6e3849e0..e9b4b563b 100644
--- a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js
+++ b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -21,14 +22,14 @@ class ProgressBarSampleApp extends React.Component {
render() {
return (
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -44,7 +45,7 @@ var ProgressBarTestModule = {
BatchedBridge.registerCallableModule(
'ProgressBarTestModule',
- ProgressBarTestModule
+ ProgressBarTestModule,
);
module.exports = ProgressBarTestModule;
diff --git a/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js b/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js
index 7654f1060..f6f83beee 100644
--- a/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js
+++ b/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -47,15 +48,24 @@ var getInitialState = function() {
};
var onScroll = function(e) {
- ScrollListener.onScroll(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
+ ScrollListener.onScroll(
+ e.nativeEvent.contentOffset.x,
+ e.nativeEvent.contentOffset.y,
+ );
};
var onScrollBeginDrag = function(e) {
- ScrollListener.onScrollBeginDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
+ ScrollListener.onScrollBeginDrag(
+ e.nativeEvent.contentOffset.x,
+ e.nativeEvent.contentOffset.y,
+ );
};
var onScrollEndDrag = function(e) {
- ScrollListener.onScrollEndDrag(e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y);
+ ScrollListener.onScrollEndDrag(
+ e.nativeEvent.contentOffset.x,
+ e.nativeEvent.contentOffset.y,
+ );
};
var onItemPress = function(itemNumber) {
@@ -78,11 +88,17 @@ var ScrollViewTestApp = createReactClass({
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
+ key={index}
+ text={item.text}
+ onPress={this.onItemPress.bind(this, index)}
+ />
));
return (
-
+
{children}
);
@@ -103,8 +119,10 @@ var HorizontalScrollViewTestApp = createReactClass({
scrollViewApp = this;
var children = this.state.data.map((item, index) => (
+ key={index}
+ text={item.text}
+ onPress={this.onItemPress.bind(this, index)}
+ />
));
return (
@@ -136,7 +154,7 @@ var ScrollViewTestModule = {
BatchedBridge.registerCallableModule(
'ScrollViewTestModule',
- ScrollViewTestModule
+ ScrollViewTestModule,
);
module.exports = ScrollViewTestModule;
diff --git a/ReactAndroid/src/androidTest/js/ShareTestModule.js b/ReactAndroid/src/androidTest/js/ShareTestModule.js
index dd0f7fc96..3c230a3d0 100644
--- a/ReactAndroid/src/androidTest/js/ShareTestModule.js
+++ b/ReactAndroid/src/androidTest/js/ShareTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -16,7 +17,7 @@ var View = require('View');
class ShareTestApp extends React.Component {
render() {
- return ();
+ return ;
}
}
@@ -25,14 +26,11 @@ var ShareTestModule = {
showShareDialog: function(content, options) {
Share.share(content, options).then(
() => RecordingModule.recordOpened(),
- ({code, message}) => RecordingModule.recordError()
+ ({code, message}) => RecordingModule.recordError(),
);
},
};
-BatchedBridge.registerCallableModule(
- 'ShareTestModule',
- ShareTestModule
-);
+BatchedBridge.registerCallableModule('ShareTestModule', ShareTestModule);
module.exports = ShareTestModule;
diff --git a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js
index 859acfc92..9f19e0e39 100644
--- a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js
+++ b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -24,12 +25,30 @@ class ClippingSample1 extends React.Component {
var styles = sample1Styles;
return (
-
-
-
-
-
-
+
+
+
+
+
+
);
@@ -75,15 +94,30 @@ class ClippingSample2 extends React.Component {
var styles = sample2Styles;
return (
-
+
-
-
-
-
+ clippableViewID="complexInner"
+ style={styles.complexInner}
+ removeClippedSubviews={true}>
+
+
+
+
@@ -132,13 +166,19 @@ var sample2Styles = StyleSheet.create({
class UpdatingSample1 extends React.Component {
render() {
var styles = updating1Styles;
- var inner1Styles = [styles.inner1, {height: this.props.update1 ? 200 : 100}];
+ var inner1Styles = [
+ styles.inner1,
+ {height: this.props.update1 ? 200 : 100},
+ ];
var inner2Styles = [styles.inner2, {top: this.props.update2 ? 200 : 50}];
return (
-
-
-
+
+
+
);
@@ -166,7 +206,7 @@ var updating1Styles = StyleSheet.create({
left: 50,
top: 50,
backgroundColor: 'green',
- }
+ },
});
class UpdatingSample2 extends React.Component {
@@ -175,8 +215,11 @@ class UpdatingSample2 extends React.Component {
var outerStyles = [styles.outer, {height: this.props.update ? 200 : 100}];
return (
-
-
+
+
);
@@ -204,25 +247,28 @@ class ScrollViewTest extends React.Component {
var children = [];
for (var i = 0; i < 4; i++) {
children[i] = (
-
+
);
}
for (var i = 4; i < 6; i++) {
var viewID = 'C' + (i - 4);
children[i] = (
-
-
+ key={i}
+ style={styles.complex}
+ clippableViewID={viewID}
+ removeClippedSubviews={true}>
+
+
);
}
return (
-
+
{children}
);
@@ -258,7 +304,6 @@ var scrollTestStyles = StyleSheet.create({
},
});
-
var appInstance = null;
class SubviewsClippingTestApp extends React.Component {
@@ -268,42 +313,40 @@ class SubviewsClippingTestApp extends React.Component {
appInstance = this;
}
- setComponent = (component) => {
+ setComponent = component => {
this.setState({component: component});
};
render() {
var component = this.state.component;
- return (
-
- {component}
-
- );
+ return {component};
}
}
var SubviewsClippingTestModule = {
App: SubviewsClippingTestApp,
renderClippingSample1: function() {
- appInstance.setComponent();
+ appInstance.setComponent();
},
renderClippingSample2: function() {
- appInstance.setComponent();
+ appInstance.setComponent();
},
renderUpdatingSample1: function(update1, update2) {
- appInstance.setComponent();
+ appInstance.setComponent(
+ ,
+ );
},
renderUpdatingSample2: function(update) {
- appInstance.setComponent();
+ appInstance.setComponent();
},
renderScrollViewTest: function() {
- appInstance.setComponent();
+ appInstance.setComponent();
},
};
BatchedBridge.registerCallableModule(
'SubviewsClippingTestModule',
- SubviewsClippingTestModule
+ SubviewsClippingTestModule,
);
module.exports = SubviewsClippingTestModule;
diff --git a/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js b/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js
index 5a126772e..0bd3fabf2 100644
--- a/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js
+++ b/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js
@@ -4,13 +4,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
var BatchedBridge = require('BatchedBridge');
var React = require('React');
-var RecordingModule = require('NativeModules').SwipeRefreshLayoutRecordingModule;
+var RecordingModule = require('NativeModules')
+ .SwipeRefreshLayoutRecordingModule;
var ScrollView = require('ScrollView');
var RefreshControl = require('RefreshControl');
var Text = require('Text');
@@ -26,9 +28,7 @@ class Row extends React.Component {
return (
-
- {this.state.clicks + ' clicks'}
-
+ {this.state.clicks + ' clicks'}
);
@@ -77,12 +77,12 @@ var SwipeRefreshLayoutTestModule = {
if (app != null) {
app.setState({rows});
}
- }
+ },
};
BatchedBridge.registerCallableModule(
'SwipeRefreshLayoutTestModule',
- SwipeRefreshLayoutTestModule
+ SwipeRefreshLayoutTestModule,
);
module.exports = SwipeRefreshLayoutTestModule;
diff --git a/ReactAndroid/src/androidTest/js/TestBundle.js b/ReactAndroid/src/androidTest/js/TestBundle.js
index 64d2c57d2..59da7e669 100644
--- a/ReactAndroid/src/androidTest/js/TestBundle.js
+++ b/ReactAndroid/src/androidTest/js/TestBundle.js
@@ -4,7 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
+
'use strict';
// Disable YellowBox so we do not have to mock its dependencies
@@ -29,86 +31,88 @@ require('SwipeRefreshLayoutTestModule');
require('TextInputTestModule');
require('TimePickerDialogTestModule');
-
// Define catalyst test apps used in integration tests
var AppRegistry = require('AppRegistry');
var apps = [
-{
- appKey: 'CatalystRootViewTestApp',
- component: () => require('CatalystRootViewTestModule').CatalystRootViewTestApp
-},
-{
- appKey: 'DatePickerDialogTestApp',
- component: () => require('DatePickerDialogTestModule').DatePickerDialogTestApp
-},
-{
- appKey: 'JSResponderTestApp',
- component: () => require('JSResponderTestApp'),
-},
-{
- appKey: 'HorizontalScrollViewTestApp',
- component: () => require('ScrollViewTestModule').HorizontalScrollViewTestApp,
-},
-{
- appKey: 'InitialPropsTestApp',
- component: () => require('InitialPropsTestApp'),
-},
-{
- appKey: 'LayoutEventsTestApp',
- component: () => require('LayoutEventsTestApp'),
-},
-{
- appKey: 'MeasureLayoutTestApp',
- component: () => require('MeasureLayoutTestModule').MeasureLayoutTestApp
-},
-{
- appKey: 'MultitouchHandlingTestAppModule',
- component: () => require('MultitouchHandlingTestAppModule')
-},
-{
- appKey: 'NativeIdTestApp',
- component: () => require('NativeIdTestModule').NativeIdTestApp
-},
-{
- appKey: 'PickerAndroidTestApp',
- component: () => require('PickerAndroidTestModule').PickerAndroidTestApp,
-},
-{
- appKey: 'ScrollViewTestApp',
- component: () => require('ScrollViewTestModule').ScrollViewTestApp,
-},
-{
- appKey: 'ShareTestApp',
- component: () => require('ShareTestModule').ShareTestApp,
-},
-{
- appKey: 'SubviewsClippingTestApp',
- component: () => require('SubviewsClippingTestModule').App,
-},
-{
- appKey: 'SwipeRefreshLayoutTestApp',
- component: () => require('SwipeRefreshLayoutTestModule').SwipeRefreshLayoutTestApp
-},
-{
- appKey: 'TextInputTestApp',
- component: () => require('TextInputTestModule').TextInputTestApp
-},
-{
- appKey: 'TestIdTestApp',
- component: () => require('TestIdTestModule').TestIdTestApp
-},
-{
- appKey: 'TimePickerDialogTestApp',
- component: () => require('TimePickerDialogTestModule').TimePickerDialogTestApp
-},
-{
- appKey: 'TouchBubblingTestAppModule',
- component: () => require('TouchBubblingTestAppModule')
-},
-
+ {
+ appKey: 'CatalystRootViewTestApp',
+ component: () =>
+ require('CatalystRootViewTestModule').CatalystRootViewTestApp,
+ },
+ {
+ appKey: 'DatePickerDialogTestApp',
+ component: () =>
+ require('DatePickerDialogTestModule').DatePickerDialogTestApp,
+ },
+ {
+ appKey: 'JSResponderTestApp',
+ component: () => require('JSResponderTestApp'),
+ },
+ {
+ appKey: 'HorizontalScrollViewTestApp',
+ component: () =>
+ require('ScrollViewTestModule').HorizontalScrollViewTestApp,
+ },
+ {
+ appKey: 'InitialPropsTestApp',
+ component: () => require('InitialPropsTestApp'),
+ },
+ {
+ appKey: 'LayoutEventsTestApp',
+ component: () => require('LayoutEventsTestApp'),
+ },
+ {
+ appKey: 'MeasureLayoutTestApp',
+ component: () => require('MeasureLayoutTestModule').MeasureLayoutTestApp,
+ },
+ {
+ appKey: 'MultitouchHandlingTestAppModule',
+ component: () => require('MultitouchHandlingTestAppModule'),
+ },
+ {
+ appKey: 'NativeIdTestApp',
+ component: () => require('NativeIdTestModule').NativeIdTestApp,
+ },
+ {
+ appKey: 'PickerAndroidTestApp',
+ component: () => require('PickerAndroidTestModule').PickerAndroidTestApp,
+ },
+ {
+ appKey: 'ScrollViewTestApp',
+ component: () => require('ScrollViewTestModule').ScrollViewTestApp,
+ },
+ {
+ appKey: 'ShareTestApp',
+ component: () => require('ShareTestModule').ShareTestApp,
+ },
+ {
+ appKey: 'SubviewsClippingTestApp',
+ component: () => require('SubviewsClippingTestModule').App,
+ },
+ {
+ appKey: 'SwipeRefreshLayoutTestApp',
+ component: () =>
+ require('SwipeRefreshLayoutTestModule').SwipeRefreshLayoutTestApp,
+ },
+ {
+ appKey: 'TextInputTestApp',
+ component: () => require('TextInputTestModule').TextInputTestApp,
+ },
+ {
+ appKey: 'TestIdTestApp',
+ component: () => require('TestIdTestModule').TestIdTestApp,
+ },
+ {
+ appKey: 'TimePickerDialogTestApp',
+ component: () =>
+ require('TimePickerDialogTestModule').TimePickerDialogTestApp,
+ },
+ {
+ appKey: 'TouchBubblingTestAppModule',
+ component: () => require('TouchBubblingTestAppModule'),
+ },
];
-
module.exports = apps;
AppRegistry.registerConfig(apps);
diff --git a/ReactAndroid/src/androidTest/js/TestIdTestModule.js b/ReactAndroid/src/androidTest/js/TestIdTestModule.js
index 0320f3cf8..5b045d38f 100644
--- a/ReactAndroid/src/androidTest/js/TestIdTestModule.js
+++ b/ReactAndroid/src/androidTest/js/TestIdTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -30,16 +31,19 @@ class TestIdTestApp extends React.Component {
render() {
return (
-
+ 'riy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7',
+ }}
+ style={styles.base}
+ />
text
@@ -64,7 +68,6 @@ class TestIdTestApp extends React.Component {
-
);
}
diff --git a/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js b/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js
index a9aca7983..9a5915396 100644
--- a/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js
+++ b/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -20,9 +21,6 @@ var TestJSLocaleModule = {
},
};
-BatchedBridge.registerCallableModule(
- 'TestJSLocaleModule',
- TestJSLocaleModule
-);
+BatchedBridge.registerCallableModule('TestJSLocaleModule', TestJSLocaleModule);
module.exports = TestJSLocaleModule;
diff --git a/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js b/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js
index 5e5527846..ec31e15cb 100644
--- a/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js
+++ b/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -49,9 +50,9 @@ var TestJSToJavaParametersModule = {
},
returnMapWithArrays: function() {
Recording.receiveMap({
- 'empty': [],
- 'ints': [43, 44],
- 'mixed': [77, 'string', ['another', 'array']],
+ empty: [],
+ ints: [43, 44],
+ mixed: [77, 'string', ['another', 'array']],
});
},
returnArrayWithStringDoubleIntMapArrayBooleanNull: function() {
@@ -65,7 +66,7 @@ var TestJSToJavaParametersModule = {
int: -55,
array: [],
boolean: true,
- null: null
+ null: null,
});
},
returnArrayWithLargeInts: function() {
@@ -80,7 +81,7 @@ var TestJSToJavaParametersModule = {
b: 41,
c: 'string',
d: 'other string',
- e: [1,'foo','bar'],
+ e: [1, 'foo', 'bar'],
f: null,
});
},
@@ -99,7 +100,8 @@ var TestJSToJavaParametersModule = {
'two-bytes': '\u00A2',
'three-bytes': '\u20AC',
'four-bytes': '\uD83D\uDE1C',
- 'mixed': '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107'
+ mixed:
+ '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
});
},
returnArrayWithMultibyteUTF8CharacterString: function() {
@@ -108,14 +110,14 @@ var TestJSToJavaParametersModule = {
'\u00A2',
'\u20AC',
'\uD83D\uDE1C',
- '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107'
+ '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
]);
},
};
BatchedBridge.registerCallableModule(
'TestJSToJavaParametersModule',
- TestJSToJavaParametersModule
+ TestJSToJavaParametersModule,
);
module.exports = TestJSToJavaParametersModule;
diff --git a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js
index 6e7106166..d112ff213 100644
--- a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js
+++ b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -24,9 +25,7 @@ function strictStringCompare(a, b) {
}
function assertStrictStringEquals(a, b) {
- assertTrue(
- strictStringCompare(a,b),
- 'Expected: ' + a + ', received: ' + b);
+ assertTrue(strictStringCompare(a, b), 'Expected: ' + a + ', received: ' + b);
}
var TestJavaToJSArgumentsModule = {
@@ -92,7 +91,8 @@ var TestJavaToJSArgumentsModule = {
assertStrictStringEquals('\uD83D\uDE1C', map['four-bytes']);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
- map.mixed);
+ map.mixed,
+ );
},
receiveArrayWithMultibyteUTF8CharacterString: function(array) {
assertTrue(true);
@@ -101,13 +101,14 @@ var TestJavaToJSArgumentsModule = {
assertStrictStringEquals('\uD83D\uDE1C', array[2]);
assertStrictStringEquals(
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
- array[3]);
+ array[3],
+ );
},
};
BatchedBridge.registerCallableModule(
'TestJavaToJSArgumentsModule',
- TestJavaToJSArgumentsModule
+ TestJavaToJSArgumentsModule,
);
module.exports = TestJavaToJSArgumentsModule;
diff --git a/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js b/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js
index 1aa72f0b8..e21f8600c 100644
--- a/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js
+++ b/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -26,12 +27,12 @@ var TestJavaToJSReturnValuesModule = {
} catch (ex) {
assertTrue(ex.message.indexOf('Exception triggered') !== -1);
}
- }
+ },
};
BatchedBridge.registerCallableModule(
'TestJavaToJSReturnValuesModule',
- TestJavaToJSReturnValuesModule
+ TestJavaToJSReturnValuesModule,
);
module.exports = TestJavaToJSReturnValuesModule;
diff --git a/ReactAndroid/src/androidTest/js/TextInputTestModule.js b/ReactAndroid/src/androidTest/js/TextInputTestModule.js
index fff1fc5bc..48d29344d 100644
--- a/ReactAndroid/src/androidTest/js/TextInputTestModule.js
+++ b/ReactAndroid/src/androidTest/js/TextInputTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -25,13 +26,14 @@ class TokenizedTextExample extends React.Component {
this.state = {text: ''};
}
render() {
-
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
- let token, index, parts = [];
+ let token,
+ index,
+ parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
@@ -50,9 +52,13 @@ class TokenizedTextExample extends React.Component {
parts.push(_text);
//highlight hashtags
- parts = parts.map((text) => {
+ parts = parts.map(text => {
if (/^#/.test(text)) {
- return {text};
+ return (
+
+ {text}
+
+ );
} else {
return text;
}
@@ -65,7 +71,7 @@ class TokenizedTextExample extends React.Component {
testID="tokenizedInput"
multiline={true}
style={styles.multiline}
- onChangeText={(text) => {
+ onChangeText={text => {
this.setState({text});
}}>
{parts}
@@ -80,7 +86,7 @@ class TextInputTestApp extends React.Component {
app = this;
}
- handleOnSubmitEditing = (record) => {
+ handleOnSubmitEditing = record => {
Recording.record(record);
};
@@ -173,7 +179,7 @@ var TextInputTestModule = {
BatchedBridge.registerCallableModule(
'TextInputTestModule',
- TextInputTestModule
+ TextInputTestModule,
);
module.exports = TextInputTestModule;
diff --git a/ReactAndroid/src/androidTest/js/TimePickerDialogTestModule.js b/ReactAndroid/src/androidTest/js/TimePickerDialogTestModule.js
index 80e355c95..5db19b67e 100644
--- a/ReactAndroid/src/androidTest/js/TimePickerDialogTestModule.js
+++ b/ReactAndroid/src/androidTest/js/TimePickerDialogTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -31,14 +32,14 @@ var TimePickerDialogTestModule = {
RecordingModule.recordDismissed();
}
},
- ({code, message}) => RecordingModule.recordError()
+ ({code, message}) => RecordingModule.recordError(),
);
},
};
BatchedBridge.registerCallableModule(
'TimePickerDialogTestModule',
- TimePickerDialogTestModule
+ TimePickerDialogTestModule,
);
module.exports = TimePickerDialogTestModule;
diff --git a/ReactAndroid/src/androidTest/js/TouchBubblingTestAppModule.js b/ReactAndroid/src/androidTest/js/TouchBubblingTestAppModule.js
index 6f8e6226a..4ae71bf70 100644
--- a/ReactAndroid/src/androidTest/js/TouchBubblingTestAppModule.js
+++ b/ReactAndroid/src/androidTest/js/TouchBubblingTestAppModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -16,16 +17,20 @@ var View = require('View');
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
class TouchBubblingTestApp extends React.Component {
- handlePress = (record) => {
+ handlePress = record => {
Recording.record(record);
};
render() {
return (
-
+
-
+
@@ -33,7 +38,9 @@ class TouchBubblingTestApp extends React.Component {
-
+
@@ -68,7 +75,7 @@ var styles = StyleSheet.create({
backgroundColor: '#eeeeee',
height: 20,
width: 20,
- }
+ },
});
module.exports = TouchBubblingTestApp;
diff --git a/ReactAndroid/src/androidTest/js/UIManagerTestModule.js b/ReactAndroid/src/androidTest/js/UIManagerTestModule.js
index 93f73d44c..33d1d3aca 100644
--- a/ReactAndroid/src/androidTest/js/UIManagerTestModule.js
+++ b/ReactAndroid/src/androidTest/js/UIManagerTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -34,16 +35,25 @@ var FlexTestApp = createReactClass({
left: 10,
width: 50,
height: 60,
- }
+ },
}),
render: function() {
return (
-
-
-
+
+
+
);
- }
+ },
});
var FlexWithText = createReactClass({
@@ -65,14 +75,17 @@ var FlexWithText = createReactClass({
}),
render: function() {
return (
-
+
Hello
World
);
- }
+ },
});
var AbsolutePositionTestApp = createReactClass({
@@ -84,11 +97,17 @@ var AbsolutePositionTestApp = createReactClass({
left: 10,
width: 50,
height: 60,
- }
+ },
}),
render: function() {
- return ;
- }
+ return (
+
+ );
+ },
});
var AbsolutePositionBottomRightTestApp = createReactClass({
@@ -104,15 +123,18 @@ var AbsolutePositionBottomRightTestApp = createReactClass({
right: 10,
width: 50,
height: 60,
- }
+ },
}),
render: function() {
return (
-
-
+
+
);
- }
+ },
});
var CenteredTextView = createReactClass({
@@ -134,11 +156,13 @@ var CenteredTextView = createReactClass({
return (
- {this.props.text}
+
+ {this.props.text}
+
);
- }
+ },
});
var flushUpdatePositionInList = null;
@@ -150,11 +174,11 @@ var UpdatePositionInListTestApp = createReactClass({
},
active: {
height: 50,
- }
+ },
}),
getInitialState: function() {
- flushUpdatePositionInList = () => this.setState({ active: true });
- return { active: false };
+ flushUpdatePositionInList = () => this.setState({active: true});
+ return {active: false};
},
render: function() {
return (
@@ -167,10 +191,10 @@ var UpdatePositionInListTestApp = createReactClass({
]}
collapsable={false}
/>
-
+
);
- }
+ },
});
var UIManagerTestModule = {
@@ -194,12 +218,12 @@ var UIManagerTestModule = {
},
flushUpdatePositionInList: function() {
flushUpdatePositionInList();
- }
+ },
};
BatchedBridge.registerCallableModule(
'UIManagerTestModule',
- UIManagerTestModule
+ UIManagerTestModule,
);
module.exports = UIManagerTestModule;
diff --git a/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js b/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js
index 0ddaa86f0..c2215318a 100644
--- a/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js
+++ b/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
@@ -26,9 +27,7 @@ class ViewSampleApp extends React.Component {
state = {};
render() {
- return (
-
- );
+ return ;
}
}
@@ -40,7 +39,10 @@ class MarginSampleApp extends React.Component {
render() {
updateMargins = this.setState.bind(this, {margin: 15});
return (
-
+
);
}
}
@@ -48,8 +50,13 @@ class MarginSampleApp extends React.Component {
class BorderSampleApp extends React.Component {
render() {
return (
-
-
+
+
);
}
@@ -64,11 +71,9 @@ class TransformSampleApp extends React.Component {
{rotate: '15deg'},
{scaleX: 5},
{scaleY: 10},
- ]
+ ],
};
- return (
-
- );
+ return ;
}
}
@@ -92,7 +97,7 @@ var ViewRenderingTestModule = {
BatchedBridge.registerCallableModule(
'ViewRenderingTestModule',
- ViewRenderingTestModule
+ ViewRenderingTestModule,
);
module.exports = ViewRenderingTestModule;
diff --git a/babel-preset/index.js b/babel-preset/index.js
index aaff5ba9f..2209567af 100644
--- a/babel-preset/index.js
+++ b/babel-preset/index.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
module.exports = require('./configs/main');
diff --git a/babel-preset/transforms/transform-symbol-member.js b/babel-preset/transforms/transform-symbol-member.js
index fd5333d1f..3cf5f5faf 100644
--- a/babel-preset/transforms/transform-symbol-member.js
+++ b/babel-preset/transforms/transform-symbol-member.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
'use strict';
@@ -37,16 +39,12 @@ module.exports = function symbolMember(babel) {
t.conditionalExpression(
t.binaryExpression(
'===',
- t.unaryExpression(
- 'typeof',
- t.identifier('Symbol'),
- true
- ),
- t.stringLiteral('function')
+ t.unaryExpression('typeof', t.identifier('Symbol'), true),
+ t.stringLiteral('function'),
),
node,
- t.stringLiteral(`@@${node.property.name}`)
- )
+ t.stringLiteral(`@@${node.property.name}`),
+ ),
);
// We should stop to avoid infinite recursion, since Babel
@@ -60,8 +58,10 @@ module.exports = function symbolMember(babel) {
function isAppropriateMember(path) {
let node = path.node;
- return path.parentPath.type !== 'AssignmentExpression' &&
+ return (
+ path.parentPath.type !== 'AssignmentExpression' &&
node.object.type === 'Identifier' &&
node.object.name === 'Symbol' &&
- node.property.type === 'Identifier';
+ node.property.type === 'Identifier'
+ );
}
diff --git a/bots/code-analysis-bot.js b/bots/code-analysis-bot.js
index 4ab9af077..d39120e53 100644
--- a/bots/code-analysis-bot.js
+++ b/bots/code-analysis-bot.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
if (!process.env.CI_USER) {
@@ -15,7 +18,9 @@ if (!process.env.CI_REPO) {
process.exit(1);
}
if (!process.env.GITHUB_TOKEN) {
- console.error('Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e');
+ console.error(
+ 'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e',
+ );
process.exit(1);
}
if (!process.env.PULL_REQUEST_NUMBER) {
@@ -90,7 +95,7 @@ var converters = {
});
});
});
- }
+ },
};
function getShaFromPullRequest(user, repo, number, callback) {
@@ -118,7 +123,6 @@ function getFilesFromCommit(user, repo, sha, callback) {
});
}
-
/**
* Sadly we can't just give the line number to github, we have to give the
* line number relative to the patch file which is super annoying. This
@@ -130,7 +134,7 @@ function getLineMapFromPatch(patchString) {
var fileLineIndex = 0;
var lineMap = {};
- patchString.split('\n').forEach((line) => {
+ patchString.split('\n').forEach(line => {
if (line.match(/^@@/)) {
fileLineIndex = line.match(/\+([0-9]+)/)[1] - 1;
return;
@@ -179,27 +183,27 @@ function main(messages, user, repo, number) {
return;
}
- getShaFromPullRequest(user, repo, number, (sha) => {
- getFilesFromCommit(user, repo, sha, (files) => {
- files
- .filter((file) => messages[file.filename])
- .forEach((file) => {
- // github api sometimes does not return a patch on large commits
- if (!file.patch) {
- return;
- }
- var lineMap = getLineMapFromPatch(file.patch);
- messages[file.filename].forEach((message) => {
- sendComment(user, repo, number, sha, file.filename, lineMap, message);
- });
+ getShaFromPullRequest(user, repo, number, sha => {
+ getFilesFromCommit(user, repo, sha, files => {
+ files.filter(file => messages[file.filename]).forEach(file => {
+ // github api sometimes does not return a patch on large commits
+ if (!file.patch) {
+ return;
+ }
+ var lineMap = getLineMapFromPatch(file.patch);
+ messages[file.filename].forEach(message => {
+ sendComment(user, repo, number, sha, file.filename, lineMap, message);
});
+ });
});
});
}
var content = '';
process.stdin.resume();
-process.stdin.on('data', function(buf) { content += buf.toString(); });
+process.stdin.on('data', function(buf) {
+ content += buf.toString();
+});
process.stdin.on('end', function() {
var messages = {};
diff --git a/bots/dangerfile.js b/bots/dangerfile.js
index 3380e718f..de7c07416 100644
--- a/bots/dangerfile.js
+++ b/bots/dangerfile.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
'use strict';
@@ -11,7 +13,7 @@ const fs = require('fs');
const includes = require('lodash.includes');
const minimatch = require('minimatch');
-const { danger, fail, markdown, message, warn } = require('danger');
+const {danger, fail, markdown, message, warn} = require('danger');
// Fails if the description is too short.
if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
@@ -22,13 +24,16 @@ if (!danger.github.pr.body || danger.github.pr.body.length < 10) {
const packageChanged = includes(danger.git.modified_files, 'package.json');
if (packageChanged) {
const title = ':lock: package.json';
- const idea = 'Changes were made to package.json. ' +
+ const idea =
+ 'Changes were made to package.json. ' +
'This will require a manual import by a Facebook employee.';
warn(`${title} - ${idea}`);
}
// Warns if a test plan is missing.
-const includesTestPlan = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('test plan');
+const includesTestPlan =
+ danger.github.pr.body &&
+ danger.github.pr.body.toLowerCase().includes('test plan');
if (!includesTestPlan) {
const title = ':clipboard: Test Plan';
const idea = 'This PR appears to be missing a Test Plan.';
@@ -36,9 +41,13 @@ if (!includesTestPlan) {
}
// Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups
-const releaseNotesRegex = /\[\s?(ANDROID|CLI|DOCS|GENERAL|INTERNAL|IOS|TVOS|WINDOWS)\s?\]\s*?\[\s?(BREAKING|BUGFIX|ENHANCEMENT|FEATURE|MINOR)\s?\]\s*?\[(.*)\]\s*?\-\s*?(.*)/ig;
-const includesReleaseNotes = danger.github.pr.body && danger.github.pr.body.toLowerCase().includes('release notes');
-const correctlyFormattedReleaseNotes = releaseNotesRegex.test(danger.github.pr.body);
+const releaseNotesRegex = /\[\s?(ANDROID|CLI|DOCS|GENERAL|INTERNAL|IOS|TVOS|WINDOWS)\s?\]\s*?\[\s?(BREAKING|BUGFIX|ENHANCEMENT|FEATURE|MINOR)\s?\]\s*?\[(.*)\]\s*?\-\s*?(.*)/gi;
+const includesReleaseNotes =
+ danger.github.pr.body &&
+ danger.github.pr.body.toLowerCase().includes('release notes');
+const correctlyFormattedReleaseNotes = releaseNotesRegex.test(
+ danger.github.pr.body,
+);
if (!includesReleaseNotes) {
const title = ':clipboard: Release Notes';
@@ -54,11 +63,20 @@ if (!includesReleaseNotes) {
var bigPRThreshold = 600;
if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) {
const title = ':exclamation: Big PR';
- const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger.github.pr.additions + danger.github.pr.deletions} lines.`;
+ const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger
+ .github.pr.additions + danger.github.pr.deletions} lines.`;
warn(`${title} - ${idea}`);
-} else if (danger.git.modified_files + danger.git.added_files + danger.git.deleted_files > bigPRThreshold) {
+} else if (
+ danger.git.modified_files +
+ danger.git.added_files +
+ danger.git.deleted_files >
+ bigPRThreshold
+) {
const title = ':exclamation: Big PR';
- const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger.git.modified_files + danger.git.added_files + danger.git.deleted_files} files.`;
+ const idea = `This PR is extremely unlikely to get reviewed because it touches ${danger
+ .git.modified_files +
+ danger.git.added_files +
+ danger.git.deleted_files} files.`;
warn(`${title} - ${idea}`);
}
@@ -68,10 +86,12 @@ const isMergeRefMaster = danger.github.pr.base.ref === 'master';
const isMergeRefStable = danger.github.pr.base.ref.indexOf('-stable') !== -1;
if (!isMergeRefMaster && isMergeRefStable) {
const title = ':grey_question: Base Branch';
- const idea = 'The base branch for this PR is something other than `master`. Are you sure you want to merge these changes into a stable release? If you are interested in backporting updates to an older release, the suggested approach is to land those changes on `master` first and then cherry-pick the commits into the branch for that release. The [Releases Guide](https://github.com/facebook/react-native/blob/master/Releases.md) has more information.';
+ const idea =
+ 'The base branch for this PR is something other than `master`. Are you sure you want to merge these changes into a stable release? If you are interested in backporting updates to an older release, the suggested approach is to land those changes on `master` first and then cherry-pick the commits into the branch for that release. The [Releases Guide](https://github.com/facebook/react-native/blob/master/Releases.md) has more information.';
warn(`${title} - ${idea}`);
} else if (!isMergeRefMaster && !isMergeRefStable) {
const title = ':exclamation: Base Branch';
- const idea = 'The base branch for this PR is something other than `master`. [Are you sure you want to target something other than the `master` branch?](http://facebook.github.io/react-native/docs/contributing.html#pull-requests)';
+ const idea =
+ 'The base branch for this PR is something other than `master`. [Are you sure you want to target something other than the `master` branch?](http://facebook.github.io/react-native/docs/contributing.html#pull-requests)';
fail(`${title} - ${idea}`);
}
diff --git a/cli.js b/cli.js
index 272a78dfc..a57a0a686 100644
--- a/cli.js
+++ b/cli.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
module.exports = require('./local-cli/cli.js');
diff --git a/flow/create-react-class.js b/flow/create-react-class.js
index 571653b18..dc3fea97e 100644
--- a/flow/create-react-class.js
+++ b/flow/create-react-class.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
* @nolint
*/
diff --git a/jest/assetFileTransformer.js b/jest/assetFileTransformer.js
index e3a318aed..da6cf34a0 100644
--- a/jest/assetFileTransformer.js
+++ b/jest/assetFileTransformer.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
/* eslint-env node */
diff --git a/jest/hasteImpl.js b/jest/hasteImpl.js
index ec838a1d4..568f7e8df 100644
--- a/jest/hasteImpl.js
+++ b/jest/hasteImpl.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -13,20 +14,20 @@ const path = require('path');
const ROOT = path.join(__dirname, '..');
-const BLACKLISTED_PATTERNS/*: Array*/ = [
+const BLACKLISTED_PATTERNS /*: Array */ = [
/.*\/__(mocks|tests)__\/.*/,
/^Libraries\/Animated\/src\/polyfills\/.*/,
/^Libraries\/Renderer\/fb\/.*/,
];
-const WHITELISTED_PREFIXES/*: Array*/ = [
+const WHITELISTED_PREFIXES /*: Array */ = [
'IntegrationTests',
'Libraries',
'ReactAndroid',
'RNTester',
];
-const NAME_REDUCERS/*: Array<[RegExp, string]>*/ = [
+const NAME_REDUCERS /*: Array<[RegExp, string]> */ = [
// extract basename
[/^(?:.*\/)?([a-zA-Z0-9$_.-]+)$/, '$1'],
// strip .js/.js.flow suffix
@@ -41,23 +42,23 @@ const haste = {
* filePath is not a haste module
*/
getHasteName(
- filePath/*: string*/,
- sourceCode/* : ?string*/
- )/*: (string | void)*/ {
+ filePath /*: string */,
+ sourceCode /*: ?string */,
+ ) /*: string | void */ {
if (!isHastePath(filePath)) {
return undefined;
}
const hasteName = NAME_REDUCERS.reduce(
(name, [pattern, replacement]) => name.replace(pattern, replacement),
- filePath
+ filePath,
);
return hasteName;
},
};
-function isHastePath(filePath/*: string*/)/*: bool*/ {
+function isHastePath(filePath /*: string */) /*: boolean */ {
if (!filePath.endsWith('.js') && !filePath.endsWith('.js.flow')) {
return false;
}
diff --git a/jest/preprocessor.js b/jest/preprocessor.js
index 6d9e60de6..a2854943d 100644
--- a/jest/preprocessor.js
+++ b/jest/preprocessor.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
@@ -22,10 +23,12 @@ const babelRegisterOnly = require('metro-babel-register');
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
const generate = require('@babel/generator').default;
-const nodeFiles = RegExp([
- '/local-cli/',
- '/metro(?:-[^\/]*)?/', // metro, metro-core, metro-source-map, metro-etc
-].join('|'));
+const nodeFiles = RegExp(
+ [
+ '/local-cli/',
+ '/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc
+ ].join('|'),
+);
const nodeOptions = babelRegisterOnly.config([nodeFiles]);
babelRegisterOnly([]);
@@ -33,11 +36,12 @@ babelRegisterOnly([]);
/* $FlowFixMe(site=react_native_oss) */
const transformer = require('metro/src/transformer.js');
module.exports = {
- process(src/*: string*/, file/*: string*/) {
- if (nodeFiles.test(file)) { // node specific transforms only
+ process(src /*: string */, file /*: string */) {
+ if (nodeFiles.test(file)) {
+ // node specific transforms only
return babelTransformSync(
src,
- Object.assign({filename: file}, nodeOptions)
+ Object.assign({filename: file}, nodeOptions),
).code;
}
@@ -96,15 +100,19 @@ module.exports = {
],
});
- return generate(ast, {
- code: true,
- comments: false,
- compact: false,
- filename: file,
- retainLines: true,
- sourceFileName: file,
- sourceMaps: true,
- }, src).code;
+ return generate(
+ ast,
+ {
+ code: true,
+ comments: false,
+ compact: false,
+ filename: file,
+ retainLines: true,
+ sourceFileName: file,
+ sourceMaps: true,
+ },
+ src,
+ ).code;
},
getCacheKey: createCacheKeyFunction([
diff --git a/jest/setup.js b/jest/setup.js
index 18cb7dfbd..1cb1eddfa 100644
--- a/jest/setup.js
+++ b/jest/setup.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
const MockNativeMethods = require.requireActual('./MockNativeMethods');
@@ -16,7 +19,9 @@ require.requireActual('../Libraries/polyfills/error-guard');
global.__DEV__ = true;
global.Promise = require.requireActual('promise');
-global.regeneratorRuntime = require.requireActual('regenerator-runtime/runtime');
+global.regeneratorRuntime = require.requireActual(
+ 'regenerator-runtime/runtime',
+);
global.requestAnimationFrame = function(callback) {
return setTimeout(callback, 0);
@@ -25,9 +30,7 @@ global.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
-jest
- .mock('setupDevtools')
- .mock('npmlog');
+jest.mock('setupDevtools').mock('npmlog');
// there's a __mock__ for it.
jest.setMock('ErrorUtils', require('ErrorUtils'));
@@ -41,10 +44,7 @@ jest
.mock('View', () => mockComponent('View', MockNativeMethods))
.mock('RefreshControl', () => require.requireMock('RefreshControlMock'))
.mock('ScrollView', () => require.requireMock('ScrollViewMock'))
- .mock(
- 'ActivityIndicator',
- () => mockComponent('ActivityIndicator'),
- )
+ .mock('ActivityIndicator', () => mockComponent('ActivityIndicator'))
.mock('ListView', () => require.requireMock('ListViewMock'))
.mock('ListViewDataSource', () => {
const DataSource = require.requireActual('ListViewDataSource');
@@ -54,9 +54,9 @@ jest
// Ensure this doesn't throw.
try {
Object.keys(dataBlob).forEach(key => {
- this.items += dataBlob[key] && (
- dataBlob[key].length || dataBlob[key].size || 0
- );
+ this.items +=
+ dataBlob[key] &&
+ (dataBlob[key].length || dataBlob[key].size || 0);
});
} catch (e) {
this.items = 'unknown';
@@ -68,7 +68,9 @@ jest
return DataSource;
})
.mock('AnimatedImplementation', () => {
- const AnimatedImplementation = require.requireActual('AnimatedImplementation');
+ const AnimatedImplementation = require.requireActual(
+ 'AnimatedImplementation',
+ );
const oldCreate = AnimatedImplementation.createAnimatedComponent;
AnimatedImplementation.createAnimatedComponent = function(Component) {
const Wrapped = oldCreate(Component);
@@ -80,7 +82,8 @@ jest
.mock('ReactNative', () => {
const ReactNative = require.requireActual('ReactNative');
const NativeMethodsMixin =
- ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.NativeMethodsMixin;
+ ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
+ .NativeMethodsMixin;
Object.assign(NativeMethodsMixin, MockNativeMethods);
Object.assign(ReactNative.NativeComponent.prototype, MockNativeMethods);
@@ -99,10 +102,18 @@ const mockNativeModules = {
removeEventListener: jest.fn(),
},
AsyncLocalStorage: {
- multiGet: jest.fn((keys, callback) => process.nextTick(() => callback(null, []))),
- multiSet: jest.fn((entries, callback) => process.nextTick(() => callback(null))),
- multiRemove: jest.fn((keys, callback) => process.nextTick(() => callback(null))),
- multiMerge: jest.fn((entries, callback) => process.nextTick(() => callback(null))),
+ multiGet: jest.fn((keys, callback) =>
+ process.nextTick(() => callback(null, [])),
+ ),
+ multiSet: jest.fn((entries, callback) =>
+ process.nextTick(() => callback(null)),
+ ),
+ multiRemove: jest.fn((keys, callback) =>
+ process.nextTick(() => callback(null)),
+ ),
+ multiMerge: jest.fn((entries, callback) =>
+ process.nextTick(() => callback(null)),
+ ),
clear: jest.fn(callback => process.nextTick(() => callback(null))),
getAllKeys: jest.fn(callback => process.nextTick(() => callback(null, []))),
},
@@ -149,14 +160,12 @@ const mockNativeModules = {
}),
},
ImageLoader: {
- getSize: jest.fn(
- (url) => Promise.resolve({width: 320, height: 240})
- ),
+ getSize: jest.fn(url => Promise.resolve({width: 320, height: 240})),
prefetchImage: jest.fn(),
},
ImageViewManager: {
- getSize: jest.fn(
- (uri, success) => process.nextTick(() => success(320, 240))
+ getSize: jest.fn((uri, success) =>
+ process.nextTick(() => success(320, 240)),
),
prefetchImage: jest.fn(),
},
@@ -166,13 +175,9 @@ const mockNativeModules = {
},
Linking: {
openURL: jest.fn(),
- canOpenURL: jest.fn(
- () => Promise.resolve(true)
- ),
+ canOpenURL: jest.fn(() => Promise.resolve(true)),
addEventListener: jest.fn(),
- getInitialURL: jest.fn(
- () => Promise.resolve()
- ),
+ getInitialURL: jest.fn(() => Promise.resolve()),
removeEventListener: jest.fn(),
},
LocationObserver: {
@@ -182,24 +187,16 @@ const mockNativeModules = {
},
ModalFullscreenViewManager: {},
NetInfo: {
- fetch: jest.fn(
- () => Promise.resolve()
- ),
- getConnectionInfo: jest.fn(
- () => Promise.resolve()
- ),
+ fetch: jest.fn(() => Promise.resolve()),
+ getConnectionInfo: jest.fn(() => Promise.resolve()),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
isConnected: {
- fetch: jest.fn(
- () => Promise.resolve()
- ),
+ fetch: jest.fn(() => Promise.resolve()),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
- isConnectionExpensive: jest.fn(
- () => Promise.resolve()
- ),
+ isConnectionExpensive: jest.fn(() => Promise.resolve()),
},
Networking: {
sendRequest: jest.fn(),
@@ -215,12 +212,20 @@ const mockNativeModules = {
getDeliveredNotifications: jest.fn(callback => process.nextTick(() => [])),
removeDeliveredNotifications: jest.fn(),
setApplicationIconBadgeNumber: jest.fn(),
- getApplicationIconBadgeNumber: jest.fn(callback => process.nextTick(() => callback(0))),
+ getApplicationIconBadgeNumber: jest.fn(callback =>
+ process.nextTick(() => callback(0)),
+ ),
cancelLocalNotifications: jest.fn(),
- getScheduledLocalNotifications: jest.fn(callback => process.nextTick(() => callback())),
- requestPermissions: jest.fn(() => Promise.resolve({alert: true, badge: true, sound: true})),
+ getScheduledLocalNotifications: jest.fn(callback =>
+ process.nextTick(() => callback()),
+ ),
+ requestPermissions: jest.fn(() =>
+ Promise.resolve({alert: true, badge: true, sound: true}),
+ ),
abandonPermissions: jest.fn(),
- checkPermissions: jest.fn(callback => process.nextTick(() => callback({alert: true, badge: true, sound: true}))),
+ checkPermissions: jest.fn(callback =>
+ process.nextTick(() => callback({alert: true, badge: true, sound: true})),
+ ),
getInitialNotification: jest.fn(() => Promise.resolve(null)),
addListener: jest.fn(),
removeListeners: jest.fn(),
@@ -300,19 +305,15 @@ Object.keys(mockNativeModules).forEach(module => {
}
});
-jest
- .doMock('NativeModules', () => mockNativeModules);
+jest.doMock('NativeModules', () => mockNativeModules);
jest.doMock('requireNativeComponent', () => {
const React = require('react');
- return viewName => class extends React.Component {
- render() {
- return React.createElement(
- viewName,
- this.props,
- this.props.children,
- );
- }
- };
+ return viewName =>
+ class extends React.Component {
+ render() {
+ return React.createElement(viewName, this.props, this.props.children);
+ }
+ };
});
diff --git a/lib/InitializeJavaScriptAppEngine.js b/lib/InitializeJavaScriptAppEngine.js
index 6709e0a27..5048f860e 100644
--- a/lib/InitializeJavaScriptAppEngine.js
+++ b/lib/InitializeJavaScriptAppEngine.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/RCTEventEmitter.js b/lib/RCTEventEmitter.js
index 8968fb864..c225257d1 100644
--- a/lib/RCTEventEmitter.js
+++ b/lib/RCTEventEmitter.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/TextInputState.js b/lib/TextInputState.js
index 37738ceb6..5345311a5 100644
--- a/lib/TextInputState.js
+++ b/lib/TextInputState.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/UIManager.js b/lib/UIManager.js
index 6bd741903..b846967b6 100644
--- a/lib/UIManager.js
+++ b/lib/UIManager.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/UIManagerStatTracker.js b/lib/UIManagerStatTracker.js
index 9300a7c6f..c62aebdf0 100644
--- a/lib/UIManagerStatTracker.js
+++ b/lib/UIManagerStatTracker.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/View.js b/lib/View.js
index 6e3f20a85..852e74125 100644
--- a/lib/View.js
+++ b/lib/View.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/deepDiffer.js b/lib/deepDiffer.js
index ad3d3cb05..6254047d4 100644
--- a/lib/deepDiffer.js
+++ b/lib/deepDiffer.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/deepFreezeAndThrowOnMutationInDev.js b/lib/deepFreezeAndThrowOnMutationInDev.js
index 92d9f8f40..6691d2a64 100644
--- a/lib/deepFreezeAndThrowOnMutationInDev.js
+++ b/lib/deepFreezeAndThrowOnMutationInDev.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/lib/flattenStyle.js b/lib/flattenStyle.js
index 3c5651fdc..1c7256c7f 100644
--- a/lib/flattenStyle.js
+++ b/lib/flattenStyle.js
@@ -4,8 +4,10 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
* @flow
*/
+
'use strict';
// This is a forwarding module to allow React to require React Native internals
diff --git a/react-native-git-upgrade/checks.js b/react-native-git-upgrade/checks.js
index 1660addd0..88be3ac07 100644
--- a/react-native-git-upgrade/checks.js
+++ b/react-native-git-upgrade/checks.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
const {execSync} = require('child_process');
@@ -12,7 +15,7 @@ const semver = require('semver');
function checkDeclaredVersion(declaredVersion) {
if (!declaredVersion) {
throw new Error(
- 'Your "package.json" file doesn\'t seem to have "react-native" as a dependency.'
+ 'Your "package.json" file doesn\'t seem to have "react-native" as a dependency.',
);
}
}
@@ -20,11 +23,15 @@ function checkDeclaredVersion(declaredVersion) {
function checkMatchingVersions(currentVersion, declaredVersion, useYarn) {
if (!semver.satisfies(currentVersion, declaredVersion)) {
throw new Error(
- 'react-native version in "package.json" (' + declaredVersion + ') doesn\'t match ' +
- 'the installed version in "node_modules" (' + currentVersion + ').\n' +
- (useYarn ?
- 'Try running "yarn" to fix this.' :
- 'Try running "npm install" to fix this.')
+ 'react-native version in "package.json" (' +
+ declaredVersion +
+ ") doesn't match " +
+ 'the installed version in "node_modules" (' +
+ currentVersion +
+ ').\n' +
+ (useYarn
+ ? 'Try running "yarn" to fix this.'
+ : 'Try running "npm install" to fix this.'),
);
}
}
@@ -33,10 +40,10 @@ function checkReactPeerDependency(currentVersion, declaredReactVersion) {
if (semver.lt(currentVersion, '0.21.0') && !declaredReactVersion) {
throw new Error(
'Your "package.json" file doesn\'t seem to have "react" as a dependency.\n' +
- '"react" was changed from a dependency to a peer dependency in react-native v0.21.0.\n' +
- 'Therefore, it\'s necessary to include "react" in your project\'s dependencies.\n' +
- 'Please run "npm install --save react", then re-run ' +
- '"react-native upgrade".'
+ '"react" was changed from a dependency to a peer dependency in react-native v0.21.0.\n' +
+ 'Therefore, it\'s necessary to include "react" in your project\'s dependencies.\n' +
+ 'Please run "npm install --save react", then re-run ' +
+ '"react-native upgrade".',
);
}
}
@@ -47,7 +54,7 @@ function checkGitAvailable() {
} catch (error) {
throw new Error(
'"react-native-git-upgrade" requires "git" to be available in path. ' +
- 'Please install Git (https://git-scm.com)"'
+ 'Please install Git (https://git-scm.com)"',
);
}
}
diff --git a/react-native-git-upgrade/cli.js b/react-native-git-upgrade/cli.js
index 94647fd16..19103c9fe 100644
--- a/react-native-git-upgrade/cli.js
+++ b/react-native-git-upgrade/cli.js
@@ -3,16 +3,19 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
require('babel-register')({
presets: [
require('babel-preset-es2015-node'),
- require('babel-preset-stage-3')
+ require('babel-preset-stage-3'),
],
// Enable transpiling for react-native-git-upgrade AND the generator, just like the upgrade CLI command does
- only: /(react-native-git-upgrade\/(?!(node_modules)))|(local-cli\/generator)/
+ only: /(react-native-git-upgrade\/(?!(node_modules)))|(local-cli\/generator)/,
});
var cliEntry = require('./cliEntry');
diff --git a/react-native-git-upgrade/cliEntry.js b/react-native-git-upgrade/cliEntry.js
index 49f9d53b4..bb3afc61e 100644
--- a/react-native-git-upgrade/cliEntry.js
+++ b/react-native-git-upgrade/cliEntry.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
const fs = require('fs');
@@ -36,7 +39,8 @@ log.heading = 'git-upgrade';
*/
function exec(command, logOutput, logger = null) {
return new Promise((resolve, reject) => {
- let stderr, stdout = '';
+ let stderr,
+ stdout = '';
const child = shell.exec(command, {async: true, silent: true});
child.stdout.on('data', data => {
@@ -63,22 +67,26 @@ function exec(command, logOutput, logger = null) {
if (code === 0) {
resolve(stdout);
} else if (code) {
- reject(new Error(`Command '${command}' exited with code ${code}:
+ reject(
+ new Error(`Command '${command}' exited with code ${code}:
stderr: ${stderr}
-stdout: ${stdout}`));
+stdout: ${stdout}`),
+ );
} else {
- reject(new Error(`Command '${command}' terminated with signal '${signal}':
+ reject(
+ new Error(`Command '${command}' terminated with signal '${signal}':
stderr: ${stderr}
-stdout: ${stdout}`));
+stdout: ${stdout}`),
+ );
}
});
});
}
function parseJsonFile(path, useYarn) {
- const installHint = useYarn ?
- 'Make sure you ran "yarn" and that you are inside a React Native project.' :
- 'Make sure you ran "npm install" and that you are inside a React Native project.';
+ const installHint = useYarn
+ ? 'Make sure you ran "yarn" and that you are inside a React Native project.'
+ : 'Make sure you ran "npm install" and that you are inside a React Native project.';
let fileContents;
try {
fileContents = fs.readFileSync(path, 'utf8');
@@ -94,18 +102,22 @@ function parseJsonFile(path, useYarn) {
function readPackageFiles(useYarn) {
const reactNativeNodeModulesPakPath = path.resolve(
- process.cwd(), 'node_modules', 'react-native', 'package.json'
+ process.cwd(),
+ 'node_modules',
+ 'react-native',
+ 'package.json',
);
const reactNodeModulesPakPath = path.resolve(
- process.cwd(), 'node_modules', 'react', 'package.json'
- );
- const pakPath = path.resolve(
- process.cwd(), 'package.json'
+ process.cwd(),
+ 'node_modules',
+ 'react',
+ 'package.json',
);
+ const pakPath = path.resolve(process.cwd(), 'package.json');
return {
reactNativeNodeModulesPak: parseJsonFile(reactNativeNodeModulesPakPath),
reactNodeModulesPak: parseJsonFile(reactNodeModulesPakPath),
- pak: parseJsonFile(pakPath)
+ pak: parseJsonFile(pakPath),
};
}
@@ -121,15 +133,16 @@ function parseInformationJsonOutput(jsonOutput, requestedVersion) {
return {newVersion, newReactVersionRange};
} catch (err) {
throw new Error(
- 'The specified version of React Native ' + requestedVersion + ' doesn\'t exist.\n' +
- 'Re-run the react-native-git-upgrade command with an existing version,\n' +
- 'for example: "react-native-git-upgrade 0.38.0",\n' +
- 'or without arguments to upgrade to the latest: "react-native-git-upgrade".'
+ 'The specified version of React Native ' +
+ requestedVersion +
+ " doesn't exist.\n" +
+ 'Re-run the react-native-git-upgrade command with an existing version,\n' +
+ 'for example: "react-native-git-upgrade 0.38.0",\n' +
+ 'or without arguments to upgrade to the latest: "react-native-git-upgrade".',
);
}
}
-
function setupWorkingDir(tmpDir) {
return new Promise((resolve, reject) => {
rimraf(tmpDir, err => {
@@ -163,7 +176,11 @@ function copyCurrentGitIgnoreFile(tmpDir) {
*/
try {
const gitignorePath = path.resolve(process.cwd(), '.gitignore');
- const repoExcludePath = path.resolve(tmpDir, process.env.GIT_DIR, 'info/exclude');
+ const repoExcludePath = path.resolve(
+ tmpDir,
+ process.env.GIT_DIR,
+ 'info/exclude',
+ );
const content = fs.readFileSync(gitignorePath, 'utf8');
fs.appendFileSync(repoExcludePath, content);
} catch (err) {
@@ -188,7 +205,10 @@ function generateTemplates(generatorDir, appName, verbose) {
}
function runCopyAndReplace(generatorDir, appName) {
- const copyProjectTemplateAndReplacePath = path.resolve(generatorDir, 'copyProjectTemplateAndReplace');
+ const copyProjectTemplateAndReplacePath = path.resolve(
+ generatorDir,
+ 'copyProjectTemplateAndReplace',
+ );
/*
* This module is required twice during the process: for both old and new version
* of React Native.
@@ -201,7 +221,7 @@ function runCopyAndReplace(generatorDir, appName) {
path.resolve(generatorDir, '..', 'templates', 'HelloWorld'),
process.cwd(),
appName,
- {upgrade: true, force: true}
+ {upgrade: true, force: true},
);
}
@@ -216,7 +236,9 @@ function runYeomanGenerators(generatorDir, appName, verbose) {
const env = yeoman.createEnv();
env.register(generatorDir, 'react:app');
const generatorArgs = ['react:app', appName];
- return new Promise((resolve) => env.run(generatorArgs, {upgrade: true, force: true}, resolve));
+ return new Promise(resolve =>
+ env.run(generatorArgs, {upgrade: true, force: true}, resolve),
+ );
}
/**
@@ -225,15 +247,17 @@ function runYeomanGenerators(generatorDir, appName, verbose) {
async function checkForUpdates() {
try {
log.info('Check for updates');
- const lastGitUpgradeVersion = await exec('npm view react-native-git-upgrade@latest version');
+ const lastGitUpgradeVersion = await exec(
+ 'npm view react-native-git-upgrade@latest version',
+ );
const current = require('./package').version;
const latest = semver.clean(lastGitUpgradeVersion);
if (semver.gt(latest, current)) {
log.warn(
'A more recent version of "react-native-git-upgrade" has been found.\n' +
- `Current: ${current}\n` +
- `Latest: ${latest}\n` +
- 'Please run "npm install -g react-native-git-upgrade"'
+ `Current: ${current}\n` +
+ `Latest: ${latest}\n` +
+ 'Please run "npm install -g react-native-git-upgrade"',
);
}
} catch (err) {
@@ -263,7 +287,13 @@ function shouldUseYarn(cliArgs, projectDir) {
*/
async function run(requestedVersion, cliArgs) {
const tmpDir = path.resolve(os.tmpdir(), 'react-native-git-upgrade');
- const generatorDir = path.resolve(process.cwd(), 'node_modules', 'react-native', 'local-cli', 'generator');
+ const generatorDir = path.resolve(
+ process.cwd(),
+ 'node_modules',
+ 'react-native',
+ 'local-cli',
+ 'generator',
+ );
let projectBackupCreated = false;
try {
@@ -272,7 +302,11 @@ async function run(requestedVersion, cliArgs) {
const useYarn = shouldUseYarn(cliArgs, path.resolve(process.cwd()));
log.info('Read package.json files');
- const {reactNativeNodeModulesPak, reactNodeModulesPak, pak} = readPackageFiles(useYarn);
+ const {
+ reactNativeNodeModulesPak,
+ reactNodeModulesPak,
+ pak,
+ } = readPackageFiles(useYarn);
const appName = pak.name;
const currentVersion = reactNativeNodeModulesPak.version;
const currentReactVersion = reactNodeModulesPak.version;
@@ -294,11 +328,19 @@ async function run(requestedVersion, cliArgs) {
checkGitAvailable();
log.info('Get information from NPM registry');
- const viewCommand = 'npm view react-native@' + (requestedVersion || 'latest') + ' --json';
+ const viewCommand =
+ 'npm view react-native@' + (requestedVersion || 'latest') + ' --json';
const jsonOutput = await exec(viewCommand, verbose);
- const {newVersion, newReactVersionRange} = parseInformationJsonOutput(jsonOutput, requestedVersion);
+ const {newVersion, newReactVersionRange} = parseInformationJsonOutput(
+ jsonOutput,
+ requestedVersion,
+ );
// Print which versions we're upgrading to
- log.info('Upgrading to React Native ' + newVersion + (newReactVersionRange ? ', React ' + newReactVersionRange : ''));
+ log.info(
+ 'Upgrading to React Native ' +
+ newVersion +
+ (newReactVersionRange ? ', React ' + newReactVersionRange : ''),
+ );
log.info('Setup temporary working directory');
await setupWorkingDir(tmpDir);
@@ -329,7 +371,10 @@ async function run(requestedVersion, cliArgs) {
await exec('git add .', verbose);
log.info('Commit old version template');
- await exec('git commit -m "Old version" --allow-empty --no-verify', verbose);
+ await exec(
+ 'git commit -m "Old version" --allow-empty --no-verify',
+ verbose,
+ );
log.info('Install the new version');
let installCommand;
@@ -339,7 +384,10 @@ async function run(requestedVersion, cliArgs) {
installCommand = 'npm install --save --color=always';
}
installCommand += ' react-native@' + newVersion;
- if (newReactVersionRange && !semver.satisfies(currentReactVersion, newReactVersionRange)) {
+ if (
+ newReactVersionRange &&
+ !semver.satisfies(currentReactVersion, newReactVersionRange)
+ ) {
// Install React as well to avoid unmet peer dependency
installCommand += ' react@' + newReactVersionRange;
}
@@ -352,13 +400,22 @@ async function run(requestedVersion, cliArgs) {
await exec('git add .', verbose);
log.info('Commit new version template');
- await exec('git commit -m "New version" --allow-empty --no-verify', verbose);
+ await exec(
+ 'git commit -m "New version" --allow-empty --no-verify',
+ verbose,
+ );
log.info('Generate the patch between the 2 versions');
- const diffOutput = await exec('git diff --binary --no-color HEAD~1 HEAD', verbose);
+ const diffOutput = await exec(
+ 'git diff --binary --no-color HEAD~1 HEAD',
+ verbose,
+ );
log.info('Save the patch in temp directory');
- const patchPath = path.resolve(tmpDir, `upgrade_${currentVersion}_${newVersion}.patch`);
+ const patchPath = path.resolve(
+ tmpDir,
+ `upgrade_${currentVersion}_${newVersion}.patch`,
+ );
fs.writeFileSync(patchPath, diffOutput);
log.info('Reset the 2 temporary commits');
@@ -376,16 +433,16 @@ async function run(requestedVersion, cliArgs) {
} catch (err) {
log.warn(
'The upgrade process succeeded but there might be conflicts to be resolved. ' +
- 'See above for the list of files that have merge conflicts. ' +
- 'If you don’t see the expected changes, try running:\n' +
- `git apply --reject ${patchPath}`);
+ 'See above for the list of files that have merge conflicts. ' +
+ 'If you don’t see the expected changes, try running:\n' +
+ `git apply --reject ${patchPath}`,
+ );
} finally {
log.info('Upgrade done');
if (cliArgs.verbose) {
log.info(`Temporary working directory: ${tmpDir}`);
}
}
-
} catch (err) {
log.error('An error occurred during upgrade:');
log.error(err.stack);
diff --git a/react-native-git-upgrade/yarn.js b/react-native-git-upgrade/yarn.js
index 9e461190e..b215cfa4a 100644
--- a/react-native-git-upgrade/yarn.js
+++ b/react-native-git-upgrade/yarn.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
const execSync = require('child_process').execSync;
@@ -22,7 +25,9 @@ function getYarnVersionIfAvailable() {
if (process.platform.startsWith('win')) {
yarnVersion = (execSync('yarn --version').toString() || '').trim();
} else {
- yarnVersion = (execSync('yarn --version 2>/dev/null').toString() || '').trim();
+ yarnVersion = (
+ execSync('yarn --version 2>/dev/null').toString() || ''
+ ).trim();
}
} catch (error) {
return null;
diff --git a/rn-get-polyfills.js b/rn-get-polyfills.js
index e7dd869c6..db65ff224 100644
--- a/rn-get-polyfills.js
+++ b/rn-get-polyfills.js
@@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
+ * @format
*/
'use strict';
diff --git a/scripts/android-e2e-test.js b/scripts/android-e2e-test.js
index bb0e10960..f23371b10 100644
--- a/scripts/android-e2e-test.js
+++ b/scripts/android-e2e-test.js
@@ -21,9 +21,11 @@
* - (cd android && ./gradlew :app:copyDownloadableDepsToLibs)
* - buck build android/app
* - node ../node_modules/.bin/_mocha ../android-e2e-test.js
+ *
+ * @format
*/
- /* eslint-env mocha */
+/* eslint-env mocha */
'use strict';
@@ -35,27 +37,32 @@ require('colors');
// value in ms to print out screen contents, set this value in CI to debug if tests are failing
const appiumDebugInterval = process.env.APPIUM_DEBUG_INTERVAL;
-describe('Android Test App', function () {
+describe('Android Test App', function() {
this.timeout(600000);
let driver;
let debugIntervalId;
- before(function () {
+ before(function() {
driver = wd.promiseChainRemote({
host: 'localhost',
- port: 4723
+ port: 4723,
});
- driver.on('status', function (info) {
+ driver.on('status', function(info) {
console.log(info.cyan);
});
- driver.on('command', function (method, path, data) {
+ driver.on('command', function(method, path, data) {
if (path === 'source()' && data) {
- console.log(' > ' + method.yellow, 'Screen contents'.grey, '\n', pd.xml(data).yellow);
+ console.log(
+ ' > ' + method.yellow,
+ 'Screen contents'.grey,
+ '\n',
+ pd.xml(data).yellow,
+ );
} else {
console.log(' > ' + method.yellow, path.grey, data || '');
}
});
- driver.on('http', function (method, path, data) {
+ driver.on('http', function(method, path, data) {
console.log(' > ' + method.magenta, path, (data || '').grey);
});
@@ -70,7 +77,7 @@ describe('Android Test App', function () {
const desired = {
platformName: 'Android',
deviceName: 'Android Emulator',
- app: path.resolve('buck-out/gen/android/app/app.apk')
+ app: path.resolve('buck-out/gen/android/app/app.apk'),
};
// React Native in dev mode often starts with Red Box "Can't fibd variable __fbBatchedBridge..."
@@ -78,56 +85,79 @@ describe('Android Test App', function () {
return driver
.init(desired)
.setImplicitWaitTimeout(5000)
- .waitForElementByXPath('//android.widget.Button[@text="Reload JS"]').
- then((elem) => {
- elem.click();
- }, (err) => {
- // ignoring if Reload JS button can't be located
- })
+ .waitForElementByXPath('//android.widget.Button[@text="Reload JS"]')
+ .then(
+ elem => {
+ elem.click();
+ },
+ err => {
+ // ignoring if Reload JS button can't be located
+ },
+ )
.setImplicitWaitTimeout(150000);
});
- after(function () {
+ after(function() {
if (debugIntervalId) {
clearInterval(debugIntervalId);
}
return driver.quit();
});
- it('should have Hot Module Reloading working', function () {
+ it('should have Hot Module Reloading working', function() {
const androidAppCode = fs.readFileSync('index.js', 'utf-8');
let intervalToUpdate;
- return driver
- .waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]')
- // http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MENU
- .pressDeviceKey(82)
- .elementByXPath('//android.widget.TextView[starts-with(@text, "Enable Hot Reloading")]')
- .click()
- .waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]')
- .then(() => {
- let iteration = 0;
- // CI environment can be quite slow and we can't guarantee that it can consistently motice a file change
- // so we change the file every few seconds just in case
- intervalToUpdate = setInterval(() => {
- fs.writeFileSync('index.js', androidAppCode.replace('Welcome to React Native!', 'Welcome to React Native with HMR!' + iteration), 'utf-8');
- }, 3000);
- })
- .waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Welcome to React Native with HMR!")]')
- .finally(() => {
- clearInterval(intervalToUpdate);
- fs.writeFileSync('index.js', androidAppCode, 'utf-8');
- });
+ return (
+ driver
+ .waitForElementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]',
+ )
+ // http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MENU
+ .pressDeviceKey(82)
+ .elementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Enable Hot Reloading")]',
+ )
+ .click()
+ .waitForElementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]',
+ )
+ .then(() => {
+ let iteration = 0;
+ // CI environment can be quite slow and we can't guarantee that it can consistently motice a file change
+ // so we change the file every few seconds just in case
+ intervalToUpdate = setInterval(() => {
+ fs.writeFileSync(
+ 'index.js',
+ androidAppCode.replace(
+ 'Welcome to React Native!',
+ 'Welcome to React Native with HMR!' + iteration,
+ ),
+ 'utf-8',
+ );
+ }, 3000);
+ })
+ .waitForElementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Welcome to React Native with HMR!")]',
+ )
+ .finally(() => {
+ clearInterval(intervalToUpdate);
+ fs.writeFileSync('index.js', androidAppCode, 'utf-8');
+ })
+ );
});
-
- it('should have Debug In Chrome working', function () {
+ it('should have Debug In Chrome working', function() {
const androidAppCode = fs.readFileSync('index.js', 'utf-8');
// http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MENU
return driver
- .waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]')
+ .waitForElementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]',
+ )
.pressDeviceKey(82)
.elementByXPath('//android.widget.TextView[starts-with(@text, "Debug")]')
.click()
- .waitForElementByXPath('//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]');
+ .waitForElementByXPath(
+ '//android.widget.TextView[starts-with(@text, "Welcome to React Native!")]',
+ );
});
});
diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js
index 269fc7014..f9492a935 100644
--- a/scripts/publish-npm.js
+++ b/scripts/publish-npm.js
@@ -3,7 +3,10 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
+
'use strict';
/**
@@ -60,17 +63,24 @@ if (buildBranch.indexOf('-stable') !== -1) {
// 34c034298dc9cad5a4553964a5a324450fda0385
const currentCommit = exec('git rev-parse HEAD', {silent: true}).stdout.trim();
// [34c034298dc9cad5a4553964a5a324450fda0385, refs/heads/0.33-stable, refs/tags/latest, refs/tags/v0.33.1, refs/tags/v0.34.1-rc]
-const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {silent: true})
+const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {
+ silent: true,
+})
.stdout.split(/\s/)
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2', 'refs/tags/v0.34.0']
- .filter(version => !!version && version.indexOf(`refs/tags/v${branchVersion}`) === 0)
+ .filter(
+ version =>
+ !!version && version.indexOf(`refs/tags/v${branchVersion}`) === 0,
+ )
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2']
.filter(version => version.indexOf(branchVersion) !== -1)
// ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2']
.map(version => version.slice('refs/tags/'.length));
if (tagsWithVersion.length === 0) {
- echo('Error: Can\'t find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit');
+ echo(
+ "Error: Can't find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit",
+ );
exit(1);
}
let releaseVersion;
@@ -86,7 +96,7 @@ if (tagsWithVersion[0].indexOf('-rc') === -1) {
// -------- Generating Android Artifacts with JavaDoc
if (exec('./gradlew :ReactAndroid:installArchives').code) {
- echo('Couldn\'t generate artifacts');
+ echo("Couldn't generate artifacts");
exit(1);
}
@@ -95,12 +105,17 @@ exec('git checkout ReactAndroid/gradle.properties');
echo('Generated artifacts for Maven');
-let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map((suffix) => {
+let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map(suffix => {
return `react-native-${releaseVersion}${suffix}`;
});
-artifacts.forEach((name) => {
- if (!test('-e', `./android/com/facebook/react/react-native/${releaseVersion}/${name}`)) {
+artifacts.forEach(name => {
+ if (
+ !test(
+ '-e',
+ `./android/com/facebook/react/react-native/${releaseVersion}/${name}`,
+ )
+ ) {
echo(`file ${name} was not generated`);
exit(1);
}
diff --git a/scripts/run-android-ci-instrumentation-tests.js b/scripts/run-android-ci-instrumentation-tests.js
index 17d382a32..9a87de4f8 100644
--- a/scripts/run-android-ci-instrumentation-tests.js
+++ b/scripts/run-android-ci-instrumentation-tests.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
'use strict';
@@ -19,12 +21,7 @@
* --retries [num] - how many times to retry possible flaky commands: npm install and running tests, default 1
*/
-const {
- echo,
- exec,
- exit,
- ls,
-} = require('shelljs');
+const {echo, exec, exit, ls} = require('shelljs');
const argv = require('yargs').argv;
const numberOfRetries = argv.retries || 1;
@@ -34,33 +31,39 @@ const path = require('path');
// Flaky tests ignored on Circle CI. They still run internally at fb.
const ignoredTests = [
'ReactScrollViewTestCase',
- 'ReactHorizontalScrollViewTestCase'
+ 'ReactHorizontalScrollViewTestCase',
];
// ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactHorizontalScrollViewTestCase.java
const testClasses = ls(`${argv.path}/*.java`)
-.map(javaFile => {
- // ReactHorizontalScrollViewTestCase
- return path.basename(javaFile, '.java');
-}).filter(className => {
- return ignoredTests.indexOf(className) === -1;
-}).map(className => {
- // com.facebook.react.tests.ReactHorizontalScrollViewTestCase
- return argv.package + '.' + className;
-});
+ .map(javaFile => {
+ // ReactHorizontalScrollViewTestCase
+ return path.basename(javaFile, '.java');
+ })
+ .filter(className => {
+ return ignoredTests.indexOf(className) === -1;
+ })
+ .map(className => {
+ // com.facebook.react.tests.ReactHorizontalScrollViewTestCase
+ return argv.package + '.' + className;
+ });
let exitCode = 0;
-testClasses.forEach((testClass) => {
- if (tryExecNTimes(
- () => {
+testClasses.forEach(testClass => {
+ if (
+ tryExecNTimes(() => {
echo(`Starting ${testClass}`);
// any faster means Circle CI crashes
exec('sleep 10s');
- return exec(`./scripts/run-instrumentation-tests-via-adb-shell.sh ${argv.package} ${testClass}`).code;
- },
- numberOfRetries)) {
- echo(`${testClass} failed ${numberOfRetries} times`);
- exitCode = 1;
+ return exec(
+ `./scripts/run-instrumentation-tests-via-adb-shell.sh ${
+ argv.package
+ } ${testClass}`,
+ ).code;
+ }, numberOfRetries)
+ ) {
+ echo(`${testClass} failed ${numberOfRetries} times`);
+ exitCode = 1;
}
});
diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js
index cd1163f0b..f3096c083 100644
--- a/scripts/run-ci-e2e-tests.js
+++ b/scripts/run-ci-e2e-tests.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
'use strict';
@@ -32,8 +34,12 @@ const TEMP = exec('mktemp -d /tmp/react-native-XXXXXXXX').stdout.trim();
// To make sure we actually installed the local version
// of react-native, we will create a temp file inside the template
// and check that it exists after `react-native init
-const MARKER_IOS = exec(`mktemp ${ROOT}/local-cli/templates/HelloWorld/ios/HelloWorld/XXXXXXXX`).stdout.trim();
-const MARKER_ANDROID = exec(`mktemp ${ROOT}/local-cli/templates/HelloWorld/android/XXXXXXXX`).stdout.trim();
+const MARKER_IOS = exec(
+ `mktemp ${ROOT}/local-cli/templates/HelloWorld/ios/HelloWorld/XXXXXXXX`,
+).stdout.trim();
+const MARKER_ANDROID = exec(
+ `mktemp ${ROOT}/local-cli/templates/HelloWorld/android/XXXXXXXX`,
+).stdout.trim();
const numberOfRetries = argv.retries || 1;
let SERVER_PID;
let APPIUM_PID;
@@ -43,7 +49,11 @@ try {
// install CLI
cd('react-native-cli');
exec('yarn pack');
- const CLI_PACKAGE = path.join(ROOT, 'react-native-cli', 'react-native-cli-*.tgz');
+ const CLI_PACKAGE = path.join(
+ ROOT,
+ 'react-native-cli',
+ 'react-native-cli-*.tgz',
+ );
cd('..');
if (!argv['skip-cli-install']) {
@@ -56,7 +66,11 @@ try {
}
if (argv.android) {
- if (exec('./gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"').code) {
+ if (
+ exec(
+ './gradlew :ReactAndroid:installArchives -Pjobs=1 -Dorg.gradle.jvmargs="-Xmx512m -XX:+HeapDumpOnOutOfMemoryError"',
+ ).code
+ ) {
echo('Failed to compile Android binaries');
exitCode = 1;
throw Error(exitCode);
@@ -71,17 +85,20 @@ try {
const PACKAGE = path.join(ROOT, 'react-native-*.tgz');
cd(TEMP);
- if (tryExecNTimes(
- () => {
- exec('sleep 10s');
- return exec(`react-native init EndToEndTest --version ${PACKAGE}`).code;
- },
- numberOfRetries,
- () => rm('-rf', 'EndToEndTest'))) {
- echo('Failed to execute react-native init');
- echo('Most common reason is npm registry connectivity, try again');
- exitCode = 1;
- throw Error(exitCode);
+ if (
+ tryExecNTimes(
+ () => {
+ exec('sleep 10s');
+ return exec(`react-native init EndToEndTest --version ${PACKAGE}`).code;
+ },
+ numberOfRetries,
+ () => rm('-rf', 'EndToEndTest'),
+ )
+ ) {
+ echo('Failed to execute react-native init');
+ echo('Most common reason is npm registry connectivity, try again');
+ exitCode = 1;
+ throw Error(exitCode);
}
cd('EndToEndTest');
@@ -89,13 +106,20 @@ try {
if (argv.android) {
echo('Running an Android e2e test');
echo('Installing e2e framework');
- if (tryExecNTimes(
- () => exec('yarn add --dev appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1', { silent: true }).code,
- numberOfRetries)) {
- echo('Failed to install appium');
- echo('Most common reason is npm registry connectivity, try again');
- exitCode = 1;
- throw Error(exitCode);
+ if (
+ tryExecNTimes(
+ () =>
+ exec(
+ 'yarn add --dev appium@1.5.1 mocha@2.4.5 wd@0.3.11 colors@1.0.3 pretty-data2@0.40.1',
+ {silent: true},
+ ).code,
+ numberOfRetries,
+ )
+ ) {
+ echo('Failed to install appium');
+ echo('Most common reason is npm registry connectivity, try again');
+ exitCode = 1;
+ throw Error(exitCode);
}
cp(`${SCRIPTS}/android-e2e-test.js`, 'android-e2e-test.js');
cd('android');
@@ -108,7 +132,9 @@ try {
throw Error(exitCode);
}
cd('..');
- exec('keytool -genkey -v -keystore android/keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"');
+ exec(
+ 'keytool -genkey -v -keystore android/keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"',
+ );
echo(`Starting appium server, ${APPIUM_PID}`);
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
@@ -124,27 +150,27 @@ try {
echo(`Starting packager server, ${SERVER_PID}`);
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], {
- env: process.env
+ env: process.env,
});
SERVER_PID = packagerProcess.pid;
// wait a bit to allow packager to startup
exec('sleep 15s');
echo('Executing android e2e test');
- if (tryExecNTimes(
- () => {
+ if (
+ tryExecNTimes(() => {
exec('sleep 10s');
return exec('node node_modules/.bin/_mocha android-e2e-test.js').code;
- },
- numberOfRetries)) {
- echo('Failed to run Android e2e tests');
- echo('Most likely the code is broken');
- exitCode = 1;
- throw Error(exitCode);
+ }, numberOfRetries)
+ ) {
+ echo('Failed to run Android e2e tests');
+ echo('Most likely the code is broken');
+ exitCode = 1;
+ throw Error(exitCode);
}
}
if (argv.ios || argv.tvos) {
- var iosTestType = (argv.tvos ? 'tvOS' : 'iOS');
+ var iosTestType = argv.tvos ? 'tvOS' : 'iOS';
echo('Running the ' + iosTestType + 'app');
cd('ios');
// Make sure we installed local version of react-native
@@ -156,43 +182,56 @@ try {
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
- const packagerProcess = spawn('yarn', ['start', '--nonPersistent'],
- {
- stdio: 'inherit',
- env: packagerEnv
- });
+ const packagerProcess = spawn('yarn', ['start', '--nonPersistent'], {
+ stdio: 'inherit',
+ env: packagerEnv,
+ });
SERVER_PID = packagerProcess.pid;
exec('sleep 15s');
// prepare cache to reduce chances of possible red screen "Can't fibd variable __fbBatchedBridge..."
- exec('response=$(curl --write-out %{http_code} --silent --output /dev/null localhost:8081/index.bundle?platform=ios&dev=true)');
+ exec(
+ 'response=$(curl --write-out %{http_code} --silent --output /dev/null localhost:8081/index.bundle?platform=ios&dev=true)',
+ );
echo(`Starting packager server, ${SERVER_PID}`);
echo('Executing ' + iosTestType + ' e2e test');
- if (tryExecNTimes(
- () => {
+ if (
+ tryExecNTimes(() => {
exec('sleep 10s');
if (argv.tvos) {
- return exec('xcodebuild -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0" -scheme EndToEndTest-tvOS -sdk appletvsimulator test | xcpretty && exit ${PIPESTATUS[0]}').code;
+ return exec(
+ 'xcodebuild -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0" -scheme EndToEndTest-tvOS -sdk appletvsimulator test | xcpretty && exit ${PIPESTATUS[0]}',
+ ).code;
} else {
- return exec('xcodebuild -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" -scheme EndToEndTest -sdk iphonesimulator test | xcpretty && exit ${PIPESTATUS[0]}').code;
+ return exec(
+ 'xcodebuild -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" -scheme EndToEndTest -sdk iphonesimulator test | xcpretty && exit ${PIPESTATUS[0]}',
+ ).code;
}
- },
- numberOfRetries)) {
- echo('Failed to run ' + iosTestType + ' e2e tests');
- echo('Most likely the code is broken');
- exitCode = 1;
- throw Error(exitCode);
+ }, numberOfRetries)
+ ) {
+ echo('Failed to run ' + iosTestType + ' e2e tests');
+ echo('Most likely the code is broken');
+ exitCode = 1;
+ throw Error(exitCode);
}
cd('..');
}
if (argv.js) {
// Check the packager produces a bundle (doesn't throw an error)
- if (exec('react-native bundle --max-workers 1 --platform android --dev true --entry-file index.js --bundle-output android-bundle.js').code) {
+ if (
+ exec(
+ 'react-native bundle --max-workers 1 --platform android --dev true --entry-file index.js --bundle-output android-bundle.js',
+ ).code
+ ) {
echo('Could not build Android bundle');
exitCode = 1;
throw Error(exitCode);
}
- if (exec('react-native --max-workers 1 bundle --platform ios --dev true --entry-file index.js --bundle-output ios-bundle.js').code) {
+ if (
+ exec(
+ 'react-native --max-workers 1 bundle --platform ios --dev true --entry-file index.js --bundle-output ios-bundle.js',
+ ).code
+ ) {
echo('Could not build iOS bundle');
exitCode = 1;
throw Error(exitCode);
@@ -209,7 +248,6 @@ try {
}
}
exitCode = 0;
-
} finally {
cd(ROOT);
rm(MARKER_IOS);
diff --git a/scripts/try-n-times.js b/scripts/try-n-times.js
index 59abeca17..1be720936 100644
--- a/scripts/try-n-times.js
+++ b/scripts/try-n-times.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
/* globals echo:false */
diff --git a/setupBabel.js b/setupBabel.js
index 96b54429d..7c6784f79 100644
--- a/setupBabel.js
+++ b/setupBabel.js
@@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
+ *
+ * @format
*/
'use strict';
@@ -17,7 +19,9 @@ const BABEL_ENABLED_PATHS = ['local-cli'];
* support Flow type annotations.
*/
function setupBabel() {
- babelRegisterOnly(babelRegisterOnly.buildRegExps(__dirname, BABEL_ENABLED_PATHS));
+ babelRegisterOnly(
+ babelRegisterOnly.buildRegExps(__dirname, BABEL_ENABLED_PATHS),
+ );
}
module.exports = setupBabel;