From 3152e930955b6440edf14fe9c5d246181bc22a55 Mon Sep 17 00:00:00 2001 From: Eli White Date: Sat, 3 Mar 2018 15:04:46 -0800 Subject: [PATCH] Converting Libraries/Components to not use var Reviewed By: sahrens Differential Revision: D7117137 fbshipit-source-id: a55a04928a0073a17e0709e851aa8b11678042ba --- .../AccessibilityInfo.android.js | 16 +-- .../AccessibilityInfo.ios.js | 20 ++-- .../Components/AppleTV/TVViewPropTypes.js | 4 +- .../DatePicker/DatePickerIOS.android.js | 10 +- .../DrawerLayoutAndroid.android.js | 48 ++++----- Libraries/Components/LazyRenderer.js | 10 +- .../Components/Navigation/NavigatorIOS.ios.js | 76 ++++++------- Libraries/Components/Picker/Picker.js | 26 ++--- .../Picker/PickerAndroid.android.js | 44 ++++---- Libraries/Components/Picker/PickerIOS.ios.js | 30 +++--- .../ProgressViewIOS.android.js | 10 +- .../ProgressViewIOS/ProgressViewIOS.ios.js | 22 ++-- .../SegmentedControlIOS.android.js | 10 +- .../SegmentedControlIOS.ios.js | 22 ++-- Libraries/Components/Slider/Slider.js | 24 ++--- Libraries/Components/StaticRenderer.js | 4 +- Libraries/Components/Subscribable.js | 2 +- Libraries/Components/Switch/Switch.js | 20 ++-- .../Components/TabBarIOS/TabBarIOS.ios.js | 14 +-- .../TabBarIOS/TabBarItemIOS.android.js | 8 +- .../Components/TabBarIOS/TabBarItemIOS.ios.js | 20 ++-- Libraries/Components/TextInput/TextInput.js | 20 ++-- .../Components/TextInput/TextInputState.js | 6 +- .../ToastAndroid/ToastAndroid.android.js | 4 +- .../ToastAndroid/ToastAndroid.ios.js | 4 +- .../ToolbarAndroid/ToolbarAndroid.android.js | 38 +++---- .../Touchable/BoundingDimensions.js | 4 +- Libraries/Components/Touchable/PooledClass.js | 40 +++---- Libraries/Components/Touchable/Position.js | 4 +- Libraries/Components/Touchable/Touchable.js | 100 +++++++++--------- .../Components/Touchable/TouchableBounce.js | 20 ++-- .../TouchableNativeFeedback.android.js | 32 +++--- .../Touchable/TouchableNativeFeedback.ios.js | 10 +- .../Components/Touchable/TouchableOpacity.js | 28 ++--- .../Touchable/ensureComponentIsNative.js | 4 +- .../Touchable/ensurePositiveDelayProps.js | 4 +- .../View/PlatformViewPropTypes.ios.js | 2 +- .../View/ReactNativeStyleAttributes.js | 18 ++-- .../View/ReactNativeViewAttributes.js | 4 +- .../Components/View/ViewStylePropTypes.js | 12 +-- .../ViewPager/ViewPagerAndroid.android.js | 20 ++-- .../Components/WebView/WebView.android.js | 54 +++++----- Libraries/Components/WebView/WebView.ios.js | 74 ++++++------- 43 files changed, 471 insertions(+), 471 deletions(-) diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js index b08593a06..afc4abe15 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js @@ -9,18 +9,18 @@ */ 'use strict'; -var NativeModules = require('NativeModules'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +const NativeModules = require('NativeModules'); +const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTAccessibilityInfo = NativeModules.AccessibilityInfo; +const RCTAccessibilityInfo = NativeModules.AccessibilityInfo; -var TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange'; +const TOUCH_EXPLORATION_EVENT = 'touchExplorationDidChange'; type ChangeEventName = $Enum<{ change: string, }>; -var _subscriptions = new Map(); +const _subscriptions = new Map(); /** * Sometimes it's useful to know whether or not the device has a screen reader @@ -32,7 +32,7 @@ var _subscriptions = new Map(); * See http://facebook.github.io/react-native/docs/accessibilityinfo.html */ -var AccessibilityInfo = { +const AccessibilityInfo = { fetch: function(): Promise { return new Promise((resolve, reject) => { @@ -48,7 +48,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): void { - var listener = RCTDeviceEventEmitter.addListener( + const listener = RCTDeviceEventEmitter.addListener( TOUCH_EXPLORATION_EVENT, (enabled) => { handler(enabled); @@ -61,7 +61,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): void { - var listener = _subscriptions.get(handler); + const listener = _subscriptions.get(handler); if (!listener) { return; } diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index 822f0dcba..6e39b5e47 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -9,21 +9,21 @@ */ 'use strict'; -var NativeModules = require('NativeModules'); -var Promise = require('Promise'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +const NativeModules = require('NativeModules'); +const Promise = require('Promise'); +const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var AccessibilityManager = NativeModules.AccessibilityManager; +const AccessibilityManager = NativeModules.AccessibilityManager; -var VOICE_OVER_EVENT = 'voiceOverDidChange'; -var ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish'; +const VOICE_OVER_EVENT = 'voiceOverDidChange'; +const ANNOUNCEMENT_DID_FINISH_EVENT = 'announcementDidFinish'; type ChangeEventName = $Enum<{ change: string, announcementFinished: string }>; -var _subscriptions = new Map(); +const _subscriptions = new Map(); /** * Sometimes it's useful to know whether or not the device has a screen reader @@ -34,7 +34,7 @@ var _subscriptions = new Map(); * * See http://facebook.github.io/react-native/docs/accessibilityinfo.html */ -var AccessibilityInfo = { +const AccessibilityInfo = { /** * Query whether a screen reader is currently enabled. @@ -72,7 +72,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): Object { - var listener; + let listener; if (eventName === 'change') { listener = RCTDeviceEventEmitter.addListener( @@ -127,7 +127,7 @@ var AccessibilityInfo = { eventName: ChangeEventName, handler: Function ): void { - var listener = _subscriptions.get(handler); + const listener = _subscriptions.get(handler); if (!listener) { return; } diff --git a/Libraries/Components/AppleTV/TVViewPropTypes.js b/Libraries/Components/AppleTV/TVViewPropTypes.js index fab7a30b8..90b86aa47 100644 --- a/Libraries/Components/AppleTV/TVViewPropTypes.js +++ b/Libraries/Components/AppleTV/TVViewPropTypes.js @@ -8,12 +8,12 @@ * @flow */ 'use strict'; -var PropTypes = require('prop-types'); +const PropTypes = require('prop-types'); /** * Additional View properties for Apple TV */ -var TVViewPropTypes = { +const TVViewPropTypes = { /** * *(Apple TV only)* When set to true, this view will be focusable * and navigable using the Apple TV remote. diff --git a/Libraries/Components/DatePicker/DatePickerIOS.android.js b/Libraries/Components/DatePicker/DatePickerIOS.android.js index 8a1db045e..2a0d8998b 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.android.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.android.js @@ -9,10 +9,10 @@ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummyDatePickerIOS extends React.Component { render() { @@ -24,7 +24,7 @@ class DummyDatePickerIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummyDatePickerIOS: { height: 100, width: 300, diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 3a39a7d02..6a20d894f 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -8,28 +8,28 @@ */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var StatusBar = require('StatusBar'); -var StyleSheet = require('StyleSheet'); -var UIManager = require('UIManager'); -var View = require('View'); -var ViewPropTypes = require('ViewPropTypes'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const Platform = require('Platform'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const StatusBar = require('StatusBar'); +const StyleSheet = require('StyleSheet'); +const UIManager = require('UIManager'); +const View = require('View'); +const ViewPropTypes = require('ViewPropTypes'); -var DrawerConsts = UIManager.AndroidDrawerLayout.Constants; +const DrawerConsts = UIManager.AndroidDrawerLayout.Constants; -var createReactClass = require('create-react-class'); -var dismissKeyboard = require('dismissKeyboard'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const dismissKeyboard = require('dismissKeyboard'); +const requireNativeComponent = require('requireNativeComponent'); -var RK_DRAWER_REF = 'drawerlayout'; -var INNERVIEW_REF = 'innerView'; +const RK_DRAWER_REF = 'drawerlayout'; +const INNERVIEW_REF = 'innerView'; -var DRAWER_STATES = [ +const DRAWER_STATES = [ 'Idle', 'Dragging', 'Settling', @@ -66,7 +66,7 @@ var DRAWER_STATES = [ * }, * ``` */ -var DrawerLayoutAndroid = createReactClass({ +const DrawerLayoutAndroid = createReactClass({ displayName: 'DrawerLayoutAndroid', statics: { positions: DrawerConsts.DrawerPosition, @@ -169,8 +169,8 @@ var DrawerLayoutAndroid = createReactClass({ }, render: function() { - var drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor; - var drawerViewWrapper = + const drawStatusBar = Platform.Version >= 21 && this.props.statusBarBackgroundColor; + const drawerViewWrapper = } ; - var childrenWrapper = + const childrenWrapper = {drawStatusBar && =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. */ const keyMirror = require('fbjs/lib/keyMirror'); -var TRANSITIONER_REF = 'transitionerRef'; +const TRANSITIONER_REF = 'transitionerRef'; -var __uid = 0; +let __uid = 0; function getuid() { return __uid++; } @@ -305,7 +305,7 @@ type Event = Object; * is pushed. * */ -var NavigatorIOS = createReactClass({ +const NavigatorIOS = createReactClass({ displayName: 'NavigatorIOS', propTypes: { @@ -584,7 +584,7 @@ var NavigatorIOS = createReactClass({ _getFocusEmitter: function(): EventEmitter { // Flow not yet tracking assignments to instance fields. - var focusEmitter = this._focusEmitter; + let focusEmitter = this._focusEmitter; if (!focusEmitter) { focusEmitter = new EventEmitter(); this._focusEmitter = focusEmitter; @@ -614,13 +614,13 @@ var NavigatorIOS = createReactClass({ }, _handleNavigatorStackChanged: function(e: Event) { - var newObservedTopOfStack = e.nativeEvent.stackLength - 1; + const newObservedTopOfStack = e.nativeEvent.stackLength - 1; invariant( newObservedTopOfStack <= this.state.requestedTopOfStack, 'No navigator item should be pushed without JS knowing about it %s %s', newObservedTopOfStack, this.state.requestedTopOfStack ); - var wasWaitingForConfirmation = + const wasWaitingForConfirmation = this.state.requestedTopOfStack !== this.state.observedTopOfStack; if (wasWaitingForConfirmation) { invariant( @@ -638,7 +638,7 @@ var NavigatorIOS = createReactClass({ // Progress isn't always 0 or 1 at the end, the system rounds // If the Navigator is offscreen these values won't be updated // TOOD: Revisit this decision when no longer relying on native navigator. - var nextState = { + const nextState = { observedTopOfStack: newObservedTopOfStack, makingNavigatorRequest: false, updatingAllIndicesAtOrBeyond: null, @@ -653,7 +653,7 @@ var NavigatorIOS = createReactClass({ // Updating the indices that we're deleting and that's all. (Truth: Nothing // even uses the indices in this case, but let's make this describe the // truth anyways). - var updatingAllIndicesAtOrBeyond = + const updatingAllIndicesAtOrBeyond = this.state.routeStack.length > this.state.observedTopOfStack + 1 ? this.state.observedTopOfStack + 1 : null; @@ -677,8 +677,8 @@ var NavigatorIOS = createReactClass({ if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { this._tryLockNavigator(() => { - var nextStack = this.state.routeStack.concat([route]); - var nextIDStack = this.state.idStack.concat([getuid()]); + const nextStack = this.state.routeStack.concat([route]); + const nextIDStack = this.state.idStack.concat([getuid()]); this.setState({ // We have to make sure that we've also supplied enough views to // satisfy our request to adjust the `requestedTopOfStack`. @@ -704,7 +704,7 @@ var NavigatorIOS = createReactClass({ if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { if (this.state.requestedTopOfStack > 0) { this._tryLockNavigator(() => { - var newRequestedTopOfStack = this.state.requestedTopOfStack - n; + const newRequestedTopOfStack = this.state.requestedTopOfStack - n; invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0'); this.setState({ requestedTopOfStack: newRequestedTopOfStack, @@ -742,8 +742,8 @@ var NavigatorIOS = createReactClass({ // I don't believe we need to lock for a replace since there's no // navigation actually happening - var nextIDStack = this.state.idStack.slice(); - var nextRouteStack = this.state.routeStack.slice(); + const nextIDStack = this.state.idStack.slice(); + const nextRouteStack = this.state.routeStack.slice(); nextIDStack[index] = getuid(); nextRouteStack[index] = route; @@ -785,12 +785,12 @@ var NavigatorIOS = createReactClass({ * @param route The new route to navigate to. */ popToRoute: function(route: Route) { - var indexOfRoute = this.state.routeStack.indexOf(route); + const indexOfRoute = this.state.routeStack.indexOf(route); invariant( indexOfRoute !== -1, 'Calling pop to route for a route that doesn\'t exist!' ); - var numToPop = this.state.routeStack.length - indexOfRoute - 1; + const numToPop = this.state.routeStack.length - indexOfRoute - 1; this.popN(numToPop); }, @@ -841,12 +841,12 @@ var NavigatorIOS = createReactClass({ }, _routeToStackItem: function(routeArg: Route, i: number) { - var {component, wrapperStyle, passProps, ...route} = routeArg; - var {itemWrapperStyle, ...props} = this.props; - var shouldUpdateChild = + const {component, wrapperStyle, passProps, ...route} = routeArg; + const {itemWrapperStyle, ...props} = this.props; + const shouldUpdateChild = this.state.updatingAllIndicesAtOrBeyond != null && this.state.updatingAllIndicesAtOrBeyond >= i; - var Component = component; + const Component = component; return ( @@ -919,7 +919,7 @@ var NavigatorIOS = createReactClass({ }, }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ stackItem: { backgroundColor: 'white', overflow: 'hidden', @@ -934,7 +934,7 @@ var styles = StyleSheet.create({ }, }); -var RCTNavigator = requireNativeComponent('RCTNavigator'); -var RCTNavigatorItem = requireNativeComponent('RCTNavItem'); +const RCTNavigator = requireNativeComponent('RCTNavigator'); +const RCTNavigatorItem = requireNativeComponent('RCTNavItem'); module.exports = NavigatorIOS; diff --git a/Libraries/Components/Picker/Picker.js b/Libraries/Components/Picker/Picker.js index d4b225c8a..1df316249 100644 --- a/Libraries/Components/Picker/Picker.js +++ b/Libraries/Components/Picker/Picker.js @@ -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. diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index c164db953..bd9c664a8 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -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; diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 3963a9485..d1fe0761d 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -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, }, diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js index 46591f628..f467db1ff 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js @@ -10,10 +10,10 @@ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummyProgressViewIOS extends React.Component { render() { @@ -27,7 +27,7 @@ class DummyProgressViewIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummy: { width: 120, height: 20, diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js index 310f02507..55ae1b83a 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js @@ -9,20 +9,20 @@ */ 'use strict'; -var Image = require('Image'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const Image = require('Image'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); /** * Use `ProgressViewIOS` to render a UIProgressView on iOS. */ -var ProgressViewIOS = createReactClass({ +const ProgressViewIOS = createReactClass({ displayName: 'ProgressViewIOS', mixins: [NativeMethodsMixin], @@ -69,13 +69,13 @@ var ProgressViewIOS = createReactClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ progressView: { height: 2, }, }); -var RCTProgressView = requireNativeComponent( +const RCTProgressView = requireNativeComponent( 'RCTProgressView', ProgressViewIOS ); diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js index 16be1c8f2..a5b4c0b33 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js @@ -10,10 +10,10 @@ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummySegmentedControlIOS extends React.Component { render() { @@ -27,7 +27,7 @@ class DummySegmentedControlIOS extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ dummy: { width: 120, height: 50, diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js index f7748fcc8..3eb4249fa 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js @@ -9,21 +9,21 @@ */ 'use strict'; -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type DefaultProps = { values: Array, enabled: boolean, }; -var SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol'; +const SEGMENTED_CONTROL_REFERENCE = 'segmentedcontrol'; type Event = Object; @@ -47,7 +47,7 @@ type Event = Object; * /> * ```` */ -var SegmentedControlIOS = createReactClass({ +const SegmentedControlIOS = createReactClass({ displayName: 'SegmentedControlIOS', mixins: [NativeMethodsMixin], @@ -117,13 +117,13 @@ var SegmentedControlIOS = createReactClass({ } }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ segmentedControl: { height: 28, }, }); -var RCTSegmentedControl = requireNativeComponent( +const RCTSegmentedControl = requireNativeComponent( 'RCTSegmentedControl', SegmentedControlIOS ); diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index 683789520..5a163fe17 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -9,18 +9,18 @@ */ 'use strict'; -var Image = require('Image'); -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var Platform = require('Platform'); -var React = require('React'); -var PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var ViewPropTypes = require('ViewPropTypes'); +const Image = require('Image'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); +const Platform = require('Platform'); +const React = require('React'); +const PropTypes = require('prop-types'); +const StyleSheet = require('StyleSheet'); +const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type Event = Object; @@ -84,7 +84,7 @@ type Event = Object; *``` * */ -var Slider = createReactClass({ +const Slider = createReactClass({ displayName: 'Slider', mixins: [NativeMethodsMixin], diff --git a/Libraries/Components/StaticRenderer.js b/Libraries/Components/StaticRenderer.js index d5474e943..777fe900e 100644 --- a/Libraries/Components/StaticRenderer.js +++ b/Libraries/Components/StaticRenderer.js @@ -9,9 +9,9 @@ */ 'use strict'; -var React = require('React'); +const React = require('React'); -var PropTypes = require('prop-types'); +const PropTypes = require('prop-types'); class StaticRenderer extends React.Component<{ shouldUpdate: boolean, diff --git a/Libraries/Components/Subscribable.js b/Libraries/Components/Subscribable.js index cc665ef98..6825acd02 100644 --- a/Libraries/Components/Subscribable.js +++ b/Libraries/Components/Subscribable.js @@ -19,7 +19,7 @@ import type EventEmitter from 'EventEmitter'; * React Core */ -var Subscribable = {}; +const Subscribable = {}; Subscribable.Mixin = { diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index 545b29b27..e88272dac 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -9,16 +9,16 @@ */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var React = require('React'); +const ColorPropType = require('ColorPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const Platform = require('Platform'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); +const StyleSheet = require('StyleSheet'); const ViewPropTypes = require('ViewPropTypes'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); type DefaultProps = { value: boolean, @@ -36,7 +36,7 @@ type DefaultProps = { * @keyword checkbox * @keyword toggle */ -var Switch = createReactClass({ +const Switch = createReactClass({ displayName: 'Switch', propTypes: { ...ViewPropTypes, @@ -98,7 +98,7 @@ var Switch = createReactClass({ }, render: function() { - var props = {...this.props}; + const props = {...this.props}; props.onStartShouldSetResponder = () => true; props.onResponderTerminationRequest = () => false; if (Platform.OS === 'android') { @@ -122,7 +122,7 @@ var Switch = createReactClass({ }, }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ rctSwitchIOS: { height: 31, width: 51, diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index 2e838b097..bfd180823 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -9,14 +9,14 @@ */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var React = require('React'); +const ColorPropType = require('ColorPropType'); +const React = require('React'); const PropTypes = require('prop-types'); -var StyleSheet = require('StyleSheet'); -var TabBarItemIOS = require('TabBarItemIOS'); +const StyleSheet = require('StyleSheet'); +const TabBarItemIOS = require('TabBarItemIOS'); const ViewPropTypes = require('ViewPropTypes'); -var requireNativeComponent = require('requireNativeComponent'); +const requireNativeComponent = require('requireNativeComponent'); import type {StyleObj} from 'StyleSheetTypes'; import type {ViewProps} from 'ViewPropTypes'; @@ -92,12 +92,12 @@ class TabBarIOS extends React.Component ); } else { - var children = props.children; - var childCount = 0; + let children = props.children; + let childCount = 0; React.Children.forEach(children, () => ++childCount); invariant( !(props.value && childCount), @@ -797,7 +797,7 @@ const TextInput = createReactClass({ }, _renderIOS: function() { - var props = Object.assign({}, this.props); + const props = Object.assign({}, this.props); props.style = [this.props.style]; if (props.selection && props.selection.end == null) { @@ -857,8 +857,8 @@ const TextInput = createReactClass({ /* $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. */ - var children = this.props.children; - var childCount = 0; + let children = this.props.children; + let childCount = 0; React.Children.forEach(children, () => ++childCount); invariant( !(this.props.value && childCount), @@ -932,7 +932,7 @@ const TextInput = createReactClass({ }); } - var text = event.nativeEvent.text; + const text = event.nativeEvent.text; this.props.onChange && this.props.onChange(event); this.props.onChangeText && this.props.onChangeText(text); @@ -1016,7 +1016,7 @@ const TextInput = createReactClass({ }, }); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ multilineInput: { // This default top inset makes RCTMultilineTextInputView seem as close as possible // to single-line RCTSinglelineTextInputView defaults, using the system defaults diff --git a/Libraries/Components/TextInput/TextInputState.js b/Libraries/Components/TextInput/TextInputState.js index 46524070f..afcca82bf 100644 --- a/Libraries/Components/TextInput/TextInputState.js +++ b/Libraries/Components/TextInput/TextInputState.js @@ -13,10 +13,10 @@ */ 'use strict'; -var Platform = require('Platform'); -var UIManager = require('UIManager'); +const Platform = require('Platform'); +const UIManager = require('UIManager'); -var TextInputState = { +const TextInputState = { /** * Internal state */ diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.android.js b/Libraries/Components/ToastAndroid/ToastAndroid.android.js index 543412666..15a8a597a 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.android.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.android.js @@ -10,7 +10,7 @@ 'use strict'; -var RCTToastAndroid = require('NativeModules').ToastAndroid; +const RCTToastAndroid = require('NativeModules').ToastAndroid; /** * This exposes the native ToastAndroid module as a JS module. This has a function 'show' @@ -33,7 +33,7 @@ var RCTToastAndroid = require('NativeModules').ToastAndroid; * ``` */ -var ToastAndroid = { +const ToastAndroid = { // Toast duration constants SHORT: RCTToastAndroid.SHORT, diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js index b44f812ec..83db0cfa8 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js @@ -9,9 +9,9 @@ */ 'use strict'; -var warning = require('fbjs/lib/warning'); +const warning = require('fbjs/lib/warning'); -var ToastAndroid = { +const ToastAndroid = { show: function ( message: string, diff --git a/Libraries/Components/ToolbarAndroid/ToolbarAndroid.android.js b/Libraries/Components/ToolbarAndroid/ToolbarAndroid.android.js index 941d14328..1d845e5b6 100644 --- a/Libraries/Components/ToolbarAndroid/ToolbarAndroid.android.js +++ b/Libraries/Components/ToolbarAndroid/ToolbarAndroid.android.js @@ -9,20 +9,20 @@ 'use strict'; -var Image = require('Image'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var UIManager = require('UIManager'); -var ViewPropTypes = require('ViewPropTypes'); -var ColorPropType = require('ColorPropType'); +const Image = require('Image'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); +const UIManager = require('UIManager'); +const ViewPropTypes = require('ViewPropTypes'); +const ColorPropType = require('ColorPropType'); -var createReactClass = require('create-react-class'); -var requireNativeComponent = require('requireNativeComponent'); -var resolveAssetSource = require('resolveAssetSource'); +const createReactClass = require('create-react-class'); +const requireNativeComponent = require('requireNativeComponent'); +const resolveAssetSource = require('resolveAssetSource'); -var optionalImageSource = PropTypes.oneOfType([ +const optionalImageSource = PropTypes.oneOfType([ Image.propTypes.source, // Image.propTypes.source is required but we want it to be optional, so we OR // it with a nullable propType. @@ -64,7 +64,7 @@ var optionalImageSource = PropTypes.oneOfType([ * * [0]: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html */ -var ToolbarAndroid = createReactClass({ +const ToolbarAndroid = createReactClass({ displayName: 'ToolbarAndroid', mixins: [NativeMethodsMixin], @@ -162,7 +162,7 @@ var ToolbarAndroid = createReactClass({ }, render: function() { - var nativeProps = { + const nativeProps = { ...this.props, }; if (this.props.logo) { @@ -175,9 +175,9 @@ var ToolbarAndroid = createReactClass({ nativeProps.overflowIcon = resolveAssetSource(this.props.overflowIcon); } if (this.props.actions) { - var nativeActions = []; - for (var i = 0; i < this.props.actions.length; i++) { - var action = { + const nativeActions = []; + for (let i = 0; i < this.props.actions.length; i++) { + const action = { ...this.props.actions[i], }; if (action.icon) { @@ -195,7 +195,7 @@ var ToolbarAndroid = createReactClass({ }, _onSelect: function(event) { - var position = event.nativeEvent.position; + const position = event.nativeEvent.position; if (position === -1) { this.props.onIconClicked && this.props.onIconClicked(); } else { @@ -204,7 +204,7 @@ var ToolbarAndroid = createReactClass({ }, }); -var NativeToolbar = requireNativeComponent('ToolbarAndroid', ToolbarAndroid, { +const NativeToolbar = requireNativeComponent('ToolbarAndroid', ToolbarAndroid, { nativeOnly: { nativeActions: true, } diff --git a/Libraries/Components/Touchable/BoundingDimensions.js b/Libraries/Components/Touchable/BoundingDimensions.js index 73e700ca3..9bc78e515 100644 --- a/Libraries/Components/Touchable/BoundingDimensions.js +++ b/Libraries/Components/Touchable/BoundingDimensions.js @@ -9,9 +9,9 @@ 'use strict'; -var PooledClass = require('PooledClass'); +const PooledClass = require('PooledClass'); -var twoArgumentPooler = PooledClass.twoArgumentPooler; +const twoArgumentPooler = PooledClass.twoArgumentPooler; /** * PooledClass representing the bounding rectangle of a region. diff --git a/Libraries/Components/Touchable/PooledClass.js b/Libraries/Components/Touchable/PooledClass.js index ad5d874ba..a3ae190aa 100644 --- a/Libraries/Components/Touchable/PooledClass.js +++ b/Libraries/Components/Touchable/PooledClass.js @@ -10,7 +10,7 @@ 'use strict'; -var invariant = require('fbjs/lib/invariant'); +const invariant = require('fbjs/lib/invariant'); /** * Static poolers. Several custom versions for each potential number of @@ -19,10 +19,10 @@ var invariant = require('fbjs/lib/invariant'); * the Class itself, not an instance. If any others are needed, simply add them * here, or in their own files. */ -var oneArgumentPooler = function(copyFieldsFrom) { - var Klass = this; +const oneArgumentPooler = function(copyFieldsFrom) { + const Klass = this; if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); + const instance = Klass.instancePool.pop(); Klass.call(instance, copyFieldsFrom); return instance; } else { @@ -30,10 +30,10 @@ var oneArgumentPooler = function(copyFieldsFrom) { } }; -var twoArgumentPooler = function(a1, a2) { - var Klass = this; +const twoArgumentPooler = function(a1, a2) { + const Klass = this; if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); + const instance = Klass.instancePool.pop(); Klass.call(instance, a1, a2); return instance; } else { @@ -41,10 +41,10 @@ var twoArgumentPooler = function(a1, a2) { } }; -var threeArgumentPooler = function(a1, a2, a3) { - var Klass = this; +const threeArgumentPooler = function(a1, a2, a3) { + const Klass = this; if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); + const instance = Klass.instancePool.pop(); Klass.call(instance, a1, a2, a3); return instance; } else { @@ -52,10 +52,10 @@ var threeArgumentPooler = function(a1, a2, a3) { } }; -var fourArgumentPooler = function(a1, a2, a3, a4) { - var Klass = this; +const fourArgumentPooler = function(a1, a2, a3, a4) { + const Klass = this; if (Klass.instancePool.length) { - var instance = Klass.instancePool.pop(); + const instance = Klass.instancePool.pop(); Klass.call(instance, a1, a2, a3, a4); return instance; } else { @@ -63,8 +63,8 @@ var fourArgumentPooler = function(a1, a2, a3, a4) { } }; -var standardReleaser = function(instance) { - var Klass = this; +const standardReleaser = function(instance) { + const Klass = this; invariant( instance instanceof Klass, 'Trying to release an instance into a pool of a different type.', @@ -75,8 +75,8 @@ var standardReleaser = function(instance) { } }; -var DEFAULT_POOL_SIZE = 10; -var DEFAULT_POOLER = oneArgumentPooler; +const DEFAULT_POOL_SIZE = 10; +const DEFAULT_POOLER = oneArgumentPooler; type Pooler = any; @@ -89,7 +89,7 @@ type Pooler = any; * @param {Function} CopyConstructor Constructor that can be used to reset. * @param {Function} pooler Customizable pooler. */ -var addPoolingTo = function( +const addPoolingTo = function( CopyConstructor: Class, pooler: Pooler, ): Class & { @@ -100,7 +100,7 @@ var addPoolingTo = function( } { // Casting as any so that flow ignores the actual implementation and trusts // it to match the type we declared - var NewKlass = (CopyConstructor: any); + const NewKlass = (CopyConstructor: any); NewKlass.instancePool = []; NewKlass.getPooled = pooler || DEFAULT_POOLER; if (!NewKlass.poolSize) { @@ -110,7 +110,7 @@ var addPoolingTo = function( return NewKlass; }; -var PooledClass = { +const PooledClass = { addPoolingTo: addPoolingTo, oneArgumentPooler: (oneArgumentPooler: Pooler), twoArgumentPooler: (twoArgumentPooler: Pooler), diff --git a/Libraries/Components/Touchable/Position.js b/Libraries/Components/Touchable/Position.js index 229e791fb..572d1132f 100644 --- a/Libraries/Components/Touchable/Position.js +++ b/Libraries/Components/Touchable/Position.js @@ -9,9 +9,9 @@ 'use strict'; -var PooledClass = require('PooledClass'); +const PooledClass = require('PooledClass'); -var twoArgumentPooler = PooledClass.twoArgumentPooler; +const twoArgumentPooler = PooledClass.twoArgumentPooler; /** * Position does not expose methods for construction via an `HTMLDOMElement`, diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index ff63195b0..9bfa38c68 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -110,7 +110,7 @@ const normalizeColor = require('normalizeColor'); /** * Touchable states. */ -var States = keyMirror({ +const States = keyMirror({ NOT_RESPONDER: null, // Not the responder RESPONDER_INACTIVE_PRESS_IN: null, // Responder, inactive, in the `PressRect` RESPONDER_INACTIVE_PRESS_OUT: null, // Responder, inactive, out of `PressRect` @@ -124,7 +124,7 @@ var States = keyMirror({ /** * Quick lookup map for states that are considered to be "active" */ -var IsActive = { +const IsActive = { RESPONDER_ACTIVE_PRESS_OUT: true, RESPONDER_ACTIVE_PRESS_IN: true }; @@ -133,20 +133,20 @@ var IsActive = { * Quick lookup for states that are considered to be "pressing" and are * therefore eligible to result in a "selection" if the press stops. */ -var IsPressingIn = { +const IsPressingIn = { RESPONDER_INACTIVE_PRESS_IN: true, RESPONDER_ACTIVE_PRESS_IN: true, RESPONDER_ACTIVE_LONG_PRESS_IN: true, }; -var IsLongPressingIn = { +const IsLongPressingIn = { RESPONDER_ACTIVE_LONG_PRESS_IN: true, }; /** * Inputs to the state machine. */ -var Signals = keyMirror({ +const Signals = keyMirror({ DELAY: null, RESPONDER_GRANT: null, RESPONDER_RELEASE: null, @@ -159,7 +159,7 @@ var Signals = keyMirror({ /** * Mapping from States x Signals => States */ -var Transitions = { +const Transitions = { NOT_RESPONDER: { DELAY: States.ERROR, RESPONDER_GRANT: States.RESPONDER_INACTIVE_PRESS_IN, @@ -237,15 +237,15 @@ var Transitions = { // ==== Typical Constants for integrating into UI components ==== // var HIT_EXPAND_PX = 20; // var HIT_VERT_OFFSET_PX = 10; -var HIGHLIGHT_DELAY_MS = 130; +const HIGHLIGHT_DELAY_MS = 130; -var PRESS_EXPAND_PX = 20; +const PRESS_EXPAND_PX = 20; -var LONG_PRESS_THRESHOLD = 500; +const LONG_PRESS_THRESHOLD = 500; -var LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS; +const LONG_PRESS_DELAY_MS = LONG_PRESS_THRESHOLD - HIGHLIGHT_DELAY_MS; -var LONG_PRESS_ALLOWED_MOVEMENT = 10; +const LONG_PRESS_ALLOWED_MOVEMENT = 10; // Default amount "active" region protrudes beyond box @@ -313,7 +313,7 @@ var LONG_PRESS_ALLOWED_MOVEMENT = 10; * * @lends Touchable.prototype */ -var TouchableMixin = { +const TouchableMixin = { componentDidMount: function() { if (!Platform.isTVOS) { return; @@ -321,7 +321,7 @@ var TouchableMixin = { this._tvEventHandler = new TVEventHandler(); this._tvEventHandler.enable(this, function(cmp, evt) { - var myTag = ReactNative.findNodeHandle(cmp); + const myTag = ReactNative.findNodeHandle(cmp); evt.dispatchConfig = {}; if (myTag === evt.tag) { if (evt.eventType === 'focus') { @@ -389,7 +389,7 @@ var TouchableMixin = { * */ touchableHandleResponderGrant: function(e) { - var dispatchID = e.currentTarget; + const dispatchID = e.currentTarget; // Since e is used in a callback invoked on another event loop // (as in setTimeout etc), we need to call e.persist() on the // event to make sure it doesn't get reused in the event object pool. @@ -401,7 +401,7 @@ var TouchableMixin = { this.state.touchable.touchState = States.NOT_RESPONDER; this.state.touchable.responderID = dispatchID; this._receiveSignal(Signals.RESPONDER_GRANT, e); - var delayMS = + let delayMS = this.touchableGetHighlightDelayMS !== undefined ? Math.max(this.touchableGetHighlightDelayMS(), 0) : HIGHLIGHT_DELAY_MS; delayMS = isNaN(delayMS) ? HIGHLIGHT_DELAY_MS : delayMS; @@ -414,7 +414,7 @@ var TouchableMixin = { this._handleDelay(e); } - var longDelayMS = + let longDelayMS = this.touchableGetLongPressDelayMS !== undefined ? Math.max(this.touchableGetLongPressDelayMS(), 10) : LONG_PRESS_DELAY_MS; longDelayMS = isNaN(longDelayMS) ? LONG_PRESS_DELAY_MS : longDelayMS; @@ -453,9 +453,9 @@ var TouchableMixin = { return; } - var positionOnActivate = this.state.touchable.positionOnActivate; - var dimensionsOnActivate = this.state.touchable.dimensionsOnActivate; - var pressRectOffset = this.touchableGetPressRectOffset ? + const positionOnActivate = this.state.touchable.positionOnActivate; + const dimensionsOnActivate = this.state.touchable.dimensionsOnActivate; + const pressRectOffset = this.touchableGetPressRectOffset ? this.touchableGetPressRectOffset() : { left: PRESS_EXPAND_PX, right: PRESS_EXPAND_PX, @@ -463,12 +463,12 @@ var TouchableMixin = { bottom: PRESS_EXPAND_PX }; - var pressExpandLeft = pressRectOffset.left; - var pressExpandTop = pressRectOffset.top; - var pressExpandRight = pressRectOffset.right; - var pressExpandBottom = pressRectOffset.bottom; + let pressExpandLeft = pressRectOffset.left; + let pressExpandTop = pressRectOffset.top; + let pressExpandRight = pressRectOffset.right; + let pressExpandBottom = pressRectOffset.bottom; - var hitSlop = this.touchableGetHitSlop ? + const hitSlop = this.touchableGetHitSlop ? this.touchableGetHitSlop() : null; if (hitSlop) { @@ -478,18 +478,18 @@ var TouchableMixin = { pressExpandBottom += hitSlop.bottom; } - var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); - var pageX = touch && touch.pageX; - var pageY = touch && touch.pageY; + const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); + const pageX = touch && touch.pageX; + const pageY = touch && touch.pageY; if (this.pressInLocation) { - var movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this.pressInLocation.pageX, this.pressInLocation.pageY); + const movedDistance = this._getDistanceBetweenPoints(pageX, pageY, this.pressInLocation.pageX, this.pressInLocation.pageY); if (movedDistance > LONG_PRESS_ALLOWED_MOVEMENT) { this._cancelLongPressDelayTimeout(); } } - var isTouchWithinActive = + const isTouchWithinActive = pageX > positionOnActivate.left - pressExpandLeft && pageY > positionOnActivate.top - pressExpandTop && pageX < @@ -502,7 +502,7 @@ var TouchableMixin = { pressExpandBottom; if (isTouchWithinActive) { this._receiveSignal(Signals.ENTER_PRESS_RECT, e); - var curState = this.state.touchable.touchState; + const curState = this.state.touchable.touchState; if (curState === States.RESPONDER_INACTIVE_PRESS_IN) { // fix for t7967420 this._cancelLongPressDelayTimeout(); @@ -620,7 +620,7 @@ var TouchableMixin = { _handleLongDelay: function(e) { this.longPressDelayTimeout = null; - var curState = this.state.touchable.touchState; + const curState = this.state.touchable.touchState; if (curState !== States.RESPONDER_ACTIVE_PRESS_IN && curState !== States.RESPONDER_ACTIVE_LONG_PRESS_IN) { console.error('Attempted to transition from state `' + curState + '` to `' + @@ -640,9 +640,9 @@ var TouchableMixin = { * @sideeffects */ _receiveSignal: function(signal, e) { - var responderID = this.state.touchable.responderID; - var curState = this.state.touchable.touchState; - var nextState = Transitions[curState] && Transitions[curState][signal]; + const responderID = this.state.touchable.responderID; + const curState = this.state.touchable.touchState; + const nextState = Transitions[curState] && Transitions[curState][signal]; if (!responderID && signal === Signals.RESPONDER_RELEASE) { return; } @@ -675,17 +675,17 @@ var TouchableMixin = { }, _savePressInLocation: function(e) { - var touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); - var pageX = touch && touch.pageX; - var pageY = touch && touch.pageY; - var locationX = touch && touch.locationX; - var locationY = touch && touch.locationY; + const touch = TouchEventUtils.extractSingleTouch(e.nativeEvent); + const pageX = touch && touch.pageX; + const pageY = touch && touch.pageY; + const locationX = touch && touch.locationX; + const locationY = touch && touch.locationY; this.pressInLocation = {pageX, pageY, locationX, locationY}; }, _getDistanceBetweenPoints: function (aX, aY, bX, bY) { - var deltaX = aX - bX; - var deltaY = aY - bY; + const deltaX = aX - bX; + const deltaY = aY - bY; return Math.sqrt(deltaX * deltaX + deltaY * deltaY); }, @@ -701,10 +701,10 @@ var TouchableMixin = { * @sideeffects */ _performSideEffectsForTransition: function(curState, nextState, signal, e) { - var curIsHighlight = this._isHighlight(curState); - var newIsHighlight = this._isHighlight(nextState); + const curIsHighlight = this._isHighlight(curState); + const newIsHighlight = this._isHighlight(nextState); - var isFinalSignal = + const isFinalSignal = signal === Signals.RESPONDER_TERMINATED || signal === Signals.RESPONDER_RELEASE; @@ -727,14 +727,14 @@ var TouchableMixin = { } if (IsPressingIn[curState] && signal === Signals.RESPONDER_RELEASE) { - var hasLongPressHandler = !!this.props.onLongPress; - var pressIsLongButStillCallOnPress = + const hasLongPressHandler = !!this.props.onLongPress; + const pressIsLongButStillCallOnPress = IsLongPressingIn[curState] && ( // We *are* long pressing.. - !hasLongPressHandler || // But either has no long handler - !this.touchableLongPressCancelsPress() // or we're told to ignore it. + (// But either has no long handler + !hasLongPressHandler || !this.touchableLongPressCancelsPress()) // or we're told to ignore it. ); - var shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress; + const shouldInvokePress = !IsLongPressingIn[curState] || pressIsLongButStillCallOnPress; if (shouldInvokePress && this.touchableHandlePress) { if (!newIsHighlight && !curIsHighlight) { // we never highlighted because of delay, but we should highlight now @@ -768,7 +768,7 @@ var TouchableMixin = { }; -var Touchable = { +const Touchable = { Mixin: TouchableMixin, TOUCH_TARGET_DEBUG: false, // Highlights all touchable targets. Toggle with Inspector. /** diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index 2f0949b6f..2afef3063 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -10,13 +10,13 @@ */ 'use strict'; -var Animated = require('Animated'); -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var createReactClass = require('create-react-class'); -var PropTypes = require('prop-types'); -var Touchable = require('Touchable'); +const Animated = require('Animated'); +const EdgeInsetsPropType = require('EdgeInsetsPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const createReactClass = require('create-react-class'); +const PropTypes = require('prop-types'); +const Touchable = require('Touchable'); type Event = Object; @@ -25,7 +25,7 @@ type State = { scale: Animated.Value, }; -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; /** * Example of using the `TouchableMixin` to play well with other responder @@ -34,7 +34,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; * `TouchableMixin` expects us to implement some abstract methods to handle * interesting interactions such as `handleTouchablePress`. */ -var TouchableBounce = createReactClass({ +const TouchableBounce = createReactClass({ displayName: 'TouchableBounce', mixins: [Touchable.Mixin, NativeMethodsMixin], @@ -115,7 +115,7 @@ var TouchableBounce = createReactClass({ }, touchableHandlePress: function(e: Event) { - var onPressWithCompletion = this.props.onPressWithCompletion; + const onPressWithCompletion = this.props.onPressWithCompletion; if (onPressWithCompletion) { onPressWithCompletion(() => { this.state.scale.setValue(0.93); diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js index effad3764..c4808b9be 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js @@ -8,37 +8,37 @@ */ 'use strict'; -var Platform = require('Platform'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var Touchable = require('Touchable'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); -var UIManager = require('UIManager'); +const Platform = require('Platform'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const Touchable = require('Touchable'); +const TouchableWithoutFeedback = require('TouchableWithoutFeedback'); +const UIManager = require('UIManager'); -var createReactClass = require('create-react-class'); -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var processColor = require('processColor'); +const createReactClass = require('create-react-class'); +const ensurePositiveDelayProps = require('ensurePositiveDelayProps'); +const processColor = require('processColor'); -var rippleBackgroundPropType = PropTypes.shape({ +const rippleBackgroundPropType = PropTypes.shape({ type: PropTypes.oneOf(['RippleAndroid']), color: PropTypes.number, borderless: PropTypes.bool, }); -var themeAttributeBackgroundPropType = PropTypes.shape({ +const themeAttributeBackgroundPropType = PropTypes.shape({ type: PropTypes.oneOf(['ThemeAttrAndroid']), attribute: PropTypes.string.isRequired, }); -var backgroundPropType = PropTypes.oneOfType([ +const backgroundPropType = PropTypes.oneOfType([ rippleBackgroundPropType, themeAttributeBackgroundPropType, ]); type Event = Object; -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; /** * A wrapper for making views respond properly to touches (Android only). @@ -69,7 +69,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; * ``` */ -var TouchableNativeFeedback = createReactClass({ +const TouchableNativeFeedback = createReactClass({ displayName: 'TouchableNativeFeedback', propTypes: { ...TouchableWithoutFeedback.propTypes, @@ -233,7 +233,7 @@ var TouchableNativeFeedback = createReactClass({ this.props.useForeground && TouchableNativeFeedback.canUseNativeForeground() ? 'nativeForegroundAndroid' : 'nativeBackgroundAndroid'; - var childProps = { + const childProps = { ...child.props, [drawableProp]: this.props.background, accessible: this.props.accessible !== false, diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js b/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js index c624cb7fd..e898d20ab 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.ios.js @@ -9,10 +9,10 @@ 'use strict'; -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); +const React = require('React'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const View = require('View'); class DummyTouchableNativeFeedback extends React.Component { static SelectableBackground = () => ({}); @@ -29,7 +29,7 @@ class DummyTouchableNativeFeedback extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { height: 100, width: 300, diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index e8d6ca171..abb77ac95 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -11,22 +11,22 @@ // Note (avik): add @flow when Flow supports spread properties in propTypes -var Animated = require('Animated'); -var Easing = require('Easing'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var PropTypes = require('prop-types'); -var TimerMixin = require('react-timer-mixin'); -var Touchable = require('Touchable'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); +const Animated = require('Animated'); +const Easing = require('Easing'); +const NativeMethodsMixin = require('NativeMethodsMixin'); +const React = require('React'); +const PropTypes = require('prop-types'); +const TimerMixin = require('react-timer-mixin'); +const Touchable = require('Touchable'); +const TouchableWithoutFeedback = require('TouchableWithoutFeedback'); -var createReactClass = require('create-react-class'); -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var flattenStyle = require('flattenStyle'); +const createReactClass = require('create-react-class'); +const ensurePositiveDelayProps = require('ensurePositiveDelayProps'); +const flattenStyle = require('flattenStyle'); type Event = Object; -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; /** * A wrapper for making views respond properly to touches. @@ -116,7 +116,7 @@ var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; * ``` * */ -var TouchableOpacity = createReactClass({ +const TouchableOpacity = createReactClass({ displayName: 'TouchableOpacity', mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin], @@ -234,7 +234,7 @@ var TouchableOpacity = createReactClass({ }, _getChildStyleOpacityWithDefault: function() { - var childStyle = flattenStyle(this.props.style) || {}; + const childStyle = flattenStyle(this.props.style) || {}; return childStyle.opacity == undefined ? 1 : childStyle.opacity; }, diff --git a/Libraries/Components/Touchable/ensureComponentIsNative.js b/Libraries/Components/Touchable/ensureComponentIsNative.js index de01d0177..63c1e8bf8 100644 --- a/Libraries/Components/Touchable/ensureComponentIsNative.js +++ b/Libraries/Components/Touchable/ensureComponentIsNative.js @@ -9,9 +9,9 @@ */ 'use strict'; -var invariant = require('fbjs/lib/invariant'); +const invariant = require('fbjs/lib/invariant'); -var ensureComponentIsNative = function(component: any) { +const ensureComponentIsNative = function(component: any) { invariant( component && typeof component.setNativeProps === 'function', 'Touchable child must either be native or forward setNativeProps to a ' + diff --git a/Libraries/Components/Touchable/ensurePositiveDelayProps.js b/Libraries/Components/Touchable/ensurePositiveDelayProps.js index 85f60091f..51b97f5ca 100644 --- a/Libraries/Components/Touchable/ensurePositiveDelayProps.js +++ b/Libraries/Components/Touchable/ensurePositiveDelayProps.js @@ -9,9 +9,9 @@ */ 'use strict'; -var invariant = require('fbjs/lib/invariant'); +const invariant = require('fbjs/lib/invariant'); -var ensurePositiveDelayProps = function(props: any) { +const ensurePositiveDelayProps = function(props: any) { invariant( !(props.delayPressIn < 0 || props.delayPressOut < 0 || props.delayLongPress < 0), diff --git a/Libraries/Components/View/PlatformViewPropTypes.ios.js b/Libraries/Components/View/PlatformViewPropTypes.ios.js index 2394a5174..c3e4f6c61 100644 --- a/Libraries/Components/View/PlatformViewPropTypes.ios.js +++ b/Libraries/Components/View/PlatformViewPropTypes.ios.js @@ -10,7 +10,7 @@ const Platform = require('Platform'); -var TVViewPropTypes = {}; +let TVViewPropTypes = {}; if (Platform.isTVOS) { TVViewPropTypes = require('TVViewPropTypes'); } diff --git a/Libraries/Components/View/ReactNativeStyleAttributes.js b/Libraries/Components/View/ReactNativeStyleAttributes.js index 462e9b7ca..a9441cad9 100644 --- a/Libraries/Components/View/ReactNativeStyleAttributes.js +++ b/Libraries/Components/View/ReactNativeStyleAttributes.js @@ -10,19 +10,19 @@ 'use strict'; -var ImageStylePropTypes = require('ImageStylePropTypes'); -var TextStylePropTypes = require('TextStylePropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); +const ImageStylePropTypes = require('ImageStylePropTypes'); +const TextStylePropTypes = require('TextStylePropTypes'); +const ViewStylePropTypes = require('ViewStylePropTypes'); /* $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. */ -var keyMirror = require('fbjs/lib/keyMirror'); -var processColor = require('processColor'); -var processTransform = require('processTransform'); -var sizesDiffer = require('sizesDiffer'); +const keyMirror = require('fbjs/lib/keyMirror'); +const processColor = require('processColor'); +const processTransform = require('processTransform'); +const sizesDiffer = require('sizesDiffer'); -var ReactNativeStyleAttributes = { +const ReactNativeStyleAttributes = { ...keyMirror(ViewStylePropTypes), ...keyMirror(TextStylePropTypes), ...keyMirror(ImageStylePropTypes), @@ -31,7 +31,7 @@ var ReactNativeStyleAttributes = { ReactNativeStyleAttributes.transform = { process: processTransform }; ReactNativeStyleAttributes.shadowOffset = { diff: sizesDiffer }; -var colorAttributes = { process: processColor }; +const colorAttributes = { process: processColor }; ReactNativeStyleAttributes.backgroundColor = colorAttributes; ReactNativeStyleAttributes.borderBottomColor = colorAttributes; ReactNativeStyleAttributes.borderColor = colorAttributes; diff --git a/Libraries/Components/View/ReactNativeViewAttributes.js b/Libraries/Components/View/ReactNativeViewAttributes.js index 64f81c719..26fb368ac 100644 --- a/Libraries/Components/View/ReactNativeViewAttributes.js +++ b/Libraries/Components/View/ReactNativeViewAttributes.js @@ -9,9 +9,9 @@ */ 'use strict'; -var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); +const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); -var ReactNativeViewAttributes = {}; +const ReactNativeViewAttributes = {}; ReactNativeViewAttributes.UIView = { pointerEvents: true, diff --git a/Libraries/Components/View/ViewStylePropTypes.js b/Libraries/Components/View/ViewStylePropTypes.js index 6e9c92163..c21ce5934 100644 --- a/Libraries/Components/View/ViewStylePropTypes.js +++ b/Libraries/Components/View/ViewStylePropTypes.js @@ -9,16 +9,16 @@ */ 'use strict'; -var ColorPropType = require('ColorPropType'); -var LayoutPropTypes = require('LayoutPropTypes'); -var ReactPropTypes = require('prop-types'); -var ShadowPropTypesIOS = require('ShadowPropTypesIOS'); -var TransformPropTypes = require('TransformPropTypes'); +const ColorPropType = require('ColorPropType'); +const LayoutPropTypes = require('LayoutPropTypes'); +const ReactPropTypes = require('prop-types'); +const ShadowPropTypesIOS = require('ShadowPropTypesIOS'); +const TransformPropTypes = require('TransformPropTypes'); /** * Warning: Some of these properties may not be supported in all releases. */ -var ViewStylePropTypes = { +const ViewStylePropTypes = { ...LayoutPropTypes, ...ShadowPropTypesIOS, ...TransformPropTypes, diff --git a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js index bcc1d8609..8463503bd 100644 --- a/Libraries/Components/ViewPager/ViewPagerAndroid.android.js +++ b/Libraries/Components/ViewPager/ViewPagerAndroid.android.js @@ -9,16 +9,16 @@ */ 'use strict'; -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var UIManager = require('UIManager'); -var ViewPropTypes = require('ViewPropTypes'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const UIManager = require('UIManager'); +const ViewPropTypes = require('ViewPropTypes'); -var dismissKeyboard = require('dismissKeyboard'); -var requireNativeComponent = require('requireNativeComponent'); +const dismissKeyboard = require('dismissKeyboard'); +const requireNativeComponent = require('requireNativeComponent'); -var VIEWPAGER_REF = 'viewPager'; +const VIEWPAGER_REF = 'viewPager'; type Event = Object; @@ -163,7 +163,7 @@ class ViewPagerAndroid extends React.Component<{ if (!child) { return null; } - var newProps = { + const newProps = { ...child.props, style: [child.props.style, { position: 'absolute', @@ -246,6 +246,6 @@ class ViewPagerAndroid extends React.Component<{ } } -var NativeAndroidViewPager = requireNativeComponent('AndroidViewPager', ViewPagerAndroid); +const NativeAndroidViewPager = requireNativeComponent('AndroidViewPager', ViewPagerAndroid); module.exports = ViewPagerAndroid; diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 851378755..16f2991df 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -8,30 +8,30 @@ */ 'use strict'; -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var ActivityIndicator = require('ActivityIndicator'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var StyleSheet = require('StyleSheet'); -var UIManager = require('UIManager'); -var View = require('View'); -var ViewPropTypes = require('ViewPropTypes'); +const EdgeInsetsPropType = require('EdgeInsetsPropType'); +const ActivityIndicator = require('ActivityIndicator'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const StyleSheet = require('StyleSheet'); +const UIManager = require('UIManager'); +const View = require('View'); +const ViewPropTypes = require('ViewPropTypes'); -var deprecatedPropType = require('deprecatedPropType'); -var keyMirror = require('fbjs/lib/keyMirror'); -var requireNativeComponent = require('requireNativeComponent'); -var resolveAssetSource = require('resolveAssetSource'); +const deprecatedPropType = require('deprecatedPropType'); +const keyMirror = require('fbjs/lib/keyMirror'); +const requireNativeComponent = require('requireNativeComponent'); +const resolveAssetSource = require('resolveAssetSource'); -var RCT_WEBVIEW_REF = 'webview'; +const RCT_WEBVIEW_REF = 'webview'; -var WebViewState = keyMirror({ +const WebViewState = keyMirror({ IDLE: null, LOADING: null, ERROR: null, }); -var defaultRenderLoading = () => ( +const defaultRenderLoading = () => ( { - var onLoadStart = this.props.onLoadStart; + const onLoadStart = this.props.onLoadStart; onLoadStart && onLoadStart(event); this.updateNavigationState(event); }; onLoadingError = (event) => { event.persist(); // persist this event because we need to store it - var {onError, onLoadEnd} = this.props; + const {onError, onLoadEnd} = this.props; onError && onError(event); onLoadEnd && onLoadEnd(event); console.warn('Encountered an error loading page', event.nativeEvent); @@ -418,7 +418,7 @@ class WebView extends React.Component { }; onLoadingFinish = (event) => { - var {onLoad, onLoadEnd} = this.props; + const {onLoad, onLoadEnd} = this.props; onLoad && onLoad(event); onLoadEnd && onLoadEnd(event); this.setState({ @@ -428,14 +428,14 @@ class WebView extends React.Component { }; onMessage = (event: Event) => { - var {onMessage} = this.props; + const {onMessage} = this.props; onMessage && onMessage(event); } } -var RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig); +const RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, }, diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index e11f8e385..f01cfae53 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -9,31 +9,31 @@ */ 'use strict'; -var ActivityIndicator = require('ActivityIndicator'); -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var React = require('React'); -var PropTypes = require('prop-types'); -var ReactNative = require('ReactNative'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var UIManager = require('UIManager'); -var View = require('View'); -var ViewPropTypes = require('ViewPropTypes'); -var ScrollView = require('ScrollView'); +const ActivityIndicator = require('ActivityIndicator'); +const EdgeInsetsPropType = require('EdgeInsetsPropType'); +const React = require('React'); +const PropTypes = require('prop-types'); +const ReactNative = require('ReactNative'); +const StyleSheet = require('StyleSheet'); +const Text = require('Text'); +const UIManager = require('UIManager'); +const View = require('View'); +const ViewPropTypes = require('ViewPropTypes'); +const ScrollView = require('ScrollView'); -var deprecatedPropType = require('deprecatedPropType'); -var invariant = require('fbjs/lib/invariant'); -var keyMirror = require('fbjs/lib/keyMirror'); -var processDecelerationRate = require('processDecelerationRate'); -var requireNativeComponent = require('requireNativeComponent'); -var resolveAssetSource = require('resolveAssetSource'); +const deprecatedPropType = require('deprecatedPropType'); +const invariant = require('fbjs/lib/invariant'); +const keyMirror = require('fbjs/lib/keyMirror'); +const processDecelerationRate = require('processDecelerationRate'); +const requireNativeComponent = require('requireNativeComponent'); +const resolveAssetSource = require('resolveAssetSource'); -var RCTWebViewManager = require('NativeModules').WebViewManager; +const RCTWebViewManager = require('NativeModules').WebViewManager; -var BGWASH = 'rgba(255,255,255,0.8)'; -var RCT_WEBVIEW_REF = 'webview'; +const BGWASH = 'rgba(255,255,255,0.8)'; +const RCT_WEBVIEW_REF = 'webview'; -var WebViewState = keyMirror({ +const WebViewState = keyMirror({ IDLE: null, LOADING: null, ERROR: null, @@ -67,12 +67,12 @@ const DataDetectorTypes = [ 'all', ]; -var defaultRenderLoading = () => ( +const defaultRenderLoading = () => ( ); -var defaultRenderError = (errorDomain, errorCode, errorDesc) => ( +const defaultRenderError = (errorDomain, errorCode, errorDesc) => ( Error loading page @@ -415,12 +415,12 @@ class WebView extends React.Component { } render() { - var otherView = null; + let otherView = null; if (this.state.viewState === WebViewState.LOADING) { otherView = (this.props.renderLoading || defaultRenderLoading)(); } else if (this.state.viewState === WebViewState.ERROR) { - var errorEvent = this.state.lastErrorEvent; + const errorEvent = this.state.lastErrorEvent; invariant( errorEvent != null, 'lastErrorEvent expected to be non-null' @@ -436,7 +436,7 @@ class WebView extends React.Component { ); } - var webViewStyles = [styles.container, styles.webView, this.props.style]; + const webViewStyles = [styles.container, styles.webView, this.props.style]; if (this.state.viewState === WebViewState.LOADING || this.state.viewState === WebViewState.ERROR) { // if we're in either LOADING or ERROR states, don't show the webView @@ -447,15 +447,15 @@ class WebView extends React.Component { const viewManager = nativeConfig.viewManager || RCTWebViewManager; - var onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => { - var shouldStart = this.props.onShouldStartLoadWithRequest && + const onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => { + const shouldStart = this.props.onShouldStartLoadWithRequest && this.props.onShouldStartLoadWithRequest(event.nativeEvent); viewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier); }); - var decelerationRate = processDecelerationRate(this.props.decelerationRate); + const decelerationRate = processDecelerationRate(this.props.decelerationRate); - var source = this.props.source || {}; + const source = this.props.source || {}; if (this.props.html) { source.html = this.props.html; } else if (this.props.url) { @@ -466,7 +466,7 @@ class WebView extends React.Component { const NativeWebView = nativeConfig.component || RCTWebView; - var webView = + const webView = { - var onLoadStart = this.props.onLoadStart; + const onLoadStart = this.props.onLoadStart; onLoadStart && onLoadStart(event); this._updateNavigationState(event); }; _onLoadingError = (event: Event) => { event.persist(); // persist this event because we need to store it - var {onError, onLoadEnd} = this.props; + const {onError, onLoadEnd} = this.props; onError && onError(event); onLoadEnd && onLoadEnd(event); console.warn('Encountered an error loading page', event.nativeEvent); @@ -613,7 +613,7 @@ class WebView extends React.Component { }; _onLoadingFinish = (event: Event) => { - var {onLoad, onLoadEnd} = this.props; + const {onLoad, onLoadEnd} = this.props; onLoad && onLoad(event); onLoadEnd && onLoadEnd(event); this.setState({ @@ -623,14 +623,14 @@ class WebView extends React.Component { }; _onMessage = (event: Event) => { - var {onMessage} = this.props; + const {onMessage} = this.props; onMessage && onMessage(event); } } -var RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig); +const RCTWebView = requireNativeComponent('RCTWebView', WebView, WebView.extraNativeComponentConfig); -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, },