react-rt-renderer, react-cs-renderer, react-call-return: Convert vars to let/const (#11721)
* react-call-return: convert var to let/const * react-cs-renderer: convert var to let/const * react-rt-renderer: convert var to let/const
Raphael Amorim committed
Nov 30, 2017 at 19:40 UTC
b3e27b264032100630ef818742f0f6aabd9db292
12 files changed
+36
-36
packages/react-call-return/src/ReactCallReturn.js
+2
-2
@@ -19,7 +19,7 @@ export function unstable_createCall<T>(
19
props: T,
20
key: ?string = null,
21
): ReactCall {
22
- var call = {
22
+ const call = {
23
// This tag allow us to uniquely identify this as a React Call
24
$$typeof: REACT_CALL_TYPE,
25
key: key == null ? null : '' + key,
@@ -40,7 +40,7 @@ export function unstable_createCall<T>(
40
}
41
42
export function unstable_createReturn(value: mixed): ReactReturn {
43
- var returnNode = {
43
+ const returnNode = {
44
// This tag allow us to uniquely identify this as a React Return
45
$$typeof: REACT_RETURN_TYPE,
46
value: value,
packages/react-call-return/src/__tests__/ReactCallReturn-test.js
+5
-5
@@ -9,9 +9,9 @@
9
10
'use strict';
11
12
-var React;
13
-var ReactNoop;
14
-var ReactCallReturn;
12
+let React;
13
+let ReactNoop;
14
+let ReactCallReturn;
15
16
describe('ReactCallReturn', () => {
17
beforeEach(() => {
@@ -31,7 +31,7 @@ describe('ReactCallReturn', () => {
31
}
32
33
it('should render a call', () => {
34
- var ops = [];
34
+ const ops = [];
35
36
function Continuation({isSame}) {
37
ops.push(['Continuation', isSame]);
@@ -159,7 +159,7 @@ describe('ReactCallReturn', () => {
159
});
160
161
it('should unmount a composite in a call', () => {
162
- var ops = [];
162
+ let ops = [];
163
164
class Continuation extends React.Component {
165
render() {
packages/react-cs-renderer/index.js
+1
-1
@@ -9,7 +9,7 @@
9
10
'use strict';
11
12
-var ReactNativeCS = require('./src/ReactNativeCS');
12
+const ReactNativeCS = require('./src/ReactNativeCS');
13
14
// TODO: decide on the top-level export form.
15
// This is hacky but makes it work with both Rollup and Jest.
packages/react-cs-renderer/src/ReactNativeCS.js
+1
-1
@@ -43,7 +43,7 @@ const infiniteDeadline = {
43
};
44
45
const arePropsEqual = (oldProps: Props, newProps: Props): boolean => {
46
- var key;
46
+ let key;
47
for (key in newProps) {
48
if (key === 'children') {
49
// Skip special case.
packages/react-cs-renderer/src/__tests__/ReactNativeCS-test.internal.js
+5
-5
@@ -9,8 +9,8 @@
9
10
'use strict';
11
12
-var React;
13
-var ReactNativeCS;
12
+let React;
13
+let ReactNativeCS;
14
15
jest.mock('shared/ReactFeatureFlags', () =>
16
require('shared/forks/ReactFeatureFlags.native-cs'),
@@ -26,9 +26,9 @@ describe('ReactNativeCS', () => {
26
27
it('should be able to create and render a native component', () => {
28
const CSView = 'View';
29
- var props = <CSView foo="test" />;
30
- var state = ReactNativeCS.getInitialState({});
31
- var stateUpdater = function() {};
29
+ const props = <CSView foo="test" />;
30
+ const state = ReactNativeCS.getInitialState({});
31
+ const stateUpdater = function() {};
32
ReactNativeCS.render({props, state, stateUpdater});
33
});
34
});
packages/react-rt-renderer/index.js
+1
-1
@@ -7,7 +7,7 @@
7
* @flow
8
*/
9
10
-var ReactNativeRT = require('./src/ReactNativeRT');
10
+const ReactNativeRT = require('./src/ReactNativeRT');
11
12
// TODO: decide on the top-level export form.
13
// This is hacky but makes it work with both Rollup and Jest.
packages/react-rt-renderer/src/ReactNativeRTComponentTree.js
+2
-2
@@ -9,8 +9,8 @@
9
10
import type {Fiber} from 'react-reconciler/src/ReactFiber';
11
12
-var instanceCache: {[key: number]: Fiber} = {};
13
-var instanceProps: {[key: number]: Object} = {};
12
+const instanceCache: {[key: number]: Fiber} = {};
13
+const instanceProps: {[key: number]: Object} = {};
14
15
export function precacheFiberNode(fiber: Fiber, tag: number): void {
16
instanceCache[tag] = fiber;
packages/react-rt-renderer/src/ReactNativeRTEventEmitter.js
+4
-4
@@ -13,7 +13,7 @@ import BatchedBridge from 'BatchedBridge';
13
14
import {getFiberCurrentPropsFromTag} from './ReactNativeRTComponentTree';
15
16
-var ReactNativeRTEventEmitter = {
16
+const ReactNativeRTEventEmitter = {
17
/**
18
* Publicly exposed method on module for native objc to invoke when a top
19
* level event is extracted.
@@ -26,12 +26,12 @@ var ReactNativeRTEventEmitter = {
26
topLevelType: string,
27
nativeEventParam: Object,
28
) {
29
- var nativeEvent = nativeEventParam;
30
- var props = getFiberCurrentPropsFromTag(tag);
29
+ const nativeEvent = nativeEventParam;
30
+ const props = getFiberCurrentPropsFromTag(tag);
31
if (props == null) {
32
return;
33
}
34
- var eventHandler = props[topLevelType];
34
+ const eventHandler = props[topLevelType];
35
if (typeof eventHandler !== 'function') {
36
return;
37
}
packages/react-rt-renderer/src/ReactNativeRTFiberInspector.js
+6
-6
@@ -21,20 +21,20 @@ import {getFiberFromTag} from './ReactNativeRTComponentTree';
21
let getInspectorDataForViewTag;
22
23
if (__DEV__) {
24
- var traverseOwnerTreeUp = function(hierarchy, instance: any) {
24
+ const traverseOwnerTreeUp = function(hierarchy, instance: any) {
25
if (instance) {
26
hierarchy.unshift(instance);
27
traverseOwnerTreeUp(hierarchy, instance._debugOwner);
28
}
29
};
30
31
- var getOwnerHierarchy = function(instance: any) {
32
- var hierarchy = [];
31
+ const getOwnerHierarchy = function(instance: any) {
32
+ const hierarchy = [];
33
traverseOwnerTreeUp(hierarchy, instance);
34
return hierarchy;
35
};
36
37
- var lastNonHostInstance = function(hierarchy) {
37
+ const lastNonHostInstance = function(hierarchy) {
38
for (let i = hierarchy.length - 1; i > 1; i--) {
39
const instance = hierarchy[i];
40
@@ -45,7 +45,7 @@ if (__DEV__) {
45
return hierarchy[0];
46
};
47
48
- var getHostProps = function(fiber) {
48
+ const getHostProps = function(fiber) {
49
const host = findCurrentHostFiber(fiber);
50
if (host) {
51
return host.memoizedProps || emptyObject;
@@ -53,7 +53,7 @@ if (__DEV__) {
53
return emptyObject;
54
};
55
56
- var createHierarchy = function(fiberHierarchy) {
56
+ const createHierarchy = function(fiberHierarchy) {
57
return fiberHierarchy.map(fiber => ({
58
name: getComponentName(fiber),
59
getInspectorData: findNodeHandle => ({
packages/react-rt-renderer/src/ReactNativeRTFiberRenderer.js
+3
-3
@@ -26,12 +26,12 @@ export type TextInstance = number;
26
27
function processProps(instance: number, props: Props): Object {
28
const propsPayload = {};
29
- for (var key in props) {
29
+ for (const key in props) {
30
if (key === 'children') {
31
// Skip special case.
32
continue;
33
}
34
- var value = props[key];
34
+ let value = props[key];
35
if (typeof value === 'function') {
36
value = {
37
style: 'rt-event',
@@ -45,7 +45,7 @@ function processProps(instance: number, props: Props): Object {
45
}
46
47
function arePropsEqual(oldProps: Props, newProps: Props): boolean {
48
- var key;
48
+ let key;
49
for (key in newProps) {
50
if (key === 'children') {
51
// Skip special case.
packages/react-rt-renderer/src/ReactNativeRTTagHandles.js
+3
-3
@@ -22,14 +22,14 @@ import invariant from 'fbjs/lib/invariant';
22
* Why: Because `dangerouslyReplaceNodeWithMarkupByID` relies on being able to
23
* unmount a component with a `rootNodeID`, then mount a new one in its place,
24
*/
25
-var INITIAL_TAG_COUNT = 1;
26
-var ReactNativeRTTagHandles = {
25
+const INITIAL_TAG_COUNT = 1;
26
+const ReactNativeRTTagHandles = {
27
tagsStartAt: INITIAL_TAG_COUNT,
28
tagCount: INITIAL_TAG_COUNT,
29
30
allocateTag: function(): number {
31
// Skip over root IDs as those are reserved for native
32
- var tag = ReactNativeRTTagHandles.tagCount;
32
+ const tag = ReactNativeRTTagHandles.tagCount;
33
ReactNativeRTTagHandles.tagCount++;
34
return tag;
35
},
packages/react-rt-renderer/src/__tests__/ReactNativeRT-test.internal.js
+3
-3
@@ -9,9 +9,9 @@
9
10
'use strict';
11
12
-var React;
13
-var ReactNativeRT;
14
-var RTManager;
12
+let React;
13
+let ReactNativeRT;
14
+let RTManager;
15
16
describe('ReactNativeRT', () => {
17
beforeEach(() => {