Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove var in RNTester #22015

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions RNTester/js/TextInputExample.android.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 {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;

class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
state = {
Expand Down Expand Up @@ -80,9 +80,9 @@ class RewriteExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> {
this.state = {text: ''};
}
render() {
var limit = 20;
var remainder = limit - this.state.text.length;
var remainderColor = remainder > 5 ? 'blue' : 'red';
const limit = 20;
const remainder = limit - this.state.text.length;
const remainderColor = remainder > 5 ? 'blue' : 'red';
return (
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
* when making Flow check .android.js files. */
Expand Down Expand Up @@ -273,7 +273,7 @@ class SelectionExample extends React.Component<
}

getRandomPosition() {
var length = this.state.value.length;
const length = this.state.value.length;
return Math.round(Math.random() * length);
}

Expand All @@ -283,7 +283,10 @@ class SelectionExample extends React.Component<
}

selectRandom() {
var positions = [this.getRandomPosition(), this.getRandomPosition()].sort();
const positions = [
this.getRandomPosition(),
this.getRandomPosition(),
].sort();
this.select(...positions);
}

Expand All @@ -296,7 +299,7 @@ class SelectionExample extends React.Component<
}

render() {
var length = this.state.value.length;
const length = this.state.value.length;

return (
<View>
Expand Down Expand Up @@ -358,7 +361,7 @@ class AutogrowingTextInputExample extends React.Component<{}> {
render() {
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
* when making Flow check .android.js files. */
var {style, multiline, ...props} = this.props;
const {style, multiline, ...props} = this.props;
return (
<View>
<Text>Width:</Text>
Expand Down Expand Up @@ -410,7 +413,7 @@ class AutogrowingTextInputExample extends React.Component<{}> {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
multiline: {
height: 60,
fontSize: 16,
Expand Down Expand Up @@ -458,8 +461,8 @@ exports.examples = [
{
title: 'Auto-capitalize',
render: function() {
var autoCapitalizeTypes = ['none', 'sentences', 'words', 'characters'];
var examples = autoCapitalizeTypes.map(type => {
const autoCapitalizeTypes = ['none', 'sentences', 'words', 'characters'];
const examples = autoCapitalizeTypes.map(type => {
return (
<TextInput
key={type}
Expand Down Expand Up @@ -494,8 +497,13 @@ exports.examples = [
{
title: 'Keyboard types',
render: function() {
var keyboardTypes = ['default', 'email-address', 'numeric', 'phone-pad'];
var examples = keyboardTypes.map(type => {
const keyboardTypes = [
'default',
'email-address',
'numeric',
'phone-pad',
];
const examples = keyboardTypes.map(type => {
return (
<TextInput
key={type}
Expand Down Expand Up @@ -763,7 +771,7 @@ exports.examples = [
{
title: 'Return key',
render: function() {
var returnKeyTypes = [
const returnKeyTypes = [
'none',
'go',
'search',
Expand All @@ -772,8 +780,8 @@ exports.examples = [
'previous',
'next',
];
var returnKeyLabels = ['Compile', 'React Native'];
var examples = returnKeyTypes.map(type => {
const returnKeyLabels = ['Compile', 'React Native'];
const examples = returnKeyTypes.map(type => {
return (
<TextInput
key={type}
Expand All @@ -783,7 +791,7 @@ exports.examples = [
/>
);
});
var types = returnKeyLabels.map(type => {
const types = returnKeyLabels.map(type => {
return (
<TextInput
key={type}
Expand Down
34 changes: 17 additions & 17 deletions RNTester/js/TextInputExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

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;
const React = require('react');
const ReactNative = require('react-native');
const {Text, TextInput, View, StyleSheet, Slider, Switch} = ReactNative;

class WithLabel extends React.Component<$FlowFixMeProps> {
render() {
Expand Down Expand Up @@ -126,9 +126,9 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> {
this.state = {text: ''};
}
render() {
var limit = 20;
var remainder = limit - this.state.text.length;
var remainderColor = remainder > 5 ? 'blue' : 'red';
const limit = 20;
const remainder = limit - this.state.text.length;
const remainderColor = remainder > 5 ? 'blue' : 'red';
return (
<View style={styles.rewriteContainer}>
<TextInput
Expand Down Expand Up @@ -356,7 +356,7 @@ class SelectionExample extends React.Component<
}

getRandomPosition() {
var length = this.state.value.length;
const length = this.state.value.length;
return Math.round(Math.random() * length);
}

Expand All @@ -366,7 +366,7 @@ class SelectionExample extends React.Component<
}

selectRandom() {
var positions = [this.getRandomPosition(), this.getRandomPosition()].sort(
const positions = [this.getRandomPosition(), this.getRandomPosition()].sort(
(a, b) => a - b,
);
this.select(...positions);
Expand All @@ -381,7 +381,7 @@ class SelectionExample extends React.Component<
}

render() {
var length = this.state.value.length;
const length = this.state.value.length;

return (
<View>
Expand Down Expand Up @@ -436,7 +436,7 @@ class AutogrowingTextInputExample extends React.Component<
}

render() {
var {style, multiline, ...props} = this.props;
const {style, multiline, ...props} = this.props;
return (
<View>
<Text>Width:</Text>
Expand Down Expand Up @@ -471,7 +471,7 @@ class AutogrowingTextInputExample extends React.Component<
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
page: {
paddingBottom: 300,
},
Expand Down Expand Up @@ -643,7 +643,7 @@ exports.examples = [
{
title: 'Keyboard types',
render: function() {
var keyboardTypes = [
const keyboardTypes = [
'default',
'ascii-capable',
'numbers-and-punctuation',
Expand All @@ -657,7 +657,7 @@ exports.examples = [
'web-search',
'numeric',
];
var examples = keyboardTypes.map(type => {
const examples = keyboardTypes.map(type => {
return (
<WithLabel key={type} label={type}>
<TextInput keyboardType={type} style={styles.default} />
Expand All @@ -670,8 +670,8 @@ exports.examples = [
{
title: 'Keyboard appearance',
render: function() {
var keyboardAppearance = ['default', 'light', 'dark'];
var examples = keyboardAppearance.map(type => {
const keyboardAppearance = ['default', 'light', 'dark'];
const examples = keyboardAppearance.map(type => {
return (
<WithLabel key={type} label={type}>
<TextInput keyboardAppearance={type} style={styles.default} />
Expand All @@ -684,7 +684,7 @@ exports.examples = [
{
title: 'Return key types',
render: function() {
var returnKeyTypes = [
const returnKeyTypes = [
'default',
'go',
'google',
Expand All @@ -697,7 +697,7 @@ exports.examples = [
'done',
'emergency-call',
];
var examples = returnKeyTypes.map(type => {
const examples = returnKeyTypes.map(type => {
return (
<WithLabel key={type} label={type}>
<TextInput returnKeyType={type} style={styles.default} />
Expand Down
14 changes: 7 additions & 7 deletions RNTester/js/TimePickerAndroidExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
const React = require('react');
const ReactNative = require('react-native');
const {
TimePickerAndroid,
StyleSheet,
Text,
TouchableWithoutFeedback,
} = ReactNative;

var RNTesterBlock = require('./RNTesterBlock');
var RNTesterPage = require('./RNTesterPage');
const RNTesterBlock = require('./RNTesterBlock');
const RNTesterPage = require('./RNTesterPage');

class TimePickerAndroidExample extends React.Component {
static title = 'TimePickerAndroid';
Expand All @@ -39,7 +39,7 @@ class TimePickerAndroidExample extends React.Component {
showPicker = async (stateKey, options) => {
try {
const {action, minute, hour} = await TimePickerAndroid.open(options);
var newState = {};
const newState = {};
if (action === TimePickerAndroid.timeSetAction) {
newState[stateKey + 'Text'] = _formatTime(hour, minute);
newState[stateKey + 'Hour'] = hour;
Expand Down Expand Up @@ -111,7 +111,7 @@ function _formatTime(hour, minute) {
return hour + ':' + (minute < 10 ? '0' + minute : minute);
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
text: {
color: 'black',
},
Expand Down
21 changes: 11 additions & 10 deletions RNTester/js/TimerExample.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 {AlertIOS, Platform, ToastAndroid, Text, View} = ReactNative;
var RNTesterButton = require('./RNTesterButton');
var performanceNow = require('fbjs/lib/performanceNow');
const React = require('react');
const ReactNative = require('react-native');
const {AlertIOS, Platform, ToastAndroid, Text, View} = ReactNative;
const RNTesterButton = require('./RNTesterButton');
const performanceNow = require('fbjs/lib/performanceNow');

function burnCPU(milliseconds) {
const start = performanceNow();
Expand Down Expand Up @@ -153,7 +153,8 @@ class TimerTester extends React.Component<TimerTesterProps> {
_timerFn: ?() => any = null;

render() {
var args = 'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : '');
const args =
'fn' + (this.props.dt !== undefined ? ', ' + this.props.dt : '');
return (
<RNTesterButton onPress={this._run}>
Measure: {this.props.type}({args}) - {this._ii || 0}
Expand Down Expand Up @@ -185,7 +186,7 @@ class TimerTester extends React.Component<TimerTesterProps> {

_run = () => {
if (!this._start) {
var d = new Date();
const d = new Date();
this._start = d.getTime();
this._iters = 100;
this._ii = 0;
Expand Down Expand Up @@ -214,9 +215,9 @@ class TimerTester extends React.Component<TimerTesterProps> {
}
}
if (this._ii >= this._iters && this._intervalId == null) {
var d = new Date();
var e = d.getTime() - this._start;
var msg =
const d = new Date();
const e = d.getTime() - this._start;
const msg =
'Finished ' +
this._ii +
' ' +
Expand Down
12 changes: 6 additions & 6 deletions RNTester/js/ToastAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {StyleSheet, Text, ToastAndroid, TouchableWithoutFeedback} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, Text, ToastAndroid, TouchableWithoutFeedback} = ReactNative;

var RNTesterBlock = require('RNTesterBlock');
var RNTesterPage = require('RNTesterPage');
const RNTesterBlock = require('RNTesterBlock');
const RNTesterPage = require('RNTesterPage');

class ToastExample extends React.Component<{}, $FlowFixMeState> {
static title = 'Toast Example';
Expand Down Expand Up @@ -117,7 +117,7 @@ class ToastExample extends React.Component<{}, $FlowFixMeState> {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
text: {
color: 'black',
},
Expand Down
Loading