mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
react-reconciler: convert vars into let/const (#11729)
This commit is contained in:
committed by
Dan Abramov
parent
8ec2ed4089
commit
6074664f73
Vendored
+1
-1
@@ -16,7 +16,7 @@ export type {
|
||||
Reconciler,
|
||||
} from './src/ReactFiberReconciler';
|
||||
|
||||
var ReactFiberReconciler = require('./src/ReactFiberReconciler');
|
||||
const ReactFiberReconciler = require('./src/ReactFiberReconciler');
|
||||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ function setCurrentPhase(phase: LifeCyclePhase | null) {
|
||||
ReactDebugCurrentFiber.phase = phase;
|
||||
}
|
||||
|
||||
var ReactDebugCurrentFiber = {
|
||||
const ReactDebugCurrentFiber = {
|
||||
current: (null: Fiber | null),
|
||||
phase: (null: LifeCyclePhase | null),
|
||||
resetCurrentFiber,
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ import {NoContext} from './ReactTypeOfInternalContext';
|
||||
if (__DEV__) {
|
||||
var hasBadMapPolyfill = false;
|
||||
try {
|
||||
const nonExtensibleObject = Object.preventExtensions({});
|
||||
var nonExtensibleObject = Object.preventExtensions({});
|
||||
/* eslint-disable no-new */
|
||||
new Map([[nonExtensibleObject, null]]);
|
||||
new Set([nonExtensibleObject]);
|
||||
@@ -212,7 +212,7 @@ function FiberNode(
|
||||
// is faster.
|
||||
// 5) It should be easy to port this to a C struct and keep a C implementation
|
||||
// compatible.
|
||||
var createFiber = function(
|
||||
const createFiber = function(
|
||||
tag: TypeOfWork,
|
||||
pendingProps: mixed,
|
||||
key: null | string,
|
||||
|
||||
+9
-9
@@ -180,10 +180,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
// It used to be here.
|
||||
}
|
||||
|
||||
var unmaskedContext = getUnmaskedContext(workInProgress);
|
||||
var context = getMaskedContext(workInProgress, unmaskedContext);
|
||||
const unmaskedContext = getUnmaskedContext(workInProgress);
|
||||
const context = getMaskedContext(workInProgress, unmaskedContext);
|
||||
|
||||
var nextChildren;
|
||||
let nextChildren;
|
||||
|
||||
if (__DEV__) {
|
||||
ReactCurrentOwner.current = workInProgress;
|
||||
@@ -438,12 +438,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
'An indeterminate component should never have mounted. This error is ' +
|
||||
'likely caused by a bug in React. Please file an issue.',
|
||||
);
|
||||
var fn = workInProgress.type;
|
||||
var props = workInProgress.pendingProps;
|
||||
var unmaskedContext = getUnmaskedContext(workInProgress);
|
||||
var context = getMaskedContext(workInProgress, unmaskedContext);
|
||||
const fn = workInProgress.type;
|
||||
const props = workInProgress.pendingProps;
|
||||
const unmaskedContext = getUnmaskedContext(workInProgress);
|
||||
const context = getMaskedContext(workInProgress, unmaskedContext);
|
||||
|
||||
var value;
|
||||
let value;
|
||||
|
||||
if (__DEV__) {
|
||||
if (fn.prototype && typeof fn.prototype.render === 'function') {
|
||||
@@ -523,7 +523,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
}
|
||||
|
||||
function updateCallComponent(current, workInProgress, renderExpirationTime) {
|
||||
var nextCall = (workInProgress.pendingProps: ReactCall);
|
||||
let nextCall = (workInProgress.pendingProps: ReactCall);
|
||||
if (hasContextChanged()) {
|
||||
// Normally we can bail out on props equality but if context has changed
|
||||
// we don't do the bailout and we have to reuse existing props instead.
|
||||
|
||||
+6
-2
@@ -31,7 +31,11 @@ import {commitCallbacks} from './ReactFiberUpdateQueue';
|
||||
import {onCommitUnmount} from './ReactFiberDevToolsHook';
|
||||
import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
|
||||
|
||||
var {invokeGuardedCallback, hasCaughtError, clearCaughtError} = ReactErrorUtils;
|
||||
const {
|
||||
invokeGuardedCallback,
|
||||
hasCaughtError,
|
||||
clearCaughtError,
|
||||
} = ReactErrorUtils;
|
||||
|
||||
export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
|
||||
@@ -39,7 +43,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
) {
|
||||
const {getPublicInstance, mutation, persistence} = config;
|
||||
|
||||
var callComponentWillUnmountWithTimer = function(current, instance) {
|
||||
const callComponentWillUnmountWithTimer = function(current, instance) {
|
||||
startPhaseTimer(current, 'componentWillUnmount');
|
||||
instance.props = current.memoizedProps;
|
||||
instance.state = current.memoizedState;
|
||||
|
||||
+6
-6
@@ -115,7 +115,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
workInProgress: Fiber,
|
||||
renderExpirationTime: ExpirationTime,
|
||||
) {
|
||||
var call = (workInProgress.memoizedProps: ?ReactCall);
|
||||
const call = (workInProgress.memoizedProps: ?ReactCall);
|
||||
invariant(
|
||||
call,
|
||||
'Should be resolved by now. This error is likely caused by a bug in ' +
|
||||
@@ -133,13 +133,13 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
|
||||
// Build up the returns.
|
||||
// TODO: Compare this to a generator or opaque helpers like Children.
|
||||
var returns: Array<mixed> = [];
|
||||
const returns: Array<mixed> = [];
|
||||
appendAllReturns(returns, workInProgress);
|
||||
var fn = call.handler;
|
||||
var props = call.props;
|
||||
var nextChildren = fn(props, returns);
|
||||
const fn = call.handler;
|
||||
const props = call.props;
|
||||
const nextChildren = fn(props, returns);
|
||||
|
||||
var currentFirstChild = current !== null ? current.child : null;
|
||||
const currentFirstChild = current !== null ? current.child : null;
|
||||
workInProgress.child = reconcileChildFibers(
|
||||
workInProgress,
|
||||
currentFirstChild,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// See https://github.com/facebook/react/pull/8033.
|
||||
// This is not part of the public API, not even for React DevTools.
|
||||
// You may only inject a debugTool if you work on React Fiber itself.
|
||||
var ReactFiberInstrumentation = {
|
||||
const ReactFiberInstrumentation = {
|
||||
debugTool: null,
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -285,9 +285,9 @@ function getContextForSubtree(
|
||||
export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
|
||||
): Reconciler<C, I, TI> {
|
||||
var {getPublicInstance} = config;
|
||||
const {getPublicInstance} = config;
|
||||
|
||||
var {
|
||||
const {
|
||||
computeAsyncExpiration,
|
||||
computeUniqueAsyncExpiration,
|
||||
computeExpirationForFiber,
|
||||
|
||||
+6
-2
@@ -79,7 +79,11 @@ import {AsyncUpdates} from './ReactTypeOfInternalContext';
|
||||
import {getUpdateExpirationTime} from './ReactFiberUpdateQueue';
|
||||
import {resetContext} from './ReactFiberContext';
|
||||
|
||||
var {invokeGuardedCallback, hasCaughtError, clearCaughtError} = ReactErrorUtils;
|
||||
const {
|
||||
invokeGuardedCallback,
|
||||
hasCaughtError,
|
||||
clearCaughtError,
|
||||
} = ReactErrorUtils;
|
||||
|
||||
export type CapturedError = {
|
||||
componentName: ?string,
|
||||
@@ -101,7 +105,7 @@ if (__DEV__) {
|
||||
var didWarnStateUpdateForUnmountedComponent = {};
|
||||
|
||||
var warnAboutUpdateOnUnmounted = function(fiber: Fiber) {
|
||||
const componentName = getComponentName(fiber) || 'ReactClass';
|
||||
var componentName = getComponentName(fiber) || 'ReactClass';
|
||||
if (didWarnStateUpdateForUnmountedComponent[componentName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import {
|
||||
} from 'shared/ReactTypeOfWork';
|
||||
import {NoEffect, Placement} from 'shared/ReactTypeOfSideEffect';
|
||||
|
||||
var MOUNTING = 1;
|
||||
var MOUNTED = 2;
|
||||
var UNMOUNTED = 3;
|
||||
const MOUNTING = 1;
|
||||
const MOUNTED = 2;
|
||||
const UNMOUNTED = 3;
|
||||
|
||||
function isFiberMountedImpl(fiber: Fiber): number {
|
||||
let node = fiber;
|
||||
@@ -80,7 +80,7 @@ export function isMounted(component: React$Component<any, any>): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
var fiber: ?Fiber = ReactInstanceMap.get(component);
|
||||
const fiber: ?Fiber = ReactInstanceMap.get(component);
|
||||
if (!fiber) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactExpiration', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactFiberReconciler;
|
||||
let React;
|
||||
let ReactFiberReconciler;
|
||||
|
||||
describe('ReactFiberHostContext', () => {
|
||||
beforeEach(() => {
|
||||
@@ -20,8 +20,8 @@ describe('ReactFiberHostContext', () => {
|
||||
});
|
||||
|
||||
it('works with null host context', () => {
|
||||
var creates = 0;
|
||||
var Renderer = ReactFiberReconciler({
|
||||
let creates = 0;
|
||||
const Renderer = ReactFiberReconciler({
|
||||
prepareForCommit: function() {},
|
||||
resetAfterCommit: function() {},
|
||||
getRootHostContext: function() {
|
||||
|
||||
+16
-16
@@ -81,7 +81,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state of children with 1 level nesting', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -121,7 +121,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state between top-level fragments', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -162,7 +162,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state of children nested at same level', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -212,7 +212,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state in non-top-level fragment nesting', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -255,7 +255,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state of children if nested 2 levels without siblings', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -296,7 +296,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state of children if nested 2 levels with siblings', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -338,7 +338,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state between array nested in fragment and fragment', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -377,7 +377,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state between top level fragment and array', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -416,7 +416,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state between array nested in fragment and double nested fragment', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -457,7 +457,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state between array nested in fragment and double nested array', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -494,7 +494,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state between double nested fragment and double nested array', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -535,7 +535,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state of children when the keys are different', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -577,7 +577,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should not preserve state between unkeyed and keyed fragment', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -618,7 +618,7 @@ describe('ReactFragment', () => {
|
||||
});
|
||||
|
||||
it('should preserve state with reordering in multiple levels', function() {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -672,7 +672,7 @@ describe('ReactFragment', () => {
|
||||
|
||||
it('should not preserve state when switching to a keyed fragment to an array', function() {
|
||||
spyOnDev(console, 'error');
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
@@ -726,7 +726,7 @@ describe('ReactFragment', () => {
|
||||
|
||||
it('should preserve state when it does not change positions', function() {
|
||||
spyOnDev(console, 'error');
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Stateful extends React.Component {
|
||||
componentDidUpdate() {
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
var PropTypes;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
let PropTypes;
|
||||
|
||||
describe('ReactIncremental', () => {
|
||||
beforeEach(() => {
|
||||
@@ -35,8 +35,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('should render a simple component, in steps if needed', () => {
|
||||
var renderCallbackCalled = false;
|
||||
var barCalled = false;
|
||||
let renderCallbackCalled = false;
|
||||
let barCalled = false;
|
||||
function Bar() {
|
||||
barCalled = true;
|
||||
return (
|
||||
@@ -46,7 +46,7 @@ describe('ReactIncremental', () => {
|
||||
);
|
||||
}
|
||||
|
||||
var fooCalled = false;
|
||||
let fooCalled = false;
|
||||
function Foo() {
|
||||
fooCalled = true;
|
||||
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
|
||||
@@ -69,7 +69,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('updates a previous render', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Header() {
|
||||
ops.push('Header');
|
||||
@@ -86,8 +86,8 @@ describe('ReactIncremental', () => {
|
||||
return <footer>Bye</footer>;
|
||||
}
|
||||
|
||||
var header = <Header />;
|
||||
var footer = <Footer />;
|
||||
const header = <Header />;
|
||||
const footer = <Footer />;
|
||||
|
||||
function Foo(props) {
|
||||
ops.push('Foo');
|
||||
@@ -136,7 +136,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('can cancel partially rendered work and restart', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -245,7 +245,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('can deprioritize unfinished work and resume it later', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -297,7 +297,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('can deprioritize a tree from without dropping work', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -349,7 +349,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('can resume work in a subtree even when a parent bails out', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -368,7 +368,7 @@ describe('ReactIncremental', () => {
|
||||
return <span>{props.children}</span>;
|
||||
}
|
||||
|
||||
var middleContent = (
|
||||
const middleContent = (
|
||||
<aaa>
|
||||
<Tester />
|
||||
<bbb hidden={true}>
|
||||
@@ -412,7 +412,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('can resume work in a bailed subtree within one pass', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -620,7 +620,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('can reuse work done after being preempted', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -632,7 +632,7 @@ describe('ReactIncremental', () => {
|
||||
return <span>{props.children}</span>;
|
||||
}
|
||||
|
||||
var middleContent = (
|
||||
const middleContent = (
|
||||
<div>
|
||||
<Middle>Hello</Middle>
|
||||
<Bar>-</Bar>
|
||||
@@ -640,7 +640,7 @@ describe('ReactIncremental', () => {
|
||||
</div>
|
||||
);
|
||||
|
||||
var step0 = (
|
||||
const step0 = (
|
||||
<div>
|
||||
<Middle>Hi</Middle>
|
||||
<Bar>{'Foo'}</Bar>
|
||||
@@ -788,7 +788,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('can reuse work if shouldComponentUpdate is false, after being preempted', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function Bar(props) {
|
||||
ops.push('Bar');
|
||||
@@ -1110,9 +1110,9 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('can call sCU while resuming a partly mounted component', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
var instances = new Set();
|
||||
const instances = new Set();
|
||||
|
||||
class Bar extends React.Component {
|
||||
state = {y: 'A'};
|
||||
@@ -1159,8 +1159,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('gets new props when setting state on a partly updated component', () => {
|
||||
var ops = [];
|
||||
var instances = [];
|
||||
let ops = [];
|
||||
const instances = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
state = {y: 'A'};
|
||||
@@ -1227,7 +1227,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('calls componentWillMount twice if the initial render is aborted', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class LifeCycle extends React.Component {
|
||||
state = {x: this.props.x};
|
||||
@@ -1283,7 +1283,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('uses state set in componentWillMount even if initial render was aborted', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class LifeCycle extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -1330,7 +1330,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('calls componentWill* twice if an update render is aborted', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class LifeCycle extends React.Component {
|
||||
componentWillMount() {
|
||||
@@ -1417,9 +1417,9 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('does not call componentWillReceiveProps for state-only updates', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
var instances = [];
|
||||
const instances = [];
|
||||
|
||||
class LifeCycle extends React.Component {
|
||||
state = {x: 0};
|
||||
@@ -1566,7 +1566,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
xit('skips will/DidUpdate when bailing unless an update was already in progress', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class LifeCycle extends React.Component {
|
||||
componentWillMount() {
|
||||
@@ -1662,8 +1662,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('can nest batchedUpdates', () => {
|
||||
var ops = [];
|
||||
var instance;
|
||||
let ops = [];
|
||||
let instance;
|
||||
|
||||
class Foo extends React.Component {
|
||||
state = {n: 0};
|
||||
@@ -1704,8 +1704,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('can handle if setState callback throws', () => {
|
||||
var ops = [];
|
||||
var instance;
|
||||
let ops = [];
|
||||
let instance;
|
||||
|
||||
class Foo extends React.Component {
|
||||
state = {n: 0};
|
||||
@@ -1740,7 +1740,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('merges and masks context', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Intl extends React.Component {
|
||||
static childContextTypes = {
|
||||
@@ -1896,7 +1896,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('does not leak own context into context provider', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class Recurse extends React.Component {
|
||||
static contextTypes = {
|
||||
n: PropTypes.number,
|
||||
@@ -1927,7 +1927,7 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('provides context when reusing work', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Intl extends React.Component {
|
||||
static childContextTypes = {
|
||||
@@ -1984,8 +1984,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('reads context when setState is below the provider', () => {
|
||||
var ops = [];
|
||||
var statefulInst;
|
||||
const ops = [];
|
||||
let statefulInst;
|
||||
|
||||
class Intl extends React.Component {
|
||||
static childContextTypes = {
|
||||
@@ -2074,8 +2074,8 @@ describe('ReactIncremental', () => {
|
||||
});
|
||||
|
||||
it('reads context when setState is above the provider', () => {
|
||||
var ops = [];
|
||||
var statefulInst;
|
||||
const ops = [];
|
||||
let statefulInst;
|
||||
|
||||
class Intl extends React.Component {
|
||||
static childContextTypes = {
|
||||
|
||||
+14
-14
@@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var PropTypes;
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let PropTypes;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalErrorHandling', () => {
|
||||
beforeEach(() => {
|
||||
@@ -60,7 +60,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('catches render error in a boundary during partial deferred mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
@@ -105,7 +105,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('catches render error in a boundary during synchronous mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
@@ -147,7 +147,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('catches render error in a boundary during batched mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
@@ -190,7 +190,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary during full deferred mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
ops.push('RethrowErrorBoundary componentDidCatch');
|
||||
@@ -225,7 +225,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary during partial deferred mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
ops.push('RethrowErrorBoundary componentDidCatch');
|
||||
@@ -263,7 +263,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary during synchronous mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
ops.push('RethrowErrorBoundary componentDidCatch');
|
||||
@@ -298,7 +298,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('propagates an error from a noop error boundary during batched mounting', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
ops.push('RethrowErrorBoundary componentDidCatch');
|
||||
@@ -380,7 +380,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('can schedule updates after uncaught error in render on mount', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function BrokenRender() {
|
||||
ops.push('BrokenRender');
|
||||
@@ -405,7 +405,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('can schedule updates after uncaught error in render on update', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
function BrokenRender(props) {
|
||||
ops.push('BrokenRender');
|
||||
@@ -437,7 +437,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('can schedule updates after uncaught error during umounting', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class BrokenComponentWillUnmount extends React.Component {
|
||||
render() {
|
||||
@@ -895,7 +895,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
});
|
||||
|
||||
it('does not interrupt unmounting if detaching a ref throws', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
componentWillUnmount() {
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalErrorLogging', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalReflection', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalScheduling', () => {
|
||||
beforeEach(() => {
|
||||
@@ -112,8 +112,8 @@ describe('ReactIncrementalScheduling', () => {
|
||||
});
|
||||
|
||||
it('schedules sync updates when inside componentDidMount/Update', () => {
|
||||
var instance;
|
||||
var ops = [];
|
||||
let instance;
|
||||
let ops = [];
|
||||
|
||||
class Foo extends React.Component {
|
||||
state = {tick: 0};
|
||||
|
||||
+13
-13
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalSideEffects', () => {
|
||||
beforeEach(() => {
|
||||
@@ -305,7 +305,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
return <span prop={props.children} />;
|
||||
}
|
||||
|
||||
var middleContent = (
|
||||
const middleContent = (
|
||||
<div>
|
||||
<Bar>Hello</Bar>
|
||||
<Bar>World</Bar>
|
||||
@@ -515,7 +515,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
),
|
||||
),
|
||||
]);
|
||||
var innerSpanA = ReactNoop.getChildren()[0].children[1].children[1];
|
||||
const innerSpanA = ReactNoop.getChildren()[0].children[1].children[1];
|
||||
ReactNoop.render(<Foo tick={2} idx={1} />);
|
||||
ReactNoop.flushDeferredPri(30 + 25);
|
||||
expect(ReactNoop.getChildren()).toEqual([
|
||||
@@ -541,7 +541,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
),
|
||||
]);
|
||||
|
||||
var innerSpanB = ReactNoop.getChildren()[0].children[1].children[1];
|
||||
const innerSpanB = ReactNoop.getChildren()[0].children[1].children[1];
|
||||
// This should have been an update to an existing instance, not recreation.
|
||||
// We verify that by ensuring that the child instance was the same as
|
||||
// before.
|
||||
@@ -549,7 +549,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
});
|
||||
|
||||
xit('can defer side-effects and reuse them later - complex', function() {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
shouldComponentUpdate(nextProps) {
|
||||
@@ -693,9 +693,9 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
});
|
||||
|
||||
it('deprioritizes setStates that happens within a deprioritized tree', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
var barInstances = [];
|
||||
const barInstances = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
constructor() {
|
||||
@@ -851,7 +851,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
// TODO: Test that callbacks are not lost if an update is preempted.
|
||||
|
||||
it('calls componentWillUnmount after a deletion, even if nested', () => {
|
||||
var ops = [];
|
||||
const ops = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
componentWillUnmount() {
|
||||
@@ -911,7 +911,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
});
|
||||
|
||||
it('calls componentDidMount/Update after insertion/update', () => {
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class Bar extends React.Component {
|
||||
componentDidMount() {
|
||||
@@ -987,9 +987,9 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
|
||||
it('invokes ref callbacks after insertion/update/unmount', () => {
|
||||
spyOnDev(console, 'error');
|
||||
var classInstance = null;
|
||||
let classInstance = null;
|
||||
|
||||
var ops = [];
|
||||
let ops = [];
|
||||
|
||||
class ClassComponent extends React.Component {
|
||||
render() {
|
||||
@@ -1060,7 +1060,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
// expected way for aborted and resumed render life-cycles.
|
||||
|
||||
it('supports string refs', () => {
|
||||
var fooInstance = null;
|
||||
let fooInstance = null;
|
||||
|
||||
class Bar extends React.Component {
|
||||
componentDidMount() {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalTriangle', () => {
|
||||
beforeEach(() => {
|
||||
@@ -359,7 +359,7 @@ describe('ReactIncrementalTriangle', () => {
|
||||
simulate(...actions);
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Triangle fuzz tester error! Copy and paste the following line into the test suite:
|
||||
`Triangle fuzz tester error! Copy and paste the following line into the test suite:
|
||||
${formatActions(actions)}
|
||||
`,
|
||||
);
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
describe('ReactIncrementalUpdates', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
let ReactPortal;
|
||||
|
||||
describe('ReactPersistent', () => {
|
||||
@@ -62,12 +62,12 @@ describe('ReactPersistent', () => {
|
||||
|
||||
render(<Foo text="Hello" />);
|
||||
ReactNoop.flush();
|
||||
var originalChildren = getChildren();
|
||||
const originalChildren = getChildren();
|
||||
expect(originalChildren).toEqual([div(span())]);
|
||||
|
||||
render(<Foo text="World" />);
|
||||
ReactNoop.flush();
|
||||
var newChildren = getChildren();
|
||||
const newChildren = getChildren();
|
||||
expect(newChildren).toEqual([div(span(), span())]);
|
||||
|
||||
expect(originalChildren).toEqual([div(span())]);
|
||||
@@ -96,12 +96,12 @@ describe('ReactPersistent', () => {
|
||||
|
||||
render(<Foo text="Hello" />);
|
||||
ReactNoop.flush();
|
||||
var originalChildren = getChildren();
|
||||
const originalChildren = getChildren();
|
||||
expect(originalChildren).toEqual([div(span('Hello'))]);
|
||||
|
||||
render(<Foo text="World" />);
|
||||
ReactNoop.flush();
|
||||
var newChildren = getChildren();
|
||||
const newChildren = getChildren();
|
||||
expect(newChildren).toEqual([div(span('Hello'), span('World'))]);
|
||||
|
||||
expect(originalChildren).toEqual([div(span('Hello'))]);
|
||||
@@ -122,12 +122,12 @@ describe('ReactPersistent', () => {
|
||||
|
||||
render(<Foo text="Hello" />);
|
||||
ReactNoop.flush();
|
||||
var originalChildren = getChildren();
|
||||
const originalChildren = getChildren();
|
||||
expect(originalChildren).toEqual([div('Hello', span())]);
|
||||
|
||||
render(<Foo text="World" />);
|
||||
ReactNoop.flush();
|
||||
var newChildren = getChildren();
|
||||
const newChildren = getChildren();
|
||||
expect(newChildren).toEqual([div('World', span())]);
|
||||
|
||||
expect(originalChildren).toEqual([div('Hello', span())]);
|
||||
@@ -170,9 +170,9 @@ describe('ReactPersistent', () => {
|
||||
|
||||
expect(emptyPortalChildSet).toEqual([]);
|
||||
|
||||
var originalChildren = getChildren();
|
||||
const originalChildren = getChildren();
|
||||
expect(originalChildren).toEqual([div()]);
|
||||
var originalPortalChildren = portalContainer.children;
|
||||
const originalPortalChildren = portalContainer.children;
|
||||
expect(originalPortalChildren).toEqual([div(span())]);
|
||||
|
||||
render(
|
||||
@@ -186,9 +186,9 @@ describe('ReactPersistent', () => {
|
||||
);
|
||||
ReactNoop.flush();
|
||||
|
||||
var newChildren = getChildren();
|
||||
const newChildren = getChildren();
|
||||
expect(newChildren).toEqual([div()]);
|
||||
var newPortalChildren = portalContainer.children;
|
||||
const newPortalChildren = portalContainer.children;
|
||||
expect(newPortalChildren).toEqual([div(span(), 'Hello ', 'World')]);
|
||||
|
||||
expect(originalChildren).toEqual([div()]);
|
||||
@@ -203,7 +203,7 @@ describe('ReactPersistent', () => {
|
||||
render(<Parent />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var clearedPortalChildren = portalContainer.children;
|
||||
const clearedPortalChildren = portalContainer.children;
|
||||
expect(clearedPortalChildren).toEqual([]);
|
||||
|
||||
// The original is unchanged.
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
// This is a new feature in Fiber so I put it in its own test file. It could
|
||||
// probably move to one of the other test files once it is official.
|
||||
@@ -30,7 +30,7 @@ describe('ReactTopLevelFragment', function() {
|
||||
});
|
||||
|
||||
it('should preserve state when switching from a single child', function() {
|
||||
var instance = null;
|
||||
let instance = null;
|
||||
|
||||
class Stateful extends React.Component {
|
||||
render() {
|
||||
@@ -49,20 +49,20 @@ describe('ReactTopLevelFragment', function() {
|
||||
ReactNoop.render(<Fragment />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceA = instance;
|
||||
const instanceA = instance;
|
||||
|
||||
expect(instanceA).not.toBe(null);
|
||||
|
||||
ReactNoop.render(<Fragment condition={true} />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceB = instance;
|
||||
const instanceB = instance;
|
||||
|
||||
expect(instanceB).toBe(instanceA);
|
||||
});
|
||||
|
||||
it('should not preserve state when switching to a nested array', function() {
|
||||
var instance = null;
|
||||
let instance = null;
|
||||
|
||||
class Stateful extends React.Component {
|
||||
render() {
|
||||
@@ -81,20 +81,20 @@ describe('ReactTopLevelFragment', function() {
|
||||
ReactNoop.render(<Fragment />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceA = instance;
|
||||
const instanceA = instance;
|
||||
|
||||
expect(instanceA).not.toBe(null);
|
||||
|
||||
ReactNoop.render(<Fragment condition={true} />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceB = instance;
|
||||
const instanceB = instance;
|
||||
|
||||
expect(instanceB).not.toBe(instanceA);
|
||||
});
|
||||
|
||||
it('preserves state if an implicit key slot switches from/to null', function() {
|
||||
var instance = null;
|
||||
let instance = null;
|
||||
|
||||
class Stateful extends React.Component {
|
||||
render() {
|
||||
@@ -111,27 +111,27 @@ describe('ReactTopLevelFragment', function() {
|
||||
ReactNoop.render(<Fragment />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceA = instance;
|
||||
const instanceA = instance;
|
||||
|
||||
expect(instanceA).not.toBe(null);
|
||||
|
||||
ReactNoop.render(<Fragment condition={true} />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceB = instance;
|
||||
const instanceB = instance;
|
||||
|
||||
expect(instanceB).toBe(instanceA);
|
||||
|
||||
ReactNoop.render(<Fragment condition={false} />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceC = instance;
|
||||
const instanceC = instance;
|
||||
|
||||
expect(instanceC === instanceA).toBe(true);
|
||||
});
|
||||
|
||||
it('should preserve state in a reorder', function() {
|
||||
var instance = null;
|
||||
let instance = null;
|
||||
|
||||
class Stateful extends React.Component {
|
||||
render() {
|
||||
@@ -148,14 +148,14 @@ describe('ReactTopLevelFragment', function() {
|
||||
ReactNoop.render(<Fragment />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceA = instance;
|
||||
const instanceA = instance;
|
||||
|
||||
expect(instanceA).not.toBe(null);
|
||||
|
||||
ReactNoop.render(<Fragment condition={true} />);
|
||||
ReactNoop.flush();
|
||||
|
||||
var instanceB = instance;
|
||||
const instanceB = instance;
|
||||
|
||||
expect(instanceB).toBe(instanceA);
|
||||
});
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var React;
|
||||
var ReactNoop;
|
||||
let React;
|
||||
let ReactNoop;
|
||||
|
||||
// This is a new feature in Fiber so I put it in its own test file. It could
|
||||
// probably move to one of the other test files once it is official.
|
||||
|
||||
Reference in New Issue
Block a user