Skip to content

Commit

Permalink
Remove var in RNTester (#22014)
Browse files Browse the repository at this point in the history
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#22014

Differential Revision: D12843150

Pulled By: TheSavior

fbshipit-source-id: 593adf141164cffe0ddc2db756721df26e38b4f5
  • Loading branch information
nissy-dev authored and facebook-github-bot committed Oct 30, 2018
1 parent b2123a3 commit 83986b4
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 87 deletions.
10 changes: 5 additions & 5 deletions js/VibrationExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
const React = require('react');
const ReactNative = require('react-native');
const {
StyleSheet,
View,
Text,
Expand All @@ -25,7 +25,7 @@ exports.framework = 'React';
exports.title = 'Vibration';
exports.description = 'Vibration API';

var pattern, patternLiteral, patternDescription;
let pattern, patternLiteral, patternDescription;
if (Platform.OS === 'android') {
pattern = [0, 500, 200, 500];
patternLiteral = '[0, 500, 200, 500]';
Expand Down Expand Up @@ -115,7 +115,7 @@ exports.examples = [
},
];

var styles = StyleSheet.create({
const styles = StyleSheet.create({
wrapper: {
borderRadius: 5,
marginBottom: 5,
Expand Down
31 changes: 16 additions & 15 deletions js/ViewPagerAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
const React = require('react');
const ReactNative = require('react-native');
const {
Image,
StyleSheet,
Text,
Expand All @@ -23,9 +23,9 @@ var {

import type {ViewPagerScrollState} from 'ViewPagerAndroid';

var PAGES = 5;
var BGCOLOR = ['#fdc08e', '#fff6b9', '#99d1b7', '#dde5fe', '#f79273'];
var IMAGE_URIS = [
const PAGES = 5;
const BGCOLOR = ['#fdc08e', '#fff6b9', '#99d1b7', '#dde5fe', '#f79273'];
const IMAGE_URIS = [
'https://apod.nasa.gov/apod/image/1410/20141008tleBaldridge001h990.jpg',
'https://apod.nasa.gov/apod/image/1409/volcanicpillar_vetter_960.jpg',
'https://apod.nasa.gov/apod/image/1409/m27_snyder_960.jpg',
Expand All @@ -43,7 +43,7 @@ class LikeCount extends React.Component {
};

render() {
var thumbsUp = '\uD83D\uDC4D';
const thumbsUp = '\uD83D\uDC4D';
return (
<View style={styles.likeContainer}>
<TouchableOpacity onPress={this.onClick} style={styles.likeButton}>
Expand Down Expand Up @@ -79,9 +79,10 @@ class Button extends React.Component {

class ProgressBar extends React.Component {
render() {
var fractionalPosition =
const fractionalPosition =
this.props.progress.position + this.props.progress.offset;
var progressBarSize = (fractionalPosition / (PAGES - 1)) * this.props.size;
const progressBarSize =
(fractionalPosition / (PAGES - 1)) * this.props.size;
return (
<View style={[styles.progressBarContainer, {width: this.props.size}]}>
<View style={[styles.progressBar, {width: progressBarSize}]} />
Expand Down Expand Up @@ -118,7 +119,7 @@ class ViewPagerAndroidExample extends React.Component {
};

move = delta => {
var page = this.state.page + delta;
const page = this.state.page + delta;
this.go(page);
};

Expand All @@ -133,9 +134,9 @@ class ViewPagerAndroidExample extends React.Component {
};

render() {
var pages = [];
for (var i = 0; i < PAGES; i++) {
var pageStyle = {
const pages = [];
for (let i = 0; i < PAGES; i++) {
const pageStyle = {
backgroundColor: BGCOLOR[i % BGCOLOR.length],
alignItems: 'center',
padding: 20,
Expand All @@ -150,7 +151,7 @@ class ViewPagerAndroidExample extends React.Component {
</View>,
);
}
var {page, animationsAreEnabled} = this.state;
const {page, animationsAreEnabled} = this.state;
return (
<View style={styles.container}>
<ViewPagerAndroid
Expand Down Expand Up @@ -222,7 +223,7 @@ class ViewPagerAndroidExample extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
buttons: {
flexDirection: 'row',
height: 30,
Expand Down
24 changes: 12 additions & 12 deletions js/WebViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
const React = require('react');
const ReactNative = require('react-native');
const {
StyleSheet,
Text,
TextInput,
Expand All @@ -22,13 +22,13 @@ var {
WebView,
} = ReactNative;

var HEADER = '#3b5998';
var BGWASH = 'rgba(255,255,255,0.8)';
var DISABLED_WASH = 'rgba(255,255,255,0.25)';
const HEADER = '#3b5998';
const BGWASH = 'rgba(255,255,255,0.8)';
const DISABLED_WASH = 'rgba(255,255,255,0.25)';

var TEXT_INPUT_REF = 'urlInput';
var WEBVIEW_REF = 'webview';
var DEFAULT_URL = 'https://m.facebook.com';
const TEXT_INPUT_REF = 'urlInput';
const WEBVIEW_REF = 'webview';
const DEFAULT_URL = 'https://m.facebook.com';
const FILE_SYSTEM_ORIGIN_WHITE_LIST = ['file://*', 'http://*', 'https://*'];

class WebViewExample extends React.Component<{}, $FlowFixMeState> {
Expand All @@ -44,7 +44,7 @@ class WebViewExample extends React.Component<{}, $FlowFixMeState> {
inputText = '';

handleTextInputChange = event => {
var url = event.nativeEvent.text;
let url = event.nativeEvent.text;
if (!/^[a-zA-Z-_]+:/.test(url)) {
url = 'http://' + url;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ class WebViewExample extends React.Component<{}, $FlowFixMeState> {
};

pressGoButton = () => {
var url = this.inputText.toLowerCase();
const url = this.inputText.toLowerCase();
if (url === this.state.url) {
this.reload();
} else {
Expand Down Expand Up @@ -297,7 +297,7 @@ class InjectJS extends React.Component<{}> {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: HEADER,
Expand Down
16 changes: 8 additions & 8 deletions js/XHRExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

'use strict';

var React = require('react');
const React = require('react');

var XHRExampleDownload = require('./XHRExampleDownload');
var XHRExampleBinaryUpload = require('./XHRExampleBinaryUpload');
var XHRExampleFormData = require('./XHRExampleFormData');
var XHRExampleHeaders = require('./XHRExampleHeaders');
var XHRExampleFetch = require('./XHRExampleFetch');
var XHRExampleOnTimeOut = require('./XHRExampleOnTimeOut');
var XHRExampleCookies = require('./XHRExampleCookies');
const XHRExampleDownload = require('./XHRExampleDownload');
const XHRExampleBinaryUpload = require('./XHRExampleBinaryUpload');
const XHRExampleFormData = require('./XHRExampleFormData');
const XHRExampleHeaders = require('./XHRExampleHeaders');
const XHRExampleFetch = require('./XHRExampleFetch');
const XHRExampleOnTimeOut = require('./XHRExampleOnTimeOut');
const XHRExampleCookies = require('./XHRExampleCookies');

exports.framework = 'React';
exports.title = 'XMLHttpRequest';
Expand Down
6 changes: 3 additions & 3 deletions js/XHRExampleBinaryUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ class XHRExampleBinaryUpload extends React.Component<{}, $FlowFixMeState> {
Alert.alert('Upload failed', 'No response payload.');
return;
}
var index = xhr.responseText.indexOf('http://www.posttestserver.com/');
const index = xhr.responseText.indexOf('http://www.posttestserver.com/');
if (index === -1) {
Alert.alert('Upload failed', 'Invalid response payload.');
return;
}
var url = xhr.responseText.slice(index).split('\n')[0];
const url = xhr.responseText.slice(index).split('\n')[0];
console.log('Upload successful: ' + url);
Linking.openURL(url);
}
Expand All @@ -77,7 +77,7 @@ class XHRExampleBinaryUpload extends React.Component<{}, $FlowFixMeState> {
};

_upload = () => {
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open('POST', 'http://posttestserver.com/post.php');
xhr.onload = () => XHRExampleBinaryUpload.handlePostTestServerUpload(xhr);
xhr.setRequestHeader('Content-Type', 'text/plain');
Expand Down
14 changes: 7 additions & 7 deletions js/XHRExampleCookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {StyleSheet, Text, TouchableHighlight, View, WebView} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, Text, TouchableHighlight, View, WebView} = ReactNative;

var RCTNetworking = require('RCTNetworking');
const RCTNetworking = require('RCTNetworking');

class XHRExampleCookies extends React.Component<any, any> {
cancelled: boolean;
Expand All @@ -30,8 +30,8 @@ class XHRExampleCookies extends React.Component<any, any> {
}

setCookie(domain: string) {
var {a, b} = this.state;
var url = `https://${domain}/cookies/set?a=${a}&b=${b}`;
const {a, b} = this.state;
const url = `https://${domain}/cookies/set?a=${a}&b=${b}`;
fetch(url).then(response => {
this.setStatus(`Cookies a=${a}, b=${b} set`);
this.refreshWebview();
Expand Down Expand Up @@ -130,7 +130,7 @@ class XHRExampleCookies extends React.Component<any, any> {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
wrapper: {
borderRadius: 5,
marginBottom: 5,
Expand Down
24 changes: 12 additions & 12 deletions js/XHRExampleFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {StyleSheet, Text, TextInput, View, Platform} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, Text, TextInput, View, Platform} = ReactNative;

class XHRExampleFetch extends React.Component<any, any> {
responseURL: ?string;
Expand Down Expand Up @@ -44,11 +44,11 @@ class XHRExampleFetch extends React.Component<any, any> {
return null;
}

var responseHeaders = [];
var keys = Object.keys(this.responseHeaders.map);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = this.responseHeaders.get(key);
const responseHeaders = [];
const keys = Object.keys(this.responseHeaders.map);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const value = this.responseHeaders.get(key);
responseHeaders.push(
<Text>
{key}: {value}
Expand All @@ -59,21 +59,21 @@ class XHRExampleFetch extends React.Component<any, any> {
}

render() {
var responseURL = this.responseURL ? (
const responseURL = this.responseURL ? (
<View style={{marginTop: 10}}>
<Text style={styles.label}>Server response URL:</Text>
<Text>{this.responseURL}</Text>
</View>
) : null;

var responseHeaders = this.responseHeaders ? (
const responseHeaders = this.responseHeaders ? (
<View style={{marginTop: 10}}>
<Text style={styles.label}>Server response headers:</Text>
{this._renderHeaders()}
</View>
) : null;

var response = this.state.responseText ? (
const response = this.state.responseText ? (
<View style={{marginTop: 10}}>
<Text style={styles.label}>Server response:</Text>
<TextInput
Expand Down Expand Up @@ -104,7 +104,7 @@ class XHRExampleFetch extends React.Component<any, any> {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
textInput: {
flex: 1,
borderRadius: 3,
Expand Down
Loading

0 comments on commit 83986b4

Please sign in to comment.