Converting Libraries/Components to not use var

Reviewed By: sahrens

Differential Revision: D7117137

fbshipit-source-id: a55a04928a0073a17e0709e851aa8b11678042ba
This commit is contained in:
Eli White
2018-03-03 15:04:46 -08:00
committed by Facebook Github Bot
parent f7343576fc
commit 3152e93095
43 changed files with 471 additions and 471 deletions

View File

@@ -10,27 +10,27 @@
'use strict';
var ColorPropType = require('ColorPropType');
var PickerIOS = require('PickerIOS');
var PickerAndroid = require('PickerAndroid');
var Platform = require('Platform');
var React = require('React');
const ColorPropType = require('ColorPropType');
const PickerIOS = require('PickerIOS');
const PickerAndroid = require('PickerAndroid');
const Platform = require('Platform');
const React = require('React');
const PropTypes = require('prop-types');
var StyleSheetPropType = require('StyleSheetPropType');
var TextStylePropTypes = require('TextStylePropTypes');
var UnimplementedView = require('UnimplementedView');
const StyleSheetPropType = require('StyleSheetPropType');
const TextStylePropTypes = require('TextStylePropTypes');
const UnimplementedView = require('UnimplementedView');
const ViewPropTypes = require('ViewPropTypes');
var ViewStylePropTypes = require('ViewStylePropTypes');
const ViewStylePropTypes = require('ViewStylePropTypes');
var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
var pickerStyleType = StyleSheetPropType({
const pickerStyleType = StyleSheetPropType({
...ViewStylePropTypes,
color: ColorPropType,
});
var MODE_DIALOG = 'dialog';
var MODE_DROPDOWN = 'dropdown';
const MODE_DIALOG = 'dialog';
const MODE_DROPDOWN = 'dropdown';
/**
* Individual selectable item in a Picker.

View File

@@ -10,21 +10,21 @@
'use strict';
var ColorPropType = require('ColorPropType');
var React = require('React');
var ReactPropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
const ColorPropType = require('ColorPropType');
const React = require('React');
const ReactPropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
const StyleSheetPropType = require('StyleSheetPropType');
const ViewPropTypes = require('ViewPropTypes');
var ViewStylePropTypes = require('ViewStylePropTypes');
const ViewStylePropTypes = require('ViewStylePropTypes');
var processColor = require('processColor');
var requireNativeComponent = require('requireNativeComponent');
const processColor = require('processColor');
const requireNativeComponent = require('requireNativeComponent');
var REF_PICKER = 'picker';
var MODE_DROPDOWN = 'dropdown';
const REF_PICKER = 'picker';
const MODE_DROPDOWN = 'dropdown';
var pickerStyleType = StyleSheetPropType({
const pickerStyleType = StyleSheetPropType({
...ViewStylePropTypes,
color: ColorPropType,
});
@@ -56,7 +56,7 @@ class PickerAndroid extends React.Component<{
constructor(props, context) {
super(props, context);
var state = this._stateFromProps(props);
const state = this._stateFromProps(props);
this.state = {
...state,
@@ -70,7 +70,7 @@ class PickerAndroid extends React.Component<{
// Translate prop and children into stuff that the native picker understands.
_stateFromProps = (props) => {
var selectedIndex = 0;
let selectedIndex = 0;
const items = React.Children.map(props.children, (child, index) => {
if (child.props.value === props.selectedValue) {
selectedIndex = index;
@@ -88,9 +88,9 @@ class PickerAndroid extends React.Component<{
};
render() {
var Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker;
const Picker = this.props.mode === MODE_DROPDOWN ? DropdownPicker : DialogPicker;
var nativeProps = {
const nativeProps = {
enabled: this.props.enabled,
items: this.state.items,
mode: this.props.mode,
@@ -107,10 +107,10 @@ class PickerAndroid extends React.Component<{
_onChange = (event: Event) => {
if (this.props.onValueChange) {
var position = event.nativeEvent.position;
const position = event.nativeEvent.position;
if (position >= 0) {
var children = React.Children.toArray(this.props.children);
var value = children[position].props.value;
const children = React.Children.toArray(this.props.children);
const value = children[position].props.value;
this.props.onValueChange(value, position);
} else {
this.props.onValueChange(null, position);
@@ -138,7 +138,7 @@ class PickerAndroid extends React.Component<{
}
}
var styles = StyleSheet.create({
const styles = StyleSheet.create({
pickerAndroid: {
// The picker will conform to whatever width is given, but we do
// have to set the component's height explicitly on the
@@ -149,14 +149,14 @@ var styles = StyleSheet.create({
},
});
var cfg = {
const cfg = {
nativeOnly: {
items: true,
selected: true,
}
};
var DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg);
var DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg);
const DropdownPicker = requireNativeComponent('AndroidDropdownPicker', PickerAndroid, cfg);
const DialogPicker = requireNativeComponent('AndroidDialogPicker', PickerAndroid, cfg);
module.exports = PickerAndroid;

View File

@@ -10,21 +10,21 @@
*/
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
const NativeMethodsMixin = require('NativeMethodsMixin');
const React = require('React');
const PropTypes = require('prop-types');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var TextStylePropTypes = require('TextStylePropTypes');
var View = require('View');
const StyleSheet = require('StyleSheet');
const StyleSheetPropType = require('StyleSheetPropType');
const TextStylePropTypes = require('TextStylePropTypes');
const View = require('View');
const ViewPropTypes = require('ViewPropTypes');
var processColor = require('processColor');
const processColor = require('processColor');
var createReactClass = require('create-react-class');
var itemStylePropType = StyleSheetPropType(TextStylePropTypes);
var requireNativeComponent = require('requireNativeComponent');
const createReactClass = require('create-react-class');
const itemStylePropType = StyleSheetPropType(TextStylePropTypes);
const requireNativeComponent = require('requireNativeComponent');
var PickerIOS = createReactClass({
const PickerIOS = createReactClass({
displayName: 'PickerIOS',
mixins: [NativeMethodsMixin],
@@ -45,8 +45,8 @@ var PickerIOS = createReactClass({
// Translate PickerIOS prop and children into stuff that RCTPickerIOS understands.
_stateFromProps: function(props) {
var selectedIndex = 0;
var items = [];
let selectedIndex = 0;
const items = [];
React.Children.toArray(props.children).forEach(function (child, index) {
if (child.props.value === props.selectedValue) {
selectedIndex = index;
@@ -111,7 +111,7 @@ PickerIOS.Item = class extends React.Component {
}
};
var styles = StyleSheet.create({
const styles = StyleSheet.create({
pickerIOS: {
// The picker will conform to whatever width is given, but we do
// have to set the component's height explicitly on the
@@ -120,7 +120,7 @@ var styles = StyleSheet.create({
},
});
var RCTPickerIOS = requireNativeComponent('RCTPicker', {
const RCTPickerIOS = requireNativeComponent('RCTPicker', {
propTypes: {
style: itemStylePropType,
},