Skip to content

Commit 2f0d608

Browse files
nissy-devfacebook-github-bot
authored andcommitted
Remove var in RNTester (#22018)
Summary: I removed `var` in RNTester. - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android [GENERAL] [ENHANCEMENT] [RNTester] - remove `var` Pull Request resolved: facebook/react-native#22018 Differential Revision: D12843078 Pulled By: TheSavior fbshipit-source-id: a3928436b2c73ead931e7c957fab8ad74975ef73
1 parent 6c8f0ec commit 2f0d608

10 files changed

+59
-59
lines changed

js/BorderExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactNative = require('react-native');
14-
var {StyleSheet, View} = ReactNative;
12+
const React = require('react');
13+
const ReactNative = require('react-native');
14+
const {StyleSheet, View} = ReactNative;
1515

16-
var styles = StyleSheet.create({
16+
const styles = StyleSheet.create({
1717
box: {
1818
width: 100,
1919
height: 100,

js/BoxShadowExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactNative = require('react-native');
14-
var {Image, StyleSheet, View} = ReactNative;
12+
const React = require('react');
13+
const ReactNative = require('react-native');
14+
const {Image, StyleSheet, View} = ReactNative;
1515

16-
var styles = StyleSheet.create({
16+
const styles = StyleSheet.create({
1717
box: {
1818
width: 100,
1919
height: 100,

js/CameraRollView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function rowHasChanged<T>(r1: Array<T>, r2: Array<T>): boolean {
3939
return true;
4040
}
4141

42-
for (var i = 0; i < r1.length; i++) {
42+
for (let i = 0; i < r1.length; i++) {
4343
if (r1[i] !== r2[i]) {
4444
return true;
4545
}

js/ClipboardExample.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212

13-
var React = require('react');
14-
var ReactNative = require('react-native');
15-
var {Clipboard, View, Text} = ReactNative;
13+
const React = require('react');
14+
const ReactNative = require('react-native');
15+
const {Clipboard, View, Text} = ReactNative;
1616

1717
class ClipboardExample extends React.Component<{}, $FlowFixMeState> {
1818
state = {
@@ -22,7 +22,7 @@ class ClipboardExample extends React.Component<{}, $FlowFixMeState> {
2222
_setClipboardContent = async () => {
2323
Clipboard.setString('Hello World');
2424
try {
25-
var content = await Clipboard.getString();
25+
const content = await Clipboard.getString();
2626
this.setState({content});
2727
} catch (e) {
2828
this.setState({content: e.message});

js/DatePickerAndroidExample.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99

1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactNative = require('react-native');
14-
var {
12+
const React = require('react');
13+
const ReactNative = require('react-native');
14+
const {
1515
DatePickerAndroid,
1616
StyleSheet,
1717
Text,
1818
TouchableWithoutFeedback,
1919
} = ReactNative;
2020

21-
var RNTesterBlock = require('./RNTesterBlock');
22-
var RNTesterPage = require('./RNTesterPage');
21+
const RNTesterBlock = require('./RNTesterBlock');
22+
const RNTesterPage = require('./RNTesterPage');
2323

2424
class DatePickerAndroidExample extends React.Component {
2525
static title = 'DatePickerAndroid';
@@ -44,12 +44,12 @@ class DatePickerAndroidExample extends React.Component {
4444

4545
showPicker = async (stateKey, options) => {
4646
try {
47-
var newState = {};
47+
const newState = {};
4848
const {action, year, month, day} = await DatePickerAndroid.open(options);
4949
if (action === DatePickerAndroid.dismissedAction) {
5050
newState[stateKey + 'Text'] = 'dismissed';
5151
} else {
52-
var date = new Date(year, month, day);
52+
const date = new Date(year, month, day);
5353
newState[stateKey + 'Text'] = date.toLocaleDateString();
5454
newState[stateKey + 'Date'] = date;
5555
}
@@ -138,7 +138,7 @@ class DatePickerAndroidExample extends React.Component {
138138
}
139139
}
140140

141-
var styles = StyleSheet.create({
141+
const styles = StyleSheet.create({
142142
text: {
143143
color: 'black',
144144
},

js/DatePickerIOSExample.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212

13-
var React = require('react');
14-
var ReactNative = require('react-native');
15-
var {DatePickerIOS, StyleSheet, Text, TextInput, View} = ReactNative;
13+
const React = require('react');
14+
const ReactNative = require('react-native');
15+
const {DatePickerIOS, StyleSheet, Text, TextInput, View} = ReactNative;
1616

1717
class DatePickerExample extends React.Component<
1818
$FlowFixMeProps,
@@ -33,7 +33,7 @@ class DatePickerExample extends React.Component<
3333
};
3434

3535
onTimezoneChange = event => {
36-
var offset = parseInt(event.nativeEvent.text, 10);
36+
const offset = parseInt(event.nativeEvent.text, 10);
3737
if (isNaN(offset)) {
3838
return;
3939
}
@@ -122,7 +122,7 @@ exports.examples = [
122122
},
123123
];
124124

125-
var styles = StyleSheet.create({
125+
const styles = StyleSheet.create({
126126
textinput: {
127127
height: 26,
128128
width: 50,

js/GeolocationExample.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
'use strict';
1212

13-
var React = require('react');
14-
var ReactNative = require('react-native');
15-
var {StyleSheet, Text, View} = ReactNative;
13+
const React = require('react');
14+
const ReactNative = require('react-native');
15+
const {StyleSheet, Text, View} = ReactNative;
1616

1717
exports.framework = 'React';
1818
exports.title = 'Geolocation';
@@ -38,14 +38,14 @@ class GeolocationExample extends React.Component<{}, $FlowFixMeState> {
3838
componentDidMount() {
3939
navigator.geolocation.getCurrentPosition(
4040
position => {
41-
var initialPosition = JSON.stringify(position);
41+
const initialPosition = JSON.stringify(position);
4242
this.setState({initialPosition});
4343
},
4444
error => alert(JSON.stringify(error)),
4545
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000},
4646
);
4747
this.watchID = navigator.geolocation.watchPosition(position => {
48-
var lastPosition = JSON.stringify(position);
48+
const lastPosition = JSON.stringify(position);
4949
this.setState({lastPosition});
5050
});
5151
}
@@ -70,7 +70,7 @@ class GeolocationExample extends React.Component<{}, $FlowFixMeState> {
7070
}
7171
}
7272

73-
var styles = StyleSheet.create({
73+
const styles = StyleSheet.create({
7474
title: {
7575
fontWeight: '500',
7676
},

js/ImageCapInsetsExample.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
'use strict';
1212

13-
var React = require('react');
14-
var ReactNative = require('react-native');
13+
const React = require('react');
14+
const ReactNative = require('react-native');
1515

16-
var nativeImageSource = require('nativeImageSource');
17-
var {Image, StyleSheet, Text, View} = ReactNative;
16+
const nativeImageSource = require('nativeImageSource');
17+
const {Image, StyleSheet, Text, View} = ReactNative;
1818

1919
class ImageCapInsetsExample extends React.Component<{}> {
2020
render() {
@@ -51,7 +51,7 @@ class ImageCapInsetsExample extends React.Component<{}> {
5151
}
5252
}
5353

54-
var styles = StyleSheet.create({
54+
const styles = StyleSheet.create({
5555
background: {
5656
backgroundColor: '#F6F6F6',
5757
justifyContent: 'center',

js/ImageEditingExample.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactNative = require('react-native');
14-
var {
12+
const React = require('react');
13+
const ReactNative = require('react-native');
14+
const {
1515
CameraRoll,
1616
Image,
1717
ImageEditor,
@@ -23,7 +23,7 @@ var {
2323
View,
2424
} = ReactNative;
2525

26-
var PAGE_SIZE = 20;
26+
const PAGE_SIZE = 20;
2727

2828
type ImageOffset = {|
2929
x: number,
@@ -68,9 +68,9 @@ class SquareImageCropper extends React.Component<
6868
if (!this._isMounted) {
6969
return;
7070
}
71-
var edges = data.edges;
72-
var edge = edges[Math.floor(Math.random() * edges.length)];
73-
var randomPhoto = edge && edge.node && edge.node.image;
71+
const edges = data.edges;
72+
const edge = edges[Math.floor(Math.random() * edges.length)];
73+
const randomPhoto = edge && edge.node && edge.node.image;
7474
if (randomPhoto) {
7575
this.setState({randomPhoto});
7676
}
@@ -89,7 +89,7 @@ class SquareImageCropper extends React.Component<
8989
<View
9090
style={styles.container}
9191
onLayout={event => {
92-
var measuredWidth = event.nativeEvent.layout.width;
92+
const measuredWidth = event.nativeEvent.layout.width;
9393
if (!measuredWidth) {
9494
return;
9595
}
@@ -111,7 +111,7 @@ class SquareImageCropper extends React.Component<
111111
if (!this.state.randomPhoto) {
112112
return <View style={styles.container} />;
113113
}
114-
var error = null;
114+
let error = null;
115115
if (this.state.cropError) {
116116
error = <Text>{this.state.cropError.message}</Text>;
117117
}
@@ -184,8 +184,8 @@ class ImageCropper extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
184184
componentWillMount() {
185185
// Scale an image to the minimum size that is large enough to completely
186186
// fill the crop box.
187-
var widthRatio = this.props.image.width / this.props.size.width;
188-
var heightRatio = this.props.image.height / this.props.size.height;
187+
const widthRatio = this.props.image.width / this.props.size.width;
188+
const heightRatio = this.props.image.height / this.props.size.height;
189189
this._horizontal = widthRatio > heightRatio;
190190
if (this._horizontal) {
191191
this._scaledImageSize = {
@@ -234,12 +234,12 @@ class ImageCropper extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
234234
}
235235

236236
_updateTransformData(offset, scaledImageSize, croppedImageSize) {
237-
var offsetRatioX = offset.x / scaledImageSize.width;
238-
var offsetRatioY = offset.y / scaledImageSize.height;
239-
var sizeRatioX = croppedImageSize.width / scaledImageSize.width;
240-
var sizeRatioY = croppedImageSize.height / scaledImageSize.height;
237+
const offsetRatioX = offset.x / scaledImageSize.width;
238+
const offsetRatioY = offset.y / scaledImageSize.height;
239+
const sizeRatioX = croppedImageSize.width / scaledImageSize.width;
240+
const sizeRatioY = croppedImageSize.height / scaledImageSize.height;
241241

242-
var cropData: ImageCropData = {
242+
const cropData: ImageCropData = {
243243
offset: {
244244
x: this.props.image.width * offsetRatioX,
245245
y: this.props.image.height * offsetRatioY,
@@ -287,7 +287,7 @@ exports.examples = [
287287
},
288288
];
289289

290-
var styles = StyleSheet.create({
290+
const styles = StyleSheet.create({
291291
container: {
292292
flex: 1,
293293
alignSelf: 'stretch',

js/ImageExample.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class NetworkImageCallbackExample extends React.Component<
9393
`✔ Prefetch OK (+${new Date() - mountTime}ms)`,
9494
);
9595
Image.queryCache([IMAGE_PREFETCH_URL]).then(map => {
96-
var result = map.get(IMAGE_PREFETCH_URL);
96+
const result = map.get(IMAGE_PREFETCH_URL);
9797
if (result) {
9898
this._loadEventFired(
9999
`✔ queryCache "${result}" (+${new Date() -
@@ -172,7 +172,7 @@ class NetworkImageExample extends React.Component<
172172
};
173173

174174
render() {
175-
var loader = this.state.loading ? (
175+
const loader = this.state.loading ? (
176176
<View style={styles.progress}>
177177
<Text>{this.state.progress}%</Text>
178178
<ActivityIndicator style={{marginLeft: 5}} />
@@ -891,14 +891,14 @@ exports.examples = [
891891
},
892892
];
893893

894-
var fullImage = {
894+
const fullImage = {
895895
uri: 'https://facebook.github.io/react-native/img/opengraph.png',
896896
};
897-
var smallImage = {
897+
const smallImage = {
898898
uri: 'https://facebook.github.io/react-native/img/favicon.png',
899899
};
900900

901-
var styles = StyleSheet.create({
901+
const styles = StyleSheet.create({
902902
base: {
903903
width: 38,
904904
height: 38,

0 commit comments

Comments
 (0)