mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
SchedulerMock.unstable_yieldValue -> SchedulerMock.log (#26312)
(This only affects our own internal repo; it's not a public API.) I think most of us agree this is a less confusing name. It's possible someone will confuse it with `console.log`. If that becomes a problem we can warn in dev or something.
This commit is contained in:
@@ -13,7 +13,7 @@ import {equals} from '@jest/expect-utils';
|
||||
import enqueueTask from './enqueueTask';
|
||||
|
||||
function assertYieldsWereCleared(Scheduler) {
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
const actualYields = Scheduler.unstable_clearLog();
|
||||
if (actualYields.length !== 0) {
|
||||
const error = Error(
|
||||
'The event log is not empty. Call assertLog(...) first.',
|
||||
@@ -45,14 +45,14 @@ export async function waitFor(expectedLog) {
|
||||
SchedulerMock.unstable_flushNumberOfYields(
|
||||
expectedLog.length - actualLog.length,
|
||||
);
|
||||
actualLog.push(...SchedulerMock.unstable_clearYields());
|
||||
actualLog.push(...SchedulerMock.unstable_clearLog());
|
||||
if (expectedLog.length > actualLog.length) {
|
||||
// Continue flushing until we've logged the expected number of items.
|
||||
} else {
|
||||
// Once we've reached the expected sequence, wait one more microtask to
|
||||
// flush any remaining synchronous work.
|
||||
await waitForMicrotasks();
|
||||
actualLog.push(...SchedulerMock.unstable_clearYields());
|
||||
actualLog.push(...SchedulerMock.unstable_clearLog());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -91,7 +91,7 @@ export async function waitForAll(expectedLog) {
|
||||
SchedulerMock.unstable_flushAllWithoutAsserting();
|
||||
} while (true);
|
||||
|
||||
const actualLog = SchedulerMock.unstable_clearYields();
|
||||
const actualLog = SchedulerMock.unstable_clearLog();
|
||||
if (equals(actualLog, expectedLog)) {
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export async function waitForPaint(expectedLog) {
|
||||
await waitForMicrotasks();
|
||||
}
|
||||
|
||||
const actualLog = SchedulerMock.unstable_clearYields();
|
||||
const actualLog = SchedulerMock.unstable_clearLog();
|
||||
if (equals(actualLog, expectedLog)) {
|
||||
return;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ ${diff(expectedLog, actualLog)}
|
||||
}
|
||||
|
||||
export function assertLog(expectedLog) {
|
||||
const actualLog = SchedulerMock.unstable_clearYields();
|
||||
const actualLog = SchedulerMock.unstable_clearLog();
|
||||
if (equals(actualLog, expectedLog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @emails react-core
|
||||
* @jest-environment node
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const {startTransition, useDeferredValue} = React;
|
||||
const ReactNoop = require('react-noop-renderer');
|
||||
const {
|
||||
waitFor,
|
||||
waitForAll,
|
||||
waitForPaint,
|
||||
waitForThrow,
|
||||
assertLog,
|
||||
} = require('internal-test-utils');
|
||||
const act = require('jest-react').act;
|
||||
const Scheduler = require('scheduler/unstable_mock');
|
||||
|
||||
describe('ReactInternalTestUtils', () => {
|
||||
test('waitFor', async () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.log(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
startTransition(() => {
|
||||
root.render(
|
||||
<div>
|
||||
<Yield id="foo" />
|
||||
<Yield id="bar" />
|
||||
<Yield id="baz" />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
await waitFor(['foo', 'bar']);
|
||||
expect(root).toMatchRenderedOutput(null);
|
||||
await waitFor(['baz']);
|
||||
expect(root).toMatchRenderedOutput(null);
|
||||
await waitForAll([]);
|
||||
expect(root).toMatchRenderedOutput(<div>foobarbaz</div>);
|
||||
});
|
||||
|
||||
test('waitForAll', async () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.log(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
startTransition(() => {
|
||||
root.render(
|
||||
<div>
|
||||
<Yield id="foo" />
|
||||
<Yield id="bar" />
|
||||
<Yield id="baz" />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
await waitForAll(['foo', 'bar', 'baz']);
|
||||
expect(root).toMatchRenderedOutput(<div>foobarbaz</div>);
|
||||
});
|
||||
|
||||
test('waitForThrow', async () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.log(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
function BadRender() {
|
||||
throw new Error('Oh no!');
|
||||
}
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<Yield id="A" />
|
||||
<Yield id="B" />
|
||||
<BadRender />
|
||||
<Yield id="C" />
|
||||
<Yield id="D" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
root.render(<App />);
|
||||
|
||||
await waitForThrow('Oh no!');
|
||||
assertLog([
|
||||
'A',
|
||||
'B',
|
||||
'C',
|
||||
'D',
|
||||
// React will try one more time before giving up.
|
||||
'A',
|
||||
'B',
|
||||
'C',
|
||||
'D',
|
||||
]);
|
||||
});
|
||||
|
||||
test('waitForPaint', async () => {
|
||||
function App({prop}) {
|
||||
const deferred = useDeferredValue(prop);
|
||||
const text = `Urgent: ${prop}, Deferred: ${deferred}`;
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
root.render(<App prop="A" />);
|
||||
|
||||
await waitForAll(['Urgent: A, Deferred: A']);
|
||||
expect(root).toMatchRenderedOutput('Urgent: A, Deferred: A');
|
||||
|
||||
// This update will result in two separate paints: an urgent one, and a
|
||||
// deferred one.
|
||||
root.render(<App prop="B" />);
|
||||
// Urgent paint
|
||||
await waitForPaint(['Urgent: B, Deferred: A']);
|
||||
expect(root).toMatchRenderedOutput('Urgent: B, Deferred: A');
|
||||
|
||||
// Deferred paint
|
||||
await waitForPaint(['Urgent: B, Deferred: B']);
|
||||
expect(root).toMatchRenderedOutput('Urgent: B, Deferred: B');
|
||||
});
|
||||
|
||||
test('assertLog', async () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.log(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<Yield id="A" />
|
||||
<Yield id="B" />
|
||||
<Yield id="C" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
await act(async () => {
|
||||
root.render(<App />);
|
||||
});
|
||||
assertLog(['A', 'B', 'C']);
|
||||
});
|
||||
});
|
||||
@@ -29,7 +29,7 @@ function captureAssertion(fn) {
|
||||
|
||||
function assertYieldsWereCleared(root) {
|
||||
const Scheduler = root._Scheduler;
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
const actualYields = Scheduler.unstable_clearLog();
|
||||
if (actualYields.length !== 0) {
|
||||
const error = Error(
|
||||
'Log of yielded values is not empty. ' +
|
||||
|
||||
@@ -54,16 +54,12 @@ describe('ReactCache', () => {
|
||||
listeners = [{resolve, reject}];
|
||||
setTimeout(() => {
|
||||
if (textResourceShouldFail) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise rejected [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise rejected [${text}]`);
|
||||
status = 'rejected';
|
||||
value = new Error('Failed to load: ' + text);
|
||||
listeners.forEach(listener => listener.reject(value));
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise resolved [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise resolved [${text}]`);
|
||||
status = 'resolved';
|
||||
value = text;
|
||||
listeners.forEach(listener => listener.resolve(value));
|
||||
@@ -93,7 +89,7 @@ describe('ReactCache', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -101,13 +97,13 @@ describe('ReactCache', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
TextResource.read([props.text, props.ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -171,7 +167,7 @@ describe('ReactCache', () => {
|
||||
});
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return BadTextResource.read(['Hi', 100]);
|
||||
}
|
||||
|
||||
@@ -322,13 +318,13 @@ describe('ReactCache', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
const actualText = BadTextResource.read([props.text, props.ms]);
|
||||
Scheduler.unstable_yieldValue(actualText);
|
||||
Scheduler.log(actualText);
|
||||
return actualText;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
|
||||
+4
-4
@@ -827,7 +827,7 @@ describe('ReactFlight', () => {
|
||||
}
|
||||
|
||||
function ClientDoubler({el}) {
|
||||
Scheduler.unstable_yieldValue('ClientDoubler');
|
||||
Scheduler.log('ClientDoubler');
|
||||
return (
|
||||
<>
|
||||
{el}
|
||||
@@ -1018,10 +1018,10 @@ describe('ReactFlight', () => {
|
||||
|
||||
function Bar() {
|
||||
if (!promise.unsuspend) {
|
||||
Scheduler.unstable_yieldValue('suspended');
|
||||
Scheduler.log('suspended');
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('rendered');
|
||||
Scheduler.log('rendered');
|
||||
const context = React.useContext(ServerContext);
|
||||
return context;
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ describe('ReactFlight', () => {
|
||||
);
|
||||
|
||||
function ClientBar() {
|
||||
Scheduler.unstable_yieldValue('ClientBar');
|
||||
Scheduler.log('ClientBar');
|
||||
const context = React.useContext(ServerContext);
|
||||
return <span>{context}</span>;
|
||||
}
|
||||
|
||||
@@ -193,12 +193,12 @@ describe('Timeline profiler', () => {
|
||||
|
||||
it('should mark render yields', async () => {
|
||||
function Bar() {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return null;
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return <Bar />;
|
||||
}
|
||||
|
||||
@@ -908,37 +908,37 @@ describe('Timeline profiler', () => {
|
||||
it('should mark passive and layout effects', async () => {
|
||||
function ComponentWithEffects() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('layout 1 mount');
|
||||
Scheduler.log('layout 1 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('layout 1 unmount');
|
||||
Scheduler.log('layout 1 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 1 mount');
|
||||
Scheduler.log('passive 1 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 1 unmount');
|
||||
Scheduler.log('passive 1 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('layout 2 mount');
|
||||
Scheduler.log('layout 2 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('layout 2 unmount');
|
||||
Scheduler.log('layout 2 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 2 mount');
|
||||
Scheduler.log('passive 2 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 2 unmount');
|
||||
Scheduler.log('passive 2 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 3 mount');
|
||||
Scheduler.log('passive 3 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 3 unmount');
|
||||
Scheduler.log('passive 3 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -1327,12 +1327,12 @@ describe('Timeline profiler', () => {
|
||||
// @reactVersion >=18.0
|
||||
it('should mark render yields', async () => {
|
||||
function Bar() {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return null;
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return <Bar />;
|
||||
}
|
||||
|
||||
@@ -1363,7 +1363,7 @@ describe('Timeline profiler', () => {
|
||||
});
|
||||
|
||||
function Example() {
|
||||
Scheduler.unstable_yieldValue(resolved ? 'resolved' : 'suspended');
|
||||
Scheduler.log(resolved ? 'resolved' : 'suspended');
|
||||
if (!resolved) {
|
||||
throw suspensePromise;
|
||||
}
|
||||
@@ -1421,7 +1421,7 @@ describe('Timeline profiler', () => {
|
||||
});
|
||||
|
||||
function Example() {
|
||||
Scheduler.unstable_yieldValue(rejected ? 'rejected' : 'suspended');
|
||||
Scheduler.log(rejected ? 'rejected' : 'suspended');
|
||||
if (!rejected) {
|
||||
throw suspensePromise;
|
||||
}
|
||||
@@ -1479,7 +1479,7 @@ describe('Timeline profiler', () => {
|
||||
});
|
||||
|
||||
function Example() {
|
||||
Scheduler.unstable_yieldValue(resolved ? 'resolved' : 'suspended');
|
||||
Scheduler.log(resolved ? 'resolved' : 'suspended');
|
||||
if (!resolved) {
|
||||
throw suspensePromise;
|
||||
}
|
||||
@@ -1537,7 +1537,7 @@ describe('Timeline profiler', () => {
|
||||
});
|
||||
|
||||
function Example() {
|
||||
Scheduler.unstable_yieldValue(rejected ? 'rejected' : 'suspended');
|
||||
Scheduler.log(rejected ? 'rejected' : 'suspended');
|
||||
if (!rejected) {
|
||||
throw suspensePromise;
|
||||
}
|
||||
@@ -1591,9 +1591,7 @@ describe('Timeline profiler', () => {
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(
|
||||
this.state.didMount ? 'update' : 'mount',
|
||||
);
|
||||
Scheduler.log(this.state.didMount ? 'update' : 'mount');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1652,7 +1650,7 @@ describe('Timeline profiler', () => {
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(forced ? 'force update' : 'mount');
|
||||
Scheduler.log(forced ? 'force update' : 'mount');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1708,7 +1706,7 @@ describe('Timeline profiler', () => {
|
||||
this.setState({didRender: true});
|
||||
}
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
this.state.didRender ? 'second render' : 'first render',
|
||||
);
|
||||
return null;
|
||||
@@ -1775,7 +1773,7 @@ describe('Timeline profiler', () => {
|
||||
class Example extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(forced ? 'force update' : 'render');
|
||||
Scheduler.log(forced ? 'force update' : 'render');
|
||||
if (!forced) {
|
||||
forced = true;
|
||||
this.forceUpdate();
|
||||
@@ -1845,7 +1843,7 @@ describe('Timeline profiler', () => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(didMount ? 'update' : 'mount');
|
||||
Scheduler.log(didMount ? 'update' : 'mount');
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -1909,7 +1907,7 @@ describe('Timeline profiler', () => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
Scheduler.unstable_yieldValue(didMount ? 'update' : 'mount');
|
||||
Scheduler.log(didMount ? 'update' : 'mount');
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -1971,7 +1969,7 @@ describe('Timeline profiler', () => {
|
||||
if (!didRender) {
|
||||
setDidRender(true);
|
||||
}
|
||||
Scheduler.unstable_yieldValue(didRender ? 'update' : 'mount');
|
||||
Scheduler.log(didRender ? 'update' : 'mount');
|
||||
return didRender;
|
||||
}
|
||||
|
||||
@@ -2024,16 +2022,16 @@ describe('Timeline profiler', () => {
|
||||
render() {
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary fallback');
|
||||
Scheduler.log('ErrorBoundary fallback');
|
||||
return null;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render');
|
||||
Scheduler.log('ErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function ExampleThatThrows() {
|
||||
Scheduler.unstable_yieldValue('ExampleThatThrows');
|
||||
Scheduler.log('ExampleThatThrows');
|
||||
throw Error('Expected error');
|
||||
}
|
||||
|
||||
@@ -2119,16 +2117,16 @@ describe('Timeline profiler', () => {
|
||||
render() {
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary fallback');
|
||||
Scheduler.log('ErrorBoundary fallback');
|
||||
return null;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render');
|
||||
Scheduler.log('ErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function ExampleThatThrows() {
|
||||
Scheduler.unstable_yieldValue('ExampleThatThrows');
|
||||
Scheduler.log('ExampleThatThrows');
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw 'Expected error';
|
||||
}
|
||||
@@ -2231,37 +2229,37 @@ describe('Timeline profiler', () => {
|
||||
it('should mark passive and layout effects', async () => {
|
||||
function ComponentWithEffects() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('layout 1 mount');
|
||||
Scheduler.log('layout 1 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('layout 1 unmount');
|
||||
Scheduler.log('layout 1 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 1 mount');
|
||||
Scheduler.log('passive 1 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 1 unmount');
|
||||
Scheduler.log('passive 1 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('layout 2 mount');
|
||||
Scheduler.log('layout 2 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('layout 2 unmount');
|
||||
Scheduler.log('layout 2 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 2 mount');
|
||||
Scheduler.log('passive 2 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 2 unmount');
|
||||
Scheduler.log('passive 2 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('passive 3 mount');
|
||||
Scheduler.log('passive 3 mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('passive 3 unmount');
|
||||
Scheduler.log('passive 3 unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -2464,7 +2462,7 @@ describe('Timeline profiler', () => {
|
||||
|
||||
it('should generate component stacks for state update', async () => {
|
||||
function CommponentWithChildren({initialRender}) {
|
||||
Scheduler.unstable_yieldValue('Render ComponentWithChildren');
|
||||
Scheduler.log('Render ComponentWithChildren');
|
||||
return <Child initialRender={initialRender} />;
|
||||
}
|
||||
|
||||
@@ -2473,7 +2471,7 @@ describe('Timeline profiler', () => {
|
||||
if (!didRender) {
|
||||
setDidRender(true);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Render Child');
|
||||
Scheduler.log('Render Child');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1352,7 +1352,7 @@ describe('Timeline profiler', () => {
|
||||
// @reactVersion >= 18.0
|
||||
it('should not warn when React finishes a previously long (async) update with a short (sync) update inside of an event', async () => {
|
||||
function Yield({id, value}) {
|
||||
Scheduler.unstable_yieldValue(`${id}:${value}`);
|
||||
Scheduler.log(`${id}:${value}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1415,9 +1415,7 @@ describe('Timeline profiler', () => {
|
||||
it('should not warn about short nested (state) updates during layout effects', async () => {
|
||||
function Component() {
|
||||
const [didMount, setDidMount] = React.useState(false);
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Component ${didMount ? 'update' : 'mount'}`,
|
||||
);
|
||||
Scheduler.log(`Component ${didMount ? 'update' : 'mount'}`);
|
||||
React.useLayoutEffect(() => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
@@ -1453,7 +1451,7 @@ describe('Timeline profiler', () => {
|
||||
this.forceUpdate();
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Component ${this._didMount ? 'update' : 'mount'}`,
|
||||
);
|
||||
return null;
|
||||
@@ -1485,9 +1483,7 @@ describe('Timeline profiler', () => {
|
||||
it.skip('should warn about long nested (state) updates during layout effects', async () => {
|
||||
function Component() {
|
||||
const [didMount, setDidMount] = React.useState(false);
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Component ${didMount ? 'update' : 'mount'}`,
|
||||
);
|
||||
Scheduler.log(`Component ${didMount ? 'update' : 'mount'}`);
|
||||
// Fake a long render
|
||||
startTime += 20000;
|
||||
React.useLayoutEffect(() => {
|
||||
@@ -1549,7 +1545,7 @@ describe('Timeline profiler', () => {
|
||||
this.forceUpdate();
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Component ${this._didMount ? 'update' : 'mount'}`,
|
||||
);
|
||||
return null;
|
||||
@@ -1606,13 +1602,11 @@ describe('Timeline profiler', () => {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [isPending, startTransition] = React.useTransition();
|
||||
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Component rendered with value ${value}`,
|
||||
);
|
||||
Scheduler.log(`Component rendered with value ${value}`);
|
||||
|
||||
// Fake a long render
|
||||
if (value !== 0) {
|
||||
Scheduler.unstable_yieldValue('Long render');
|
||||
Scheduler.log('Long render');
|
||||
startTime += 20000;
|
||||
}
|
||||
|
||||
@@ -1677,13 +1671,13 @@ describe('Timeline profiler', () => {
|
||||
const [value, setValue] = React.useState(0);
|
||||
const deferredValue = React.useDeferredValue(value);
|
||||
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Component rendered with value ${value} and deferredValue ${deferredValue}`,
|
||||
);
|
||||
|
||||
// Fake a long render
|
||||
if (deferredValue !== 0) {
|
||||
Scheduler.unstable_yieldValue('Long render');
|
||||
Scheduler.log('Long render');
|
||||
startTime += 20000;
|
||||
}
|
||||
|
||||
@@ -1805,7 +1799,7 @@ describe('Timeline profiler', () => {
|
||||
}
|
||||
|
||||
function Component({shouldSuspend}) {
|
||||
Scheduler.unstable_yieldValue(`Component ${shouldSuspend}`);
|
||||
Scheduler.log(`Component ${shouldSuspend}`);
|
||||
if (shouldSuspend) {
|
||||
readValue(123);
|
||||
}
|
||||
@@ -1863,7 +1857,7 @@ describe('Timeline profiler', () => {
|
||||
}
|
||||
|
||||
function Component({shouldSuspend}) {
|
||||
Scheduler.unstable_yieldValue(`Component ${shouldSuspend}`);
|
||||
Scheduler.log(`Component ${shouldSuspend}`);
|
||||
if (shouldSuspend) {
|
||||
readValue(123);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,3 @@ afterEach(() => {
|
||||
// so that we don't disconnect the ReactCurrentDispatcher ref.
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
expect.extend({
|
||||
...require('../../../../scripts/jest/matchers/schedulerTestMatchers'),
|
||||
});
|
||||
|
||||
@@ -600,7 +600,7 @@ describe('ReactDOMFiberAsync', () => {
|
||||
const root = ReactDOMClient.createRoot(container);
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
|
||||
+38
-60
@@ -2118,7 +2118,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
}
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -2153,9 +2153,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Log recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Log recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2203,7 +2201,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
return () => {};
|
||||
}
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
function App() {
|
||||
@@ -2238,9 +2236,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Log recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Log recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2296,7 +2292,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
getClientSnapshot,
|
||||
getServerSnapshot,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2323,7 +2319,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2378,7 +2374,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
getClientSnapshot,
|
||||
getServerSnapshot,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2413,7 +2409,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2468,7 +2464,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
if (isClient) {
|
||||
throw new Error('Oops!');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Yay!');
|
||||
Scheduler.log('Yay!');
|
||||
return 'Yay!';
|
||||
}
|
||||
|
||||
@@ -2527,7 +2523,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
} else {
|
||||
throw Error('Oops.');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Yay!');
|
||||
Scheduler.log('Yay!');
|
||||
return 'Yay!';
|
||||
}
|
||||
|
||||
@@ -2546,7 +2542,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
await act(async () => {
|
||||
const {pipe} = renderToPipeableStream(<App />, {
|
||||
onError(error) {
|
||||
Scheduler.unstable_yieldValue('[s!] ' + error.message);
|
||||
Scheduler.log('[s!] ' + error.message);
|
||||
},
|
||||
});
|
||||
pipe(writable);
|
||||
@@ -2561,7 +2557,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('[c!] ' + error.message);
|
||||
Scheduler.log('[c!] ' + error.message);
|
||||
},
|
||||
});
|
||||
// This should not report any errors yet.
|
||||
@@ -2612,7 +2608,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
} else {
|
||||
throw Error('Oops.');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Yay! (' + color + ')');
|
||||
Scheduler.log('Yay! (' + color + ')');
|
||||
return 'Yay! (' + color + ')';
|
||||
}
|
||||
|
||||
@@ -2631,7 +2627,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
await act(async () => {
|
||||
const {pipe} = renderToPipeableStream(<App color="red" />, {
|
||||
onError(error) {
|
||||
Scheduler.unstable_yieldValue('[s!] ' + error.message);
|
||||
Scheduler.log('[s!] ' + error.message);
|
||||
},
|
||||
});
|
||||
pipe(writable);
|
||||
@@ -2646,7 +2642,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
const root = ReactDOMClient.hydrateRoot(container, <App color="red" />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('[c!] ' + error.message);
|
||||
Scheduler.log('[c!] ' + error.message);
|
||||
},
|
||||
});
|
||||
// This should not report any errors yet.
|
||||
@@ -2709,7 +2705,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
} else {
|
||||
throw Error('Oops.');
|
||||
}
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2731,7 +2727,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
<App fallbackText="Loading..." />,
|
||||
{
|
||||
onError(error) {
|
||||
Scheduler.unstable_yieldValue('[s!] ' + error.message);
|
||||
Scheduler.log('[s!] ' + error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -2749,7 +2745,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
<App fallbackText="Loading..." />,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('[c!] ' + error.message);
|
||||
Scheduler.log('[c!] ' + error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -2833,7 +2829,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
if (isClient) {
|
||||
readText(value);
|
||||
}
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2868,7 +2864,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2914,15 +2910,15 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
function A() {
|
||||
if (shouldThrow) {
|
||||
Scheduler.unstable_yieldValue('Oops!');
|
||||
Scheduler.log('Oops!');
|
||||
throw new Error('Oops!');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
return 'A';
|
||||
}
|
||||
|
||||
function B() {
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
return 'B';
|
||||
}
|
||||
|
||||
@@ -2937,9 +2933,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
const root = ReactDOMClient.createRoot(container, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged a recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged a recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
React.startTransition(() => {
|
||||
@@ -2990,7 +2984,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
// useSyncExternalStore in this test is because getServerSnapshot has the
|
||||
// ability to observe whether we're hydrating.
|
||||
useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -3018,9 +3012,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
isClient = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3722,9 +3714,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
const [ClientApp, clientResolve] = makeApp();
|
||||
ReactDOMClient.hydrateRoot(container, <ClientApp />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
Scheduler.unstable_flushAll();
|
||||
@@ -3801,9 +3791,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
const [ClientApp, clientResolve] = makeApp();
|
||||
ReactDOMClient.hydrateRoot(container, <ClientApp text="replaced" />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
Scheduler.unstable_flushAll();
|
||||
@@ -3872,9 +3860,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App text="replaced" />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
@@ -3963,9 +3949,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
@@ -4005,7 +3989,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
function ThrowUntilOnClient({children, message}) {
|
||||
if (isClient && shouldThrow) {
|
||||
Scheduler.unstable_yieldValue('throwing: ' + message);
|
||||
Scheduler.log('throwing: ' + message);
|
||||
throw new Error(message);
|
||||
}
|
||||
return children;
|
||||
@@ -4055,9 +4039,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
@@ -4127,7 +4109,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
};
|
||||
});
|
||||
}
|
||||
Scheduler.unstable_yieldValue('suspending');
|
||||
Scheduler.log('suspending');
|
||||
throw promise;
|
||||
}
|
||||
return null;
|
||||
@@ -4135,7 +4117,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
function ThrowUntilOnClient({children, message}) {
|
||||
if (isClient && shouldThrow) {
|
||||
Scheduler.unstable_yieldValue('throwing: ' + message);
|
||||
Scheduler.log('throwing: ' + message);
|
||||
throw new Error(message);
|
||||
}
|
||||
return children;
|
||||
@@ -4186,9 +4168,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
@@ -4250,7 +4230,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
};
|
||||
});
|
||||
}
|
||||
Scheduler.unstable_yieldValue('suspending');
|
||||
Scheduler.log('suspending');
|
||||
throw promise;
|
||||
}
|
||||
return null;
|
||||
@@ -4258,7 +4238,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
function ThrowUntilOnClient({children, message}) {
|
||||
if (isClient && shouldThrow) {
|
||||
Scheduler.unstable_yieldValue('throwing: ' + message);
|
||||
Scheduler.log('throwing: ' + message);
|
||||
throw new Error(message);
|
||||
}
|
||||
return children;
|
||||
@@ -4309,9 +4289,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Logged recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Logged recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
|
||||
@@ -129,7 +129,7 @@ describe('ReactDOMFizzShellHydration', () => {
|
||||
return record.value;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -153,13 +153,13 @@ describe('ReactDOMFizzShellHydration', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text}) {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ describe('ReactDOMFizzShellHydration', () => {
|
||||
const root = await clientAct(async () => {
|
||||
return ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
+12
-12
@@ -156,7 +156,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
// Don't miss a hydration error. There should be none.
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -196,7 +196,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -237,7 +237,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -284,7 +284,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -320,7 +320,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -368,7 +368,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -419,7 +419,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -468,7 +468,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -522,7 +522,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -559,7 +559,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -592,7 +592,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
@@ -638,7 +638,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
|
||||
);
|
||||
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await expect(async () => {
|
||||
|
||||
@@ -29,12 +29,12 @@ let waitFor;
|
||||
let assertLog;
|
||||
|
||||
function PhaseMarkers({children}) {
|
||||
Scheduler.unstable_yieldValue('render start');
|
||||
Scheduler.log('render start');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('last layout');
|
||||
Scheduler.log('last layout');
|
||||
});
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('last passive');
|
||||
Scheduler.log('last passive');
|
||||
});
|
||||
return children;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ function last(arr) {
|
||||
}
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ function Text(props) {
|
||||
// const text = props.text;
|
||||
// try {
|
||||
// TextResource.read([props.text, props.ms]);
|
||||
// Scheduler.unstable_yieldValue(text);
|
||||
// Scheduler.log(text);
|
||||
// return text;
|
||||
// } catch (promise) {
|
||||
// if (typeof promise.then === 'function') {
|
||||
// Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
// Scheduler.log(`Suspend! [${text}]`);
|
||||
// } else {
|
||||
// Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
// Scheduler.log(`Error! [${text}]`);
|
||||
// }
|
||||
// throw promise;
|
||||
// }
|
||||
@@ -72,12 +72,12 @@ function Text(props) {
|
||||
|
||||
function Img({src: maybeSrc, onLoad, useImageLoader, ref}) {
|
||||
const src = maybeSrc || 'default';
|
||||
Scheduler.unstable_yieldValue('Img ' + src);
|
||||
Scheduler.log('Img ' + src);
|
||||
return <img src={src} onLoad={onLoad} />;
|
||||
}
|
||||
|
||||
function Yield() {
|
||||
Scheduler.unstable_yieldValue('Yield');
|
||||
Scheduler.log('Yield');
|
||||
Scheduler.unstable_requestPaint();
|
||||
return null;
|
||||
}
|
||||
@@ -105,12 +105,12 @@ describe('ReactDOMImageLoad', () => {
|
||||
|
||||
onLoadSpy = jest.fn(reactEvent => {
|
||||
const src = reactEvent.target.getAttribute('src');
|
||||
Scheduler.unstable_yieldValue('onLoadSpy [' + src + ']');
|
||||
Scheduler.log('onLoadSpy [' + src + ']');
|
||||
});
|
||||
|
||||
actualLoadSpy = jest.fn(nativeEvent => {
|
||||
const src = nativeEvent.target.getAttribute('src');
|
||||
Scheduler.unstable_yieldValue('actualLoadSpy [' + src + ']');
|
||||
Scheduler.log('actualLoadSpy [' + src + ']');
|
||||
nativeEvent.__originalDispatch = false;
|
||||
});
|
||||
|
||||
@@ -127,14 +127,14 @@ describe('ReactDOMImageLoad', () => {
|
||||
// listeners = [{resolve, reject}];
|
||||
// setTimeout(() => {
|
||||
// if (textResourceShouldFail) {
|
||||
// Scheduler.unstable_yieldValue(
|
||||
// Scheduler.log(
|
||||
// `Promise rejected [${text}]`,
|
||||
// );
|
||||
// status = 'rejected';
|
||||
// value = new Error('Failed to load: ' + text);
|
||||
// listeners.forEach(listener => listener.reject(value));
|
||||
// } else {
|
||||
// Scheduler.unstable_yieldValue(
|
||||
// Scheduler.log(
|
||||
// `Promise resolved [${text}]`,
|
||||
// );
|
||||
// status = 'resolved';
|
||||
@@ -185,7 +185,7 @@ describe('ReactDOMImageLoad', () => {
|
||||
return this.getAttribute('src');
|
||||
},
|
||||
set(value) {
|
||||
Scheduler.unstable_yieldValue('load triggered');
|
||||
Scheduler.log('load triggered');
|
||||
this.__needsDispatch = true;
|
||||
this.setAttribute('src', value);
|
||||
},
|
||||
@@ -438,7 +438,7 @@ describe('ReactDOMImageLoad', () => {
|
||||
|
||||
// it('captures the load event if it happens in a suspended subtree and replays it between layout and passive effects on resumption', async function() {
|
||||
// function SuspendingWithImage() {
|
||||
// Scheduler.unstable_yieldValue('SuspendingWithImage');
|
||||
// Scheduler.log('SuspendingWithImage');
|
||||
// return (
|
||||
// <Suspense fallback={<Text text="Loading..." />}>
|
||||
// <AsyncText text="A" ms={100} />
|
||||
@@ -511,9 +511,9 @@ describe('ReactDOMImageLoad', () => {
|
||||
}
|
||||
|
||||
function YieldingWithImage({src}) {
|
||||
Scheduler.unstable_yieldValue('YieldingWithImage');
|
||||
Scheduler.log('YieldingWithImage');
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Committed');
|
||||
Scheduler.log('Committed');
|
||||
});
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -287,7 +287,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
|
||||
const target = React.createRef(null);
|
||||
function Foo({hovered}) {
|
||||
const hoverString = hovered ? 'hovered' : 'not hovered';
|
||||
Scheduler.unstable_yieldValue(hoverString);
|
||||
Scheduler.log(hoverString);
|
||||
return <div ref={target}>{hoverString}</div>;
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
|
||||
ReactDOM.unstable_batchedUpdates(() => {
|
||||
setCount(count + 1);
|
||||
});
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
container.textContent + ' [after batchedUpdates]',
|
||||
);
|
||||
};
|
||||
|
||||
@@ -41,9 +41,7 @@ describe('ReactDOMNestedEvents', () => {
|
||||
// The update triggered by the focus event should not have flushed yet.
|
||||
// Nor the click update. They would have if we had wrapped the focus
|
||||
// call in `flushSync`, though.
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Value right after focus call: ' + el.innerHTML,
|
||||
);
|
||||
Scheduler.log('Value right after focus call: ' + el.innerHTML);
|
||||
};
|
||||
const onFocus = () => {
|
||||
setIsFocused(true);
|
||||
|
||||
+2
-2
@@ -258,7 +258,7 @@ describe('ReactDOMRoot', () => {
|
||||
it('callback passed to legacy hydrate() API', () => {
|
||||
container.innerHTML = '<div>Hi</div>';
|
||||
ReactDOM.hydrate(<div>Hi</div>, container, () => {
|
||||
Scheduler.unstable_yieldValue('callback');
|
||||
Scheduler.log('callback');
|
||||
});
|
||||
expect(container.textContent).toEqual('Hi');
|
||||
assertLog(['callback']);
|
||||
@@ -394,7 +394,7 @@ describe('ReactDOMRoot', () => {
|
||||
});
|
||||
|
||||
function Foo({value}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return <div>{value}</div>;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ let useDebugValue;
|
||||
let forwardRef;
|
||||
let yieldedValues;
|
||||
let yieldValue;
|
||||
let clearYields;
|
||||
let clearLog;
|
||||
|
||||
function initModules() {
|
||||
// Reset warning cache.
|
||||
@@ -59,7 +59,7 @@ function initModules() {
|
||||
yieldValue = value => {
|
||||
yieldedValues.push(value);
|
||||
};
|
||||
clearYields = () => {
|
||||
clearLog = () => {
|
||||
const ret = yieldedValues;
|
||||
yieldedValues = [];
|
||||
return ret;
|
||||
@@ -207,7 +207,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
|
||||
expect(clearYields()).toEqual(['Render: 0', 0]);
|
||||
expect(clearLog()).toEqual(['Render: 0', 0]);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('0');
|
||||
});
|
||||
@@ -224,7 +224,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
|
||||
expect(clearYields()).toEqual(['Render: 1', 1]);
|
||||
expect(clearLog()).toEqual(['Render: 1', 1]);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('1');
|
||||
});
|
||||
@@ -246,7 +246,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
|
||||
expect(clearYields()).toEqual([
|
||||
expect(clearLog()).toEqual([
|
||||
'Render: 0',
|
||||
'Render: 1',
|
||||
'Render: 2',
|
||||
@@ -299,7 +299,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
|
||||
expect(clearYields()).toEqual([
|
||||
expect(clearLog()).toEqual([
|
||||
// The count should increase by alternating amounts of 10 and 1
|
||||
// until we reach 21.
|
||||
'Render: 0',
|
||||
@@ -326,7 +326,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<CapitalizedText text="hello" />);
|
||||
expect(clearYields()).toEqual(["Capitalize 'hello'", 'HELLO']);
|
||||
expect(clearLog()).toEqual(["Capitalize 'hello'", 'HELLO']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('HELLO');
|
||||
});
|
||||
@@ -343,7 +343,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<LazyCompute compute={computeA} />);
|
||||
expect(clearYields()).toEqual(['compute A', 'A']);
|
||||
expect(clearLog()).toEqual(['compute A', 'A']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('A');
|
||||
});
|
||||
@@ -365,7 +365,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<CapitalizedText text="hello" />);
|
||||
expect(clearYields()).toEqual([
|
||||
expect(clearLog()).toEqual([
|
||||
"Capitalize 'hello'",
|
||||
"Capitalize 'hello, world.'",
|
||||
'HELLO, WORLD.',
|
||||
@@ -399,7 +399,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<CapitalizedText text="hello" />);
|
||||
expect(clearYields()).toEqual([
|
||||
expect(clearLog()).toEqual([
|
||||
"Capitalize 'hello'",
|
||||
0,
|
||||
1,
|
||||
@@ -470,7 +470,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
expect(clearYields()).toEqual([0, 1, 2, 3]);
|
||||
expect(clearLog()).toEqual([0, 1, 2, 3]);
|
||||
expect(domNode.textContent).toEqual('Count: 3');
|
||||
},
|
||||
);
|
||||
@@ -500,7 +500,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<Counter />);
|
||||
expect(clearYields()).toEqual([0, 1, 2, 3]);
|
||||
expect(clearLog()).toEqual([0, 1, 2, 3]);
|
||||
expect(domNode.textContent).toEqual('Count: 3');
|
||||
},
|
||||
);
|
||||
@@ -517,7 +517,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<Counter count={0} />);
|
||||
yields.push(clearYields());
|
||||
yields.push(clearLog());
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 0');
|
||||
});
|
||||
@@ -542,7 +542,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
return <Text text={'Count: ' + props.count} />;
|
||||
}
|
||||
const domNode = await render(<Counter count={0} />);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 0');
|
||||
});
|
||||
@@ -555,7 +555,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
return <Text text={renderCount(3)} />;
|
||||
}
|
||||
const domNode = await render(<Counter count={2} />);
|
||||
expect(clearYields()).toEqual(['Count: 5']);
|
||||
expect(clearLog()).toEqual(['Count: 5']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 5');
|
||||
});
|
||||
@@ -578,7 +578,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<CapitalizedText text="hello" />);
|
||||
const [first, second, third, fourth, result] = clearYields();
|
||||
const [first, second, third, fourth, result] = clearLog();
|
||||
expect(first).toBe(second);
|
||||
expect(second).toBe(third);
|
||||
expect(third).not.toBe(fourth);
|
||||
@@ -603,7 +603,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
const domNode = await serverRender(
|
||||
<Counter label="Count" ref={counter} />,
|
||||
);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 0');
|
||||
});
|
||||
@@ -618,7 +618,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
return <Text text="Count: 0" />;
|
||||
}
|
||||
const domNode = await serverRender(<Counter />, 1);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 0');
|
||||
});
|
||||
@@ -634,7 +634,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
return <Text text="Count: 0" />;
|
||||
}
|
||||
const domNode = await serverRender(<Counter />, 1);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
expect(domNode.tagName).toEqual('SPAN');
|
||||
expect(domNode.textContent).toEqual('Count: 0');
|
||||
});
|
||||
@@ -738,7 +738,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<App foo={1} bar={3} baz={5} />);
|
||||
expect(clearYields()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
|
||||
expect(clearLog()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
|
||||
expect(domNode.childNodes.length).toBe(2);
|
||||
expect(domNode.firstChild.tagName).toEqual('SPAN');
|
||||
expect(domNode.firstChild.textContent).toEqual('Foo: 1, Bar: 3');
|
||||
@@ -834,7 +834,7 @@ describe('ReactDOMServerHooks', () => {
|
||||
}
|
||||
|
||||
const domNode = await render(<App foo={1} bar={3} baz={5} />);
|
||||
expect(clearYields()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
|
||||
expect(clearLog()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
|
||||
expect(domNode.childNodes.length).toBe(2);
|
||||
expect(domNode.firstChild.tagName).toEqual('SPAN');
|
||||
expect(domNode.firstChild.textContent).toEqual('Foo: 1, Bar: 3');
|
||||
|
||||
+9
-11
@@ -19,8 +19,8 @@ let ReactTestUtils;
|
||||
let forwardRef;
|
||||
let memo;
|
||||
let yieldedValues;
|
||||
let unstable_yieldValue;
|
||||
let clearYields;
|
||||
let log;
|
||||
let clearLog;
|
||||
|
||||
function initModules() {
|
||||
// Reset warning cache.
|
||||
@@ -33,10 +33,10 @@ function initModules() {
|
||||
memo = React.memo;
|
||||
|
||||
yieldedValues = [];
|
||||
unstable_yieldValue = value => {
|
||||
log = value => {
|
||||
yieldedValues.push(value);
|
||||
};
|
||||
clearYields = () => {
|
||||
clearLog = () => {
|
||||
const ret = yieldedValues;
|
||||
yieldedValues = [];
|
||||
return ret;
|
||||
@@ -93,7 +93,7 @@ describe('ReactDOMServerIntegration', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
unstable_yieldValue(text);
|
||||
log(text);
|
||||
return <span>{text}</span>;
|
||||
}
|
||||
|
||||
@@ -115,27 +115,25 @@ describe('ReactDOMServerIntegration', () => {
|
||||
ref.current = 0;
|
||||
await render(<MemoRefCounter ref={ref} />);
|
||||
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
});
|
||||
|
||||
itRenders('with comparator', async render => {
|
||||
const MemoCounter = memo(Counter, (oldProps, newProps) => false);
|
||||
await render(<MemoCounter count={0} />);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
});
|
||||
|
||||
itRenders(
|
||||
'comparator functions are not invoked on the server',
|
||||
async render => {
|
||||
const MemoCounter = React.memo(Counter, (oldProps, newProps) => {
|
||||
unstable_yieldValue(
|
||||
`Old count: ${oldProps.count}, New count: ${newProps.count}`,
|
||||
);
|
||||
log(`Old count: ${oldProps.count}, New count: ${newProps.count}`);
|
||||
return oldProps.count === newProps.count;
|
||||
});
|
||||
|
||||
await render(<MemoCounter count={0} />);
|
||||
expect(clearYields()).toEqual(['Count: 0']);
|
||||
expect(clearLog()).toEqual(['Count: 0']);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -234,7 +234,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
suspend = true;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
Scheduler.unstable_flushAll();
|
||||
@@ -271,15 +271,15 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
});
|
||||
function Child() {
|
||||
if (suspend) {
|
||||
Scheduler.unstable_yieldValue('Suspend');
|
||||
Scheduler.log('Suspend');
|
||||
throw promise;
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Hello');
|
||||
Scheduler.log('Hello');
|
||||
return 'Hello';
|
||||
}
|
||||
}
|
||||
function Component({shouldMismatch}) {
|
||||
Scheduler.unstable_yieldValue('Component');
|
||||
Scheduler.log('Component');
|
||||
if (shouldMismatch && client) {
|
||||
return <article>Mismatch</article>;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([
|
||||
@@ -435,7 +435,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
deleted.push(node);
|
||||
},
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
await waitForAll([]);
|
||||
@@ -513,7 +513,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
act(() => {
|
||||
ReactDOMClient.hydrateRoot(container, <App hasB={false} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -639,7 +639,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
act(() => {
|
||||
ReactDOMClient.hydrateRoot(container, <App hasB={false} />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1086,7 +1086,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
<App text="Hello" className="hello" />,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -1165,7 +1165,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
<App text="Hello" className="hello" />,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -1242,7 +1242,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
<App text="Hello" className="hello" />,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -1367,7 +1367,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
function Child() {
|
||||
const [state, setState] = React.useState('Hello');
|
||||
updateText = setState;
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
if (suspend) {
|
||||
throw promise;
|
||||
} else {
|
||||
@@ -1376,7 +1376,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
}
|
||||
|
||||
function Sibling() {
|
||||
Scheduler.unstable_yieldValue('Sibling');
|
||||
Scheduler.log('Sibling');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1559,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
</Context.Provider>,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -1635,7 +1635,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
suspend = false;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
if (__DEV__) {
|
||||
@@ -1708,7 +1708,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
suspend = false;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
if (__DEV__) {
|
||||
@@ -1786,7 +1786,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
suspend = false;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
if (__DEV__) {
|
||||
@@ -1994,12 +1994,12 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
}
|
||||
|
||||
function Before() {
|
||||
Scheduler.unstable_yieldValue('Before');
|
||||
Scheduler.log('Before');
|
||||
return null;
|
||||
}
|
||||
|
||||
function After() {
|
||||
Scheduler.unstable_yieldValue('After');
|
||||
Scheduler.log('After');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2106,7 +2106,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2182,7 +2182,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
suspend = false;
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
if (__DEV__) {
|
||||
@@ -2299,7 +2299,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
</ClassName.Provider>,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -2980,15 +2980,15 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
if (suspend) {
|
||||
throw promise;
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return 'Hello';
|
||||
}
|
||||
}
|
||||
|
||||
function Sibling() {
|
||||
Scheduler.unstable_yieldValue('Sibling');
|
||||
Scheduler.log('Sibling');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit Sibling');
|
||||
Scheduler.log('Commit Sibling');
|
||||
});
|
||||
return 'World';
|
||||
}
|
||||
@@ -3175,9 +3175,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Log recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Log recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3280,12 +3278,12 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
const visibleRef = React.createRef();
|
||||
|
||||
function HiddenChild() {
|
||||
Scheduler.unstable_yieldValue('HiddenChild');
|
||||
Scheduler.log('HiddenChild');
|
||||
return <span>Hidden</span>;
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<>
|
||||
<span ref={visibleRef}>Visible</span>
|
||||
@@ -3422,9 +3420,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
act(() => {
|
||||
ReactDOMClient.hydrateRoot(container, <App />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Log recoverable error: ' + error.message,
|
||||
);
|
||||
Scheduler.log('Log recoverable error: ' + error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -3474,7 +3470,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
act(() => {
|
||||
ReactDOMClient.hydrateRoot(container, <DirectTextChild text="bad" />, {
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -3518,7 +3514,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
<TextChildWithSibling text="bad" />,
|
||||
{
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue(error.message);
|
||||
Scheduler.log(error.message);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
+96
-98
@@ -154,12 +154,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
it('hydrates the target boundary synchronously during a click', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -167,7 +167,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -222,12 +222,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -235,7 +235,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -318,12 +318,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -331,7 +331,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -429,11 +429,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
function Child({text}) {
|
||||
const ref = React.useRef(null);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
if (!isServerRendering) {
|
||||
React.useLayoutEffect(() => {
|
||||
return setClick(ref.current, () => {
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -442,7 +442,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -502,12 +502,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
|
||||
if (!isServerRendering) {
|
||||
React.useLayoutEffect(() => {
|
||||
return setClick(ref.current, () => {
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -516,7 +516,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -599,12 +599,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
|
||||
if (!isServerRendering) {
|
||||
React.useLayoutEffect(() => {
|
||||
return setClick(ref.current, () => {
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -612,7 +612,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -708,16 +708,16 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Hover ' + text);
|
||||
Scheduler.log('Hover ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -725,7 +725,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -819,44 +819,44 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
id={text}
|
||||
onClickCapture={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Capture Clicked ' + text);
|
||||
Scheduler.log('Capture Clicked ' + text);
|
||||
}}
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Mouse Enter ' + text);
|
||||
Scheduler.log('Mouse Enter ' + text);
|
||||
}}
|
||||
onMouseOut={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Mouse Out ' + text);
|
||||
Scheduler.log('Mouse Out ' + text);
|
||||
}}
|
||||
onMouseOutCapture={e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
Scheduler.unstable_yieldValue('Mouse Out Capture ' + text);
|
||||
Scheduler.log('Mouse Out Capture ' + text);
|
||||
}}
|
||||
onMouseOverCapture={e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
Scheduler.unstable_yieldValue('Mouse Over Capture ' + text);
|
||||
Scheduler.log('Mouse Over Capture ' + text);
|
||||
}}
|
||||
onMouseOver={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Mouse Over ' + text);
|
||||
Scheduler.log('Mouse Over ' + text);
|
||||
}}>
|
||||
<div
|
||||
onMouseOverCapture={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Mouse Over Capture Inner ' + text);
|
||||
Scheduler.log('Mouse Over Capture Inner ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</div>
|
||||
@@ -865,15 +865,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div
|
||||
onClickCapture={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Capture Clicked Parent');
|
||||
Scheduler.log('Capture Clicked Parent');
|
||||
}}
|
||||
onMouseOverCapture={e => {
|
||||
Scheduler.unstable_yieldValue('Mouse Over Capture Parent');
|
||||
Scheduler.log('Mouse Over Capture Parent');
|
||||
}}>
|
||||
<Suspense fallback="Loading...">
|
||||
<Child text="A" />
|
||||
@@ -1028,16 +1028,16 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
function Outer() {
|
||||
if (suspendOuter) {
|
||||
OuterScheduler.unstable_yieldValue('Suspend Outer');
|
||||
OuterScheduler.log('Suspend Outer');
|
||||
throw outerPromise;
|
||||
}
|
||||
OuterScheduler.unstable_yieldValue('Outer');
|
||||
OuterScheduler.log('Outer');
|
||||
const innerRoot = outerContainer.querySelector('#inner-root');
|
||||
return (
|
||||
<div
|
||||
id="inner-root"
|
||||
onMouseEnter={() => {
|
||||
Scheduler.unstable_yieldValue('Outer Mouse Enter');
|
||||
Scheduler.log('Outer Mouse Enter');
|
||||
}}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: innerRoot ? innerRoot.innerHTML : '',
|
||||
@@ -1062,15 +1062,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
function Inner() {
|
||||
if (suspendInner) {
|
||||
InnerScheduler.unstable_yieldValue('Suspend Inner');
|
||||
InnerScheduler.log('Suspend Inner');
|
||||
throw innerPromise;
|
||||
}
|
||||
InnerScheduler.unstable_yieldValue('Inner');
|
||||
InnerScheduler.log('Inner');
|
||||
return (
|
||||
<div
|
||||
id="inner"
|
||||
onMouseEnter={() => {
|
||||
Scheduler.unstable_yieldValue('Inner Mouse Enter');
|
||||
Scheduler.log('Inner Mouse Enter');
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -1092,8 +1092,8 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
const innerHTML = ReactDOMServer.renderToString(<InnerApp />);
|
||||
innerContainer.innerHTML = innerHTML;
|
||||
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
|
||||
|
||||
suspendOuter = true;
|
||||
suspendInner = true;
|
||||
@@ -1103,8 +1103,8 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
OuterScheduler.unstable_flushAllWithoutAsserting();
|
||||
InnerScheduler.unstable_flushAllWithoutAsserting();
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual(['Suspend Inner']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
|
||||
|
||||
innerDiv = document.querySelector('#inner');
|
||||
|
||||
@@ -1117,7 +1117,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
InnerScheduler.unstable_flushAllWithoutAsserting();
|
||||
});
|
||||
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
|
||||
if (
|
||||
gate(
|
||||
flags =>
|
||||
@@ -1126,12 +1126,10 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
) {
|
||||
// InnerApp doesn't see the event because OuterApp calls stopPropagation in
|
||||
// capture phase since the event is blocked on suspended component
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual([]);
|
||||
} else {
|
||||
// no stopPropagation
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([
|
||||
'Suspend Inner',
|
||||
]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
|
||||
}
|
||||
|
||||
assertLog([]);
|
||||
@@ -1153,15 +1151,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
InnerScheduler.unstable_flushAllWithoutAsserting();
|
||||
});
|
||||
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
|
||||
// Inner App renders because it is unblocked
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
|
||||
// No event is replayed yet
|
||||
assertLog([]);
|
||||
|
||||
dispatchMouseHoverEvent(innerDiv);
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual([]);
|
||||
// No event is replayed yet
|
||||
assertLog([]);
|
||||
|
||||
@@ -1176,9 +1174,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
// Nothing happens to inner app yet.
|
||||
// Its blocked on the outer app replaying the event
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual([]);
|
||||
// Outer hydrates and schedules Replay
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
|
||||
// No event is replayed yet
|
||||
assertLog([]);
|
||||
|
||||
@@ -1207,9 +1205,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
|
||||
// Outer resolves and scheduled replay
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
|
||||
// Inner App is still blocked
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual([]);
|
||||
|
||||
// Replay outer event
|
||||
await act(async () => {
|
||||
@@ -1221,12 +1219,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
// Inner is still blocked so when Outer replays the event in capture phase
|
||||
// inner ends up caling stopPropagation
|
||||
assertLog([]);
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual(['Suspend Inner']);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
|
||||
|
||||
dispatchMouseHoverEvent(innerDiv);
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual([]);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual([]);
|
||||
assertLog([]);
|
||||
|
||||
await act(async () => {
|
||||
@@ -1238,9 +1236,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
|
||||
// Inner hydrates
|
||||
expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
|
||||
expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
|
||||
// Outer was hydrated earlier
|
||||
expect(OuterScheduler.unstable_clearYields()).toEqual([]);
|
||||
expect(OuterScheduler.unstable_clearLog()).toEqual([]);
|
||||
|
||||
await act(async () => {
|
||||
Scheduler.unstable_flushAllWithoutAsserting();
|
||||
@@ -1268,11 +1266,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if (suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return (
|
||||
<div
|
||||
onMouseOver={() => {
|
||||
Scheduler.unstable_yieldValue('on mouse over');
|
||||
Scheduler.log('on mouse over');
|
||||
}}>
|
||||
Child
|
||||
</div>
|
||||
@@ -1315,7 +1313,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
const container2 = document.createElement('div');
|
||||
container2.addEventListener('mouseover', () => {
|
||||
Scheduler.unstable_yieldValue('container2 mouse over');
|
||||
Scheduler.log('container2 mouse over');
|
||||
});
|
||||
container2.appendChild(childDiv);
|
||||
},
|
||||
@@ -1338,12 +1336,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if ((text === 'A' || text === 'D') && suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onMouseEnter={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Hover ' + text);
|
||||
Scheduler.log('Hover ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -1351,7 +1349,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -1417,12 +1415,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
it('hydrates the last explicitly hydrated target at higher priority', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span>{text}</span>;
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -1465,7 +1463,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
// @gate experimental || www
|
||||
it('hydrates before an update even if hydration moves away from it', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span>{text}</span>;
|
||||
}
|
||||
const ChildWithBoundary = React.memo(function ({text}) {
|
||||
@@ -1478,9 +1476,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
|
||||
function App({a}) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
@@ -1574,24 +1572,24 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
it('fires capture event handlers and native events if content is hydratable during discrete event', async () => {
|
||||
spyOnDev(console, 'error');
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
const ref = React.useRef();
|
||||
React.useLayoutEffect(() => {
|
||||
if (!ref.current) {
|
||||
return;
|
||||
}
|
||||
ref.current.onclick = () => {
|
||||
Scheduler.unstable_yieldValue('Native Click ' + text);
|
||||
Scheduler.log('Native Click ' + text);
|
||||
};
|
||||
}, [text]);
|
||||
return (
|
||||
<span
|
||||
ref={ref}
|
||||
onClickCapture={() => {
|
||||
Scheduler.unstable_yieldValue('Capture Clicked ' + text);
|
||||
Scheduler.log('Capture Clicked ' + text);
|
||||
}}
|
||||
onClick={e => {
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -1599,7 +1597,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback="Loading...">
|
||||
@@ -1658,7 +1656,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if (suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return (
|
||||
<span
|
||||
onClickCapture={e => {
|
||||
@@ -1673,7 +1671,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
const onClick = () => {
|
||||
triggeredParent = true;
|
||||
};
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div
|
||||
ref={n => {
|
||||
@@ -1719,12 +1717,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
if (suspend) {
|
||||
throw promise;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return (
|
||||
<span
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
Scheduler.unstable_yieldValue('Clicked ' + text);
|
||||
Scheduler.log('Clicked ' + text);
|
||||
}}>
|
||||
{text}
|
||||
</span>
|
||||
@@ -1732,7 +1730,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<div>
|
||||
<Child text="A" />
|
||||
@@ -1790,11 +1788,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
it('can force hydration in response to sync update', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(`Child ${text}`);
|
||||
Scheduler.log(`Child ${text}`);
|
||||
return <span ref={ref => (spanRef = ref)}>{text}</span>;
|
||||
}
|
||||
function App({text}) {
|
||||
Scheduler.unstable_yieldValue(`App ${text}`);
|
||||
Scheduler.log(`App ${text}`);
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback={null}>
|
||||
@@ -1826,11 +1824,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
// @gate experimental || www
|
||||
it('can force hydration in response to continuous update', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(`Child ${text}`);
|
||||
Scheduler.log(`Child ${text}`);
|
||||
return <span ref={ref => (spanRef = ref)}>{text}</span>;
|
||||
}
|
||||
function App({text}) {
|
||||
Scheduler.unstable_yieldValue(`App ${text}`);
|
||||
Scheduler.log(`App ${text}`);
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback={null}>
|
||||
@@ -1862,11 +1860,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
it('can force hydration in response to default update', async () => {
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(`Child ${text}`);
|
||||
Scheduler.log(`Child ${text}`);
|
||||
return <span ref={ref => (spanRef = ref)}>{text}</span>;
|
||||
}
|
||||
function App({text}) {
|
||||
Scheduler.unstable_yieldValue(`App ${text}`);
|
||||
Scheduler.log(`App ${text}`);
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback={null}>
|
||||
@@ -1898,12 +1896,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
function ContextReader(props) {
|
||||
const value = React.useContext(Context);
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span>{text}</span>;
|
||||
}
|
||||
const ChildWithBoundary = React.memo(function ({text}) {
|
||||
@@ -1915,9 +1913,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
|
||||
function App({a}) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<>
|
||||
@@ -1956,12 +1954,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
|
||||
function ContextReader(props) {
|
||||
const value = React.useContext(Context);
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span>{text}</span>;
|
||||
}
|
||||
const ChildWithBoundary = React.memo(function ({text}) {
|
||||
@@ -1973,9 +1971,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
|
||||
});
|
||||
|
||||
function App({a}) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -55,202 +55,152 @@ describe('ReactErrorBoundaries', () => {
|
||||
BrokenConstructor = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor constructor [!]');
|
||||
Scheduler.log('BrokenConstructor constructor [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor render');
|
||||
Scheduler.log('BrokenConstructor render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor componentWillMount');
|
||||
Scheduler.log('BrokenConstructor componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor componentDidMount');
|
||||
Scheduler.log('BrokenConstructor componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenConstructor componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenConstructor componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor componentWillUpdate');
|
||||
Scheduler.log('BrokenConstructor componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor componentDidUpdate');
|
||||
Scheduler.log('BrokenConstructor componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('BrokenConstructor componentWillUnmount');
|
||||
Scheduler.log('BrokenConstructor componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
BrokenComponentWillMount = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillMount constructor');
|
||||
Scheduler.log('BrokenComponentWillMount constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillMount render');
|
||||
Scheduler.log('BrokenComponentWillMount render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentWillMount [!]',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentWillMount [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentWillUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentDidUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMount componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
BrokenComponentDidMount = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenComponentDidMount constructor');
|
||||
Scheduler.log('BrokenComponentDidMount constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentDidMount render');
|
||||
Scheduler.log('BrokenComponentDidMount render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentDidMount [!]',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentDidMount [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentWillUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentDidUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMount componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
BrokenComponentWillReceiveProps = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps constructor',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillReceiveProps render');
|
||||
Scheduler.log('BrokenComponentWillReceiveProps render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentWillReceiveProps componentWillReceiveProps [!]',
|
||||
);
|
||||
throw new Error('Hello');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps componentWillUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps componentDidUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillReceiveProps componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillReceiveProps componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
BrokenComponentWillUpdate = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillUpdate constructor');
|
||||
Scheduler.log('BrokenComponentWillUpdate constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillUpdate render');
|
||||
Scheduler.log('BrokenComponentWillUpdate render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentWillUpdate [!]',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentWillUpdate [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentDidUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUpdate componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUpdate componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -260,42 +210,30 @@ describe('ReactErrorBoundaries', () => {
|
||||
};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenComponentDidUpdate constructor');
|
||||
Scheduler.log('BrokenComponentDidUpdate constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentDidUpdate render');
|
||||
Scheduler.log('BrokenComponentDidUpdate render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentWillUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentDidUpdate [!]',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentDidUpdate [!]');
|
||||
throw new Error(this.props.errorText);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidUpdate componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidUpdate componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -305,41 +243,29 @@ describe('ReactErrorBoundaries', () => {
|
||||
};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillUnmount constructor');
|
||||
Scheduler.log('BrokenComponentWillUnmount constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillUnmount render');
|
||||
Scheduler.log('BrokenComponentWillUnmount render');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentWillReceiveProps',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentWillUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentDidUpdate',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentWillUnmount [!]',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentWillUnmount [!]');
|
||||
throw new Error(this.props.errorText);
|
||||
}
|
||||
};
|
||||
@@ -348,40 +274,34 @@ describe('ReactErrorBoundaries', () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {error: null};
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMountErrorBoundary constructor',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMountErrorBoundary constructor');
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMountErrorBoundary render error',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMountErrorBoundary render error');
|
||||
return <div>Caught an error: {this.state.error.message}.</div>;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillMountErrorBoundary render success',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillMountErrorBoundary render success');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentWillMountErrorBoundary componentWillMount [!]',
|
||||
);
|
||||
throw new Error('Hello');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentWillMountErrorBoundary componentDidMount',
|
||||
);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentWillMountErrorBoundary componentWillUnmount',
|
||||
);
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentWillMountErrorBoundary static getDerivedStateFromError',
|
||||
);
|
||||
return {error};
|
||||
@@ -392,40 +312,34 @@ describe('ReactErrorBoundaries', () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {error: null};
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMountErrorBoundary constructor',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMountErrorBoundary constructor');
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMountErrorBoundary render error',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMountErrorBoundary render error');
|
||||
return <div>Caught an error: {this.state.error.message}.</div>;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentDidMountErrorBoundary render success',
|
||||
);
|
||||
Scheduler.log('BrokenComponentDidMountErrorBoundary render success');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentDidMountErrorBoundary componentWillMount',
|
||||
);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentDidMountErrorBoundary componentDidMount [!]',
|
||||
);
|
||||
throw new Error('Hello');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentDidMountErrorBoundary componentWillUnmount',
|
||||
);
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenComponentDidMountErrorBoundary static getDerivedStateFromError',
|
||||
);
|
||||
return {error};
|
||||
@@ -436,37 +350,27 @@ describe('ReactErrorBoundaries', () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {error: null};
|
||||
Scheduler.unstable_yieldValue('BrokenRenderErrorBoundary constructor');
|
||||
Scheduler.log('BrokenRenderErrorBoundary constructor');
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderErrorBoundary render error [!]',
|
||||
);
|
||||
Scheduler.log('BrokenRenderErrorBoundary render error [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderErrorBoundary render success',
|
||||
);
|
||||
Scheduler.log('BrokenRenderErrorBoundary render success');
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderErrorBoundary componentWillMount',
|
||||
);
|
||||
Scheduler.log('BrokenRenderErrorBoundary componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderErrorBoundary componentDidMount',
|
||||
);
|
||||
Scheduler.log('BrokenRenderErrorBoundary componentDidMount');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderErrorBoundary componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenRenderErrorBoundary componentWillUnmount');
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'BrokenRenderErrorBoundary static getDerivedStateFromError',
|
||||
);
|
||||
return {error};
|
||||
@@ -476,37 +380,37 @@ describe('ReactErrorBoundaries', () => {
|
||||
BrokenRender = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('BrokenRender constructor');
|
||||
Scheduler.log('BrokenRender constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender render [!]');
|
||||
Scheduler.log('BrokenRender render [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentWillMount');
|
||||
Scheduler.log('BrokenRender componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentDidMount');
|
||||
Scheduler.log('BrokenRender componentDidMount');
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentWillReceiveProps');
|
||||
Scheduler.log('BrokenRender componentWillReceiveProps');
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentWillUpdate');
|
||||
Scheduler.log('BrokenRender componentWillUpdate');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentDidUpdate');
|
||||
Scheduler.log('BrokenRender componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('BrokenRender componentWillUnmount');
|
||||
Scheduler.log('BrokenRender componentWillUnmount');
|
||||
}
|
||||
};
|
||||
|
||||
BrokenUseEffect = ({children}) => {
|
||||
Scheduler.unstable_yieldValue('BrokenUseEffect render');
|
||||
Scheduler.log('BrokenUseEffect render');
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('BrokenUseEffect useEffect [!]');
|
||||
Scheduler.log('BrokenUseEffect useEffect [!]');
|
||||
throw new Error('Hello');
|
||||
});
|
||||
|
||||
@@ -514,12 +418,10 @@ describe('ReactErrorBoundaries', () => {
|
||||
};
|
||||
|
||||
BrokenUseLayoutEffect = ({children}) => {
|
||||
Scheduler.unstable_yieldValue('BrokenUseLayoutEffect render');
|
||||
Scheduler.log('BrokenUseLayoutEffect render');
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenUseLayoutEffect useLayoutEffect [!]',
|
||||
);
|
||||
Scheduler.log('BrokenUseLayoutEffect useLayoutEffect [!]');
|
||||
throw new Error('Hello');
|
||||
});
|
||||
|
||||
@@ -529,25 +431,23 @@ describe('ReactErrorBoundaries', () => {
|
||||
NoopErrorBoundary = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('NoopErrorBoundary constructor');
|
||||
Scheduler.log('NoopErrorBoundary constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('NoopErrorBoundary render');
|
||||
Scheduler.log('NoopErrorBoundary render');
|
||||
return <BrokenRender />;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue('NoopErrorBoundary componentWillMount');
|
||||
Scheduler.log('NoopErrorBoundary componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('NoopErrorBoundary componentDidMount');
|
||||
Scheduler.log('NoopErrorBoundary componentDidMount');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('NoopErrorBoundary componentWillUnmount');
|
||||
Scheduler.log('NoopErrorBoundary componentWillUnmount');
|
||||
}
|
||||
static getDerivedStateFromError() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'NoopErrorBoundary static getDerivedStateFromError',
|
||||
);
|
||||
Scheduler.log('NoopErrorBoundary static getDerivedStateFromError');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -557,41 +457,29 @@ describe('ReactErrorBoundaries', () => {
|
||||
};
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue(`${this.props.logName} constructor`);
|
||||
Scheduler.log(`${this.props.logName} constructor`);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.logName} render`);
|
||||
Scheduler.log(`${this.props.logName} render`);
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillMount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillMount`);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentDidMount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentDidMount`);
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillReceiveProps`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillReceiveProps`);
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillUpdate`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillUpdate`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentDidUpdate`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillUnmount`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -599,51 +487,37 @@ describe('ReactErrorBoundaries', () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {error: null};
|
||||
Scheduler.unstable_yieldValue(`${this.props.logName} constructor`);
|
||||
Scheduler.log(`${this.props.logName} constructor`);
|
||||
}
|
||||
render() {
|
||||
if (this.state.error && !this.props.forceRetry) {
|
||||
Scheduler.unstable_yieldValue(`${this.props.logName} render error`);
|
||||
Scheduler.log(`${this.props.logName} render error`);
|
||||
return this.props.renderError(this.state.error, this.props);
|
||||
}
|
||||
Scheduler.unstable_yieldValue(`${this.props.logName} render success`);
|
||||
Scheduler.log(`${this.props.logName} render success`);
|
||||
return <div>{this.props.children}</div>;
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ErrorBoundary static getDerivedStateFromError',
|
||||
);
|
||||
Scheduler.log('ErrorBoundary static getDerivedStateFromError');
|
||||
return {error};
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillMount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillMount`);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentDidMount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentDidMount`);
|
||||
}
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillReceiveProps`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillReceiveProps`);
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillUpdate`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillUpdate`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentDidUpdate`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.props.logName} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`${this.props.logName} componentWillUnmount`);
|
||||
}
|
||||
};
|
||||
ErrorBoundary.defaultProps = {
|
||||
@@ -660,27 +534,23 @@ describe('ReactErrorBoundaries', () => {
|
||||
RetryErrorBoundary = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('RetryErrorBoundary constructor');
|
||||
Scheduler.log('RetryErrorBoundary constructor');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('RetryErrorBoundary render');
|
||||
Scheduler.log('RetryErrorBoundary render');
|
||||
return <BrokenRender />;
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue('RetryErrorBoundary componentWillMount');
|
||||
Scheduler.log('RetryErrorBoundary componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('RetryErrorBoundary componentDidMount');
|
||||
Scheduler.log('RetryErrorBoundary componentDidMount');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'RetryErrorBoundary componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('RetryErrorBoundary componentWillUnmount');
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'RetryErrorBoundary static getDerivedStateFromError [!]',
|
||||
);
|
||||
Scheduler.log('RetryErrorBoundary static getDerivedStateFromError [!]');
|
||||
// In Fiber, calling setState() (and failing) is treated as a rethrow.
|
||||
return {};
|
||||
}
|
||||
@@ -689,19 +559,19 @@ describe('ReactErrorBoundaries', () => {
|
||||
ErrorMessage = class extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue('ErrorMessage constructor');
|
||||
Scheduler.log('ErrorMessage constructor');
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage componentWillMount');
|
||||
Scheduler.log('ErrorMessage componentWillMount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage componentDidMount');
|
||||
Scheduler.log('ErrorMessage componentDidMount');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage componentWillUnmount');
|
||||
Scheduler.log('ErrorMessage componentWillUnmount');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage render');
|
||||
Scheduler.log('ErrorMessage render');
|
||||
return <div>Caught an error: {this.props.message}.</div>;
|
||||
}
|
||||
};
|
||||
@@ -1146,10 +1016,10 @@ describe('ReactErrorBoundaries', () => {
|
||||
|
||||
it('resets callback refs if mounting aborts', () => {
|
||||
function childRef(x) {
|
||||
Scheduler.unstable_yieldValue('Child ref is set to ' + x);
|
||||
Scheduler.log('Child ref is set to ' + x);
|
||||
}
|
||||
function errorMessageRef(x) {
|
||||
Scheduler.unstable_yieldValue('Error message ref is set to ' + x);
|
||||
Scheduler.log('Error message ref is set to ' + x);
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
@@ -1246,7 +1116,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
</ErrorBoundary>,
|
||||
container,
|
||||
);
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal />
|
||||
@@ -1291,7 +1161,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal />
|
||||
@@ -1338,7 +1208,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal />
|
||||
@@ -1380,7 +1250,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal />
|
||||
@@ -1421,7 +1291,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal />
|
||||
@@ -1460,13 +1330,13 @@ describe('ReactErrorBoundaries', () => {
|
||||
|
||||
it('keeps refs up-to-date during updates', () => {
|
||||
function child1Ref(x) {
|
||||
Scheduler.unstable_yieldValue('Child1 ref is set to ' + x);
|
||||
Scheduler.log('Child1 ref is set to ' + x);
|
||||
}
|
||||
function child2Ref(x) {
|
||||
Scheduler.unstable_yieldValue('Child2 ref is set to ' + x);
|
||||
Scheduler.log('Child2 ref is set to ' + x);
|
||||
}
|
||||
function errorMessageRef(x) {
|
||||
Scheduler.unstable_yieldValue('Error message ref is set to ' + x);
|
||||
Scheduler.log('Error message ref is set to ' + x);
|
||||
}
|
||||
|
||||
const container = document.createElement('div');
|
||||
@@ -1530,7 +1400,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<BrokenComponentWillUnmount />
|
||||
@@ -1586,7 +1456,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<Normal>
|
||||
@@ -1655,7 +1525,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary
|
||||
logName="OuterErrorBoundary"
|
||||
@@ -1718,7 +1588,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
expect(container.textContent).toBe('Caught an error: Hello.');
|
||||
|
||||
// Force the success path:
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary forceRetry={true}>
|
||||
<Normal />
|
||||
@@ -1784,7 +1654,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
ReactDOM.render(<ErrorBoundary />, container);
|
||||
expect(container.textContent).toBe('Caught an error: Hello.');
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
assertLog(['ErrorBoundary componentWillUnmount']);
|
||||
});
|
||||
@@ -1802,7 +1672,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
);
|
||||
expect(container.textContent).toBe('Caught an error: Hello.');
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
assertLog(['ErrorBoundary componentWillUnmount']);
|
||||
});
|
||||
@@ -1850,7 +1720,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
);
|
||||
expect(container.textContent).toBe('Caught an error: Hello.');
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
assertLog(['ErrorBoundary componentWillUnmount']);
|
||||
});
|
||||
@@ -1862,7 +1732,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
|
||||
render() {
|
||||
if (fail) {
|
||||
Scheduler.unstable_yieldValue('Stateful render [!]');
|
||||
Scheduler.log('Stateful render [!]');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
return <div>{this.props.children}</div>;
|
||||
@@ -1878,7 +1748,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
expect(() => {
|
||||
fail = true;
|
||||
statefulInst.forceUpdate();
|
||||
@@ -1963,7 +1833,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary>
|
||||
<BrokenComponentDidUpdate />
|
||||
@@ -2010,7 +1880,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
]);
|
||||
|
||||
expect(container.firstChild.textContent).toBe('Initial value');
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
});
|
||||
|
||||
// verify flushed passive effects and handle the error
|
||||
@@ -2116,7 +1986,7 @@ describe('ReactErrorBoundaries', () => {
|
||||
container,
|
||||
);
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
ReactDOM.render(
|
||||
<ErrorBoundary logName="OuterErrorBoundary">
|
||||
<ErrorBoundary
|
||||
@@ -2489,19 +2359,17 @@ describe('ReactErrorBoundaries', () => {
|
||||
class LocalErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ErrorBoundary static getDerivedStateFromError`,
|
||||
);
|
||||
Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
|
||||
return {error};
|
||||
}
|
||||
render() {
|
||||
const {children, id, fallbackID} = this.props;
|
||||
const {error} = this.state;
|
||||
if (error) {
|
||||
Scheduler.unstable_yieldValue(`${id} render error`);
|
||||
Scheduler.log(`${id} render error`);
|
||||
return <Component id={fallbackID} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(`${id} render success`);
|
||||
Scheduler.log(`${id} render success`);
|
||||
return children || null;
|
||||
}
|
||||
}
|
||||
@@ -2509,21 +2377,19 @@ describe('ReactErrorBoundaries', () => {
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const {id} = this.props;
|
||||
Scheduler.unstable_yieldValue('Component render ' + id);
|
||||
Scheduler.log('Component render ' + id);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
class LocalBrokenComponentWillUnmount extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenComponentWillUnmount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenComponentWillUnmount componentWillUnmount');
|
||||
throw Error('Expected');
|
||||
}
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BrokenComponentWillUnmount render');
|
||||
Scheduler.log('BrokenComponentWillUnmount render');
|
||||
return 'broken';
|
||||
}
|
||||
}
|
||||
@@ -2573,19 +2439,17 @@ describe('ReactErrorBoundaries', () => {
|
||||
class LocalErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ErrorBoundary static getDerivedStateFromError`,
|
||||
);
|
||||
Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
|
||||
return {error};
|
||||
}
|
||||
render() {
|
||||
const {children, id, fallbackID} = this.props;
|
||||
const {error} = this.state;
|
||||
if (error) {
|
||||
Scheduler.unstable_yieldValue(`${id} render error`);
|
||||
Scheduler.log(`${id} render error`);
|
||||
return <Component id={fallbackID} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue(`${id} render success`);
|
||||
Scheduler.log(`${id} render success`);
|
||||
return children || null;
|
||||
}
|
||||
}
|
||||
@@ -2593,21 +2457,21 @@ describe('ReactErrorBoundaries', () => {
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
const {id} = this.props;
|
||||
Scheduler.unstable_yieldValue('Component render ' + id);
|
||||
Scheduler.log('Component render ' + id);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
class LocalBrokenCallbackRef extends React.Component {
|
||||
_ref = ref => {
|
||||
Scheduler.unstable_yieldValue('LocalBrokenCallbackRef ref ' + !!ref);
|
||||
Scheduler.log('LocalBrokenCallbackRef ref ' + !!ref);
|
||||
if (ref === null) {
|
||||
throw Error('Expected');
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('LocalBrokenCallbackRef render');
|
||||
Scheduler.log('LocalBrokenCallbackRef render');
|
||||
return <div ref={this._ref}>ref</div>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
it('can use act to flush effects', () => {
|
||||
function App() {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(100);
|
||||
Scheduler.log(100);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
function App() {
|
||||
const [ctr, setCtr] = React.useState(0);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(ctr);
|
||||
Scheduler.log(ctr);
|
||||
});
|
||||
return (
|
||||
<button id="button" onClick={() => setCtr(x => x + 1)}>
|
||||
@@ -213,7 +213,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
it('should flush effects only on exiting the outermost act', () => {
|
||||
function App() {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(0);
|
||||
Scheduler.log(0);
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
something();
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(state);
|
||||
Scheduler.log(state);
|
||||
});
|
||||
return state;
|
||||
}
|
||||
@@ -571,7 +571,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
setState(x => x + 1);
|
||||
}
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(state);
|
||||
Scheduler.log(state);
|
||||
ticker();
|
||||
}, [Math.min(state, 4)]);
|
||||
return state;
|
||||
@@ -644,7 +644,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
it('should cleanup after errors - sync', () => {
|
||||
function App() {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('oh yes');
|
||||
Scheduler.log('oh yes');
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@@ -671,7 +671,7 @@ function runActTests(label, render, unmount, rerender) {
|
||||
function App() {
|
||||
async function somethingAsync() {
|
||||
await null;
|
||||
Scheduler.unstable_yieldValue('oh yes');
|
||||
Scheduler.log('oh yes');
|
||||
}
|
||||
React.useEffect(() => {
|
||||
somethingAsync();
|
||||
|
||||
+9
-9
@@ -15,7 +15,7 @@ let act;
|
||||
let container;
|
||||
let yields;
|
||||
|
||||
function clearYields() {
|
||||
function clearLog() {
|
||||
try {
|
||||
return yields;
|
||||
} finally {
|
||||
@@ -60,7 +60,7 @@ it('can use act to flush effects', () => {
|
||||
render(<App />, container);
|
||||
});
|
||||
|
||||
expect(clearYields()).toEqual([100]);
|
||||
expect(clearLog()).toEqual([100]);
|
||||
});
|
||||
|
||||
// @gate __DEV__
|
||||
@@ -81,7 +81,7 @@ it('flushes effects on every call', () => {
|
||||
render(<App />, container);
|
||||
});
|
||||
|
||||
expect(clearYields()).toEqual([0]);
|
||||
expect(clearLog()).toEqual([0]);
|
||||
|
||||
const button = container.querySelector('#button');
|
||||
function click() {
|
||||
@@ -94,11 +94,11 @@ it('flushes effects on every call', () => {
|
||||
click();
|
||||
});
|
||||
// it consolidates the 3 updates, then fires the effect
|
||||
expect(clearYields()).toEqual([3]);
|
||||
expect(clearLog()).toEqual([3]);
|
||||
act(click);
|
||||
expect(clearYields()).toEqual([4]);
|
||||
expect(clearLog()).toEqual([4]);
|
||||
act(click);
|
||||
expect(clearYields()).toEqual([5]);
|
||||
expect(clearLog()).toEqual([5]);
|
||||
expect(button.innerHTML).toEqual('5');
|
||||
});
|
||||
|
||||
@@ -136,10 +136,10 @@ it('should flush effects only on exiting the outermost act', () => {
|
||||
});
|
||||
// the effect wouldn't have yielded yet because
|
||||
// we're still inside an act() scope
|
||||
expect(clearYields()).toEqual([]);
|
||||
expect(clearLog()).toEqual([]);
|
||||
});
|
||||
// but after exiting the last one, effects get flushed
|
||||
expect(clearYields()).toEqual([0]);
|
||||
expect(clearLog()).toEqual([0]);
|
||||
});
|
||||
|
||||
// @gate __DEV__
|
||||
@@ -163,6 +163,6 @@ it('can handle cascading promises', async () => {
|
||||
render(<App />, container);
|
||||
});
|
||||
// all 5 ticks present and accounted for
|
||||
expect(clearYields()).toEqual([0, 1, 2, 3, 4]);
|
||||
expect(clearLog()).toEqual([0, 1, 2, 3, 4]);
|
||||
expect(container.innerHTML).toBe('5');
|
||||
});
|
||||
|
||||
+8
-8
@@ -1331,7 +1331,7 @@ describe('ReactUpdates', () => {
|
||||
const container = document.createElement('div');
|
||||
|
||||
function Baz() {
|
||||
Scheduler.unstable_yieldValue('Baz');
|
||||
Scheduler.log('Baz');
|
||||
return <p>baz</p>;
|
||||
}
|
||||
|
||||
@@ -1339,14 +1339,14 @@ describe('ReactUpdates', () => {
|
||||
function Bar() {
|
||||
const [counter, _setCounter] = React.useState(0);
|
||||
setCounter = _setCounter;
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return <p>bar {counter}</p>;
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Foo#effect');
|
||||
Scheduler.log('Foo#effect');
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
@@ -1627,7 +1627,7 @@ describe('ReactUpdates', () => {
|
||||
const [step, setStep] = React.useState(0);
|
||||
React.useEffect(() => {
|
||||
setStep(x => x + 1);
|
||||
Scheduler.unstable_yieldValue(step);
|
||||
Scheduler.log(step);
|
||||
});
|
||||
return step;
|
||||
}
|
||||
@@ -1650,7 +1650,7 @@ describe('ReactUpdates', () => {
|
||||
ReactDOM.render(<App />, container);
|
||||
while (error === null) {
|
||||
Scheduler.unstable_flushNumberOfYields(1);
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
}
|
||||
expect(error).toContain('Warning: Maximum update depth exceeded.');
|
||||
expect(stack).toContain(' NonTerminating');
|
||||
@@ -1675,7 +1675,7 @@ describe('ReactUpdates', () => {
|
||||
setStep(x => x + 1);
|
||||
}
|
||||
});
|
||||
Scheduler.unstable_yieldValue(step);
|
||||
Scheduler.log(step);
|
||||
return step;
|
||||
}
|
||||
|
||||
@@ -1697,7 +1697,7 @@ describe('ReactUpdates', () => {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
setStep(x => x + 1);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Done');
|
||||
Scheduler.log('Done');
|
||||
}, []);
|
||||
return step;
|
||||
}
|
||||
|
||||
@@ -94,16 +94,16 @@ function readText(text) {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -127,14 +127,14 @@ function readText(text) {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span prop={text} />;
|
||||
}
|
||||
|
||||
function AsyncText({text, showVersion}) {
|
||||
const version = readText(text);
|
||||
const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return <span prop={fullText} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1959,7 +1959,7 @@ describe('DOMPluginEventSystem', () => {
|
||||
});
|
||||
});
|
||||
|
||||
Scheduler.unstable_yieldValue('Test');
|
||||
Scheduler.log('Test');
|
||||
return <button ref={ref}>Press me</button>;
|
||||
}
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ describe('ChangeEventPlugin', () => {
|
||||
state = {value: 'initial'};
|
||||
onChange = event => this.setState({value: event.target.value});
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
|
||||
Scheduler.log(`render: ${this.state.value}`);
|
||||
const controlledValue =
|
||||
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
|
||||
return (
|
||||
@@ -556,7 +556,7 @@ describe('ChangeEventPlugin', () => {
|
||||
this.setState({checked: event.target.checked});
|
||||
};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`render: ${this.state.checked}`);
|
||||
Scheduler.log(`render: ${this.state.checked}`);
|
||||
const controlledValue = this.props.reverse
|
||||
? !this.state.checked
|
||||
: this.state.checked;
|
||||
@@ -609,7 +609,7 @@ describe('ChangeEventPlugin', () => {
|
||||
state = {value: 'initial'};
|
||||
onChange = event => this.setState({value: event.target.value});
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
|
||||
Scheduler.log(`render: ${this.state.value}`);
|
||||
const controlledValue =
|
||||
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
|
||||
return (
|
||||
@@ -651,7 +651,7 @@ describe('ChangeEventPlugin', () => {
|
||||
state = {value: 'initial'};
|
||||
onChange = event => this.setState({value: event.target.value});
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
|
||||
Scheduler.log(`render: ${this.state.value}`);
|
||||
const controlledValue =
|
||||
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
|
||||
return (
|
||||
@@ -700,7 +700,7 @@ describe('ChangeEventPlugin', () => {
|
||||
this.setState({value: ''});
|
||||
};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
|
||||
Scheduler.log(`render: ${this.state.value}`);
|
||||
const controlledValue =
|
||||
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
|
||||
return (
|
||||
|
||||
@@ -200,7 +200,7 @@ describe('SimpleEventPlugin', function () {
|
||||
count: state.count + 1,
|
||||
}));
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`didUpdate - Count: ${this.state.count}`);
|
||||
Scheduler.log(`didUpdate - Count: ${this.state.count}`);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@@ -263,12 +263,12 @@ describe('SimpleEventPlugin', function () {
|
||||
state = {disabled: false};
|
||||
onClick = () => {
|
||||
// Perform some side-effect
|
||||
Scheduler.unstable_yieldValue('Side-effect');
|
||||
Scheduler.log('Side-effect');
|
||||
// Disable the button
|
||||
this.setState({disabled: true});
|
||||
};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`render button: ${this.state.disabled ? 'disabled' : 'enabled'}`,
|
||||
);
|
||||
return (
|
||||
|
||||
+1
-1
@@ -980,7 +980,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
|
||||
|
||||
flushNextYield(): Array<mixed> {
|
||||
Scheduler.unstable_flushNumberOfYields(1);
|
||||
return Scheduler.unstable_clearYields();
|
||||
return Scheduler.unstable_clearLog();
|
||||
},
|
||||
|
||||
flushWithHostCounters(fn: () => void):
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ import {
|
||||
UserBlockingPriority as UserBlockingSchedulerPriority,
|
||||
NormalPriority as NormalSchedulerPriority,
|
||||
IdlePriority as IdleSchedulerPriority,
|
||||
unstable_yieldValue,
|
||||
log,
|
||||
unstable_setDisableYieldValue,
|
||||
} from './Scheduler';
|
||||
import {setSuppressWarning} from 'shared/consoleWithStackDev';
|
||||
@@ -201,8 +201,8 @@ export function onCommitUnmount(fiber: Fiber) {
|
||||
|
||||
export function setIsStrictModeForDevtools(newIsStrictMode: boolean) {
|
||||
if (consoleManagedByDevToolsDuringStrictMode) {
|
||||
if (typeof unstable_yieldValue === 'function') {
|
||||
// We're in a test because Scheduler.unstable_yieldValue only exists
|
||||
if (typeof log === 'function') {
|
||||
// We're in a test because Scheduler.log only exists
|
||||
// in SchedulerMock. To reduce the noise in strict mode tests,
|
||||
// suppress warnings and disable scheduler yielding during the double render
|
||||
unstable_setDisableYieldValue(newIsStrictMode);
|
||||
|
||||
+1
-1
@@ -29,6 +29,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null;
|
||||
|
||||
// this doesn't actually exist on the scheduler, but it *does*
|
||||
// on scheduler/unstable_mock, which we'll need for internal testing
|
||||
export const unstable_yieldValue = Scheduler.unstable_yieldValue;
|
||||
export const log = Scheduler.log;
|
||||
export const unstable_setDisableYieldValue =
|
||||
Scheduler.unstable_setDisableYieldValue;
|
||||
|
||||
@@ -87,16 +87,16 @@ describe('act warnings', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -120,13 +120,13 @@ describe('act warnings', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text}) {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('ReactBlockingMode', () => {
|
||||
([text, ms = 0]) => {
|
||||
return new Promise((resolve, reject) =>
|
||||
setTimeout(() => {
|
||||
Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
|
||||
Scheduler.log(`Promise resolved [${text}]`);
|
||||
resolve(text);
|
||||
}, ms),
|
||||
);
|
||||
@@ -38,7 +38,7 @@ describe('ReactBlockingMode', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ describe('ReactBlockingMode', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
TextResource.read([props.text, props.ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return props.text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ describe('ReactBlockingMode', () => {
|
||||
|
||||
function App() {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Layout effect');
|
||||
Scheduler.log('Layout effect');
|
||||
});
|
||||
return <Text text="Hi" />;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// const record = textCache.get(text);
|
||||
// if (record !== undefined) {
|
||||
// if (record.status === 'pending') {
|
||||
// Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
|
||||
// Scheduler.log(`Promise rejected [${text}]`);
|
||||
// record.ping();
|
||||
// record.status = 'rejected';
|
||||
// clearTimeout(record.promise._timer);
|
||||
@@ -95,7 +95,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
|
||||
@@ -100,9 +100,7 @@ describe('ReactCache', () => {
|
||||
record.cleanupScheduled = true;
|
||||
if (getCacheSignal) {
|
||||
signal.addEventListener('abort', () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Cache cleanup: ${text} [v${textCache.version}]`,
|
||||
);
|
||||
Scheduler.log(`Cache cleanup: ${text} [v${textCache.version}]`);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -115,7 +113,7 @@ describe('ReactCache', () => {
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Cache miss! [${text}]`);
|
||||
Scheduler.log(`Cache miss! [${text}]`);
|
||||
|
||||
let resolve;
|
||||
let reject;
|
||||
@@ -148,9 +146,7 @@ describe('ReactCache', () => {
|
||||
|
||||
if (getCacheSignal) {
|
||||
signal.addEventListener('abort', () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Cache cleanup: ${text} [v${textCache.version}]`,
|
||||
);
|
||||
Scheduler.log(`Cache cleanup: ${text} [v${textCache.version}]`);
|
||||
});
|
||||
}
|
||||
throw thenable;
|
||||
@@ -158,14 +154,14 @@ describe('ReactCache', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text, showVersion}) {
|
||||
const version = readText(text);
|
||||
const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return fullText;
|
||||
}
|
||||
|
||||
|
||||
+4
-10
@@ -18,7 +18,7 @@ describe('ReactClassSetStateCallback', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,13 @@ describe('ReactClassSetStateCallback', () => {
|
||||
await act(async () => {
|
||||
if (gate(flags => flags.enableUnifiedSyncLane)) {
|
||||
React.startTransition(() => {
|
||||
app.setState({step: 1}, () =>
|
||||
Scheduler.unstable_yieldValue('Callback 1'),
|
||||
);
|
||||
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
|
||||
});
|
||||
} else {
|
||||
app.setState({step: 1}, () =>
|
||||
Scheduler.unstable_yieldValue('Callback 1'),
|
||||
);
|
||||
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
|
||||
}
|
||||
ReactNoop.flushSync(() => {
|
||||
app.setState({step: 2}, () =>
|
||||
Scheduler.unstable_yieldValue('Callback 2'),
|
||||
);
|
||||
app.setState({step: 2}, () => Scheduler.log('Callback 2'));
|
||||
});
|
||||
});
|
||||
assertLog([2, 'Callback 2', 2, 'Callback 1']);
|
||||
|
||||
+5
-5
@@ -86,16 +86,16 @@ describe('ReactConcurrentErrorRecovery', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -119,14 +119,14 @@ describe('ReactConcurrentErrorRecovery', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text, showVersion}) {
|
||||
const version = readText(text);
|
||||
const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return fullText;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,16 +96,16 @@ describe('ReactLazyContextPropagation', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -129,14 +129,14 @@ describe('ReactLazyContextPropagation', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
// function AsyncText({text, showVersion}) {
|
||||
// const version = readText(text);
|
||||
// const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
// Scheduler.unstable_yieldValue(fullText);
|
||||
// Scheduler.log(fullText);
|
||||
// return text;
|
||||
// }
|
||||
|
||||
@@ -321,7 +321,7 @@ describe('ReactLazyContextPropagation', () => {
|
||||
const [, _setOtherValue] = useState(0);
|
||||
setOtherValue = _setOtherValue;
|
||||
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
|
||||
return <Text text={value} />;
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('ReactDeferredValue', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ describe('ReactSuspenseList', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('ReactSuspenseList', () => {
|
||||
let resolved = false;
|
||||
const Component = function () {
|
||||
if (!resolved) {
|
||||
Scheduler.unstable_yieldValue('Suspend! [' + text + ']');
|
||||
Scheduler.log('Suspend! [' + text + ']');
|
||||
throw promise;
|
||||
}
|
||||
return <Text text={text} />;
|
||||
@@ -79,11 +79,11 @@ describe('ReactSuspenseList', () => {
|
||||
expect(root).toMatchRenderedOutput(null);
|
||||
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Resolve A');
|
||||
Scheduler.log('Resolve A');
|
||||
A.resolve();
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Resolve B');
|
||||
Scheduler.log('Resolve B');
|
||||
B.resolve();
|
||||
});
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@ describe('ReactEffectOrdering', () => {
|
||||
|
||||
function Parent() {
|
||||
useLayoutEffect(() => {
|
||||
return () => Scheduler.unstable_yieldValue('Unmount parent');
|
||||
return () => Scheduler.log('Unmount parent');
|
||||
});
|
||||
return <Child />;
|
||||
}
|
||||
|
||||
function Child() {
|
||||
useLayoutEffect(() => {
|
||||
return () => Scheduler.unstable_yieldValue('Unmount child');
|
||||
return () => Scheduler.log('Unmount child');
|
||||
});
|
||||
return 'Child';
|
||||
}
|
||||
@@ -68,14 +68,14 @@ describe('ReactEffectOrdering', () => {
|
||||
|
||||
function Parent() {
|
||||
useEffect(() => {
|
||||
return () => Scheduler.unstable_yieldValue('Unmount parent');
|
||||
return () => Scheduler.log('Unmount parent');
|
||||
});
|
||||
return <Child />;
|
||||
}
|
||||
|
||||
function Child() {
|
||||
useEffect(() => {
|
||||
return () => Scheduler.unstable_yieldValue('Unmount child');
|
||||
return () => Scheduler.log('Unmount child');
|
||||
});
|
||||
return 'Child';
|
||||
}
|
||||
|
||||
+15
-21
@@ -69,7 +69,7 @@ describe('ReactExpiration', () => {
|
||||
const record = textCache.get(text);
|
||||
if (record !== undefined) {
|
||||
if (record.status === 'pending') {
|
||||
Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
|
||||
Scheduler.log(`Promise resolved [${text}]`);
|
||||
record.ping();
|
||||
record.ping = null;
|
||||
record.status = 'resolved';
|
||||
@@ -88,7 +88,7 @@ describe('ReactExpiration', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -96,18 +96,18 @@ describe('ReactExpiration', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
if (typeof props.ms === 'number' && promise._timer === undefined) {
|
||||
promise._timer = setTimeout(() => {
|
||||
resolveText(text);
|
||||
}, props.ms);
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -147,13 +147,13 @@ describe('ReactExpiration', () => {
|
||||
it('two updates of like priority in the same event always flush within the same batch', async () => {
|
||||
class TextClass extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
|
||||
Scheduler.log(`${this.props.text} [commit]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
|
||||
Scheduler.log(`${this.props.text} [commit]`);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
|
||||
Scheduler.log(`${this.props.text} [render]`);
|
||||
return <span prop={this.props.text} />;
|
||||
}
|
||||
}
|
||||
@@ -204,13 +204,13 @@ describe('ReactExpiration', () => {
|
||||
async () => {
|
||||
class TextClass extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
|
||||
Scheduler.log(`${this.props.text} [commit]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
|
||||
Scheduler.log(`${this.props.text} [commit]`);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
|
||||
Scheduler.log(`${this.props.text} [render]`);
|
||||
return <span prop={this.props.text} />;
|
||||
}
|
||||
}
|
||||
@@ -268,19 +268,13 @@ describe('ReactExpiration', () => {
|
||||
state = {text: store.text};
|
||||
componentDidMount() {
|
||||
subscribers.push(this);
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.state.text} [${this.props.label}] [commit]`,
|
||||
);
|
||||
Scheduler.log(`${this.state.text} [${this.props.label}] [commit]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.state.text} [${this.props.label}] [commit]`,
|
||||
);
|
||||
Scheduler.log(`${this.state.text} [${this.props.label}] [commit]`);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`${this.state.text} [${this.props.label}] [render]`,
|
||||
);
|
||||
Scheduler.log(`${this.state.text} [${this.props.label}] [render]`);
|
||||
return <span prop={this.state.text} />;
|
||||
}
|
||||
}
|
||||
@@ -717,7 +711,7 @@ describe('ReactExpiration', () => {
|
||||
it('passive effects of expired update flush after paint', async () => {
|
||||
function App({step}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect: ' + step);
|
||||
Scheduler.log('Effect: ' + step);
|
||||
}, [step]);
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('ReactFlushSync', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ describe('ReactFlushSync', () => {
|
||||
test('flushes passive effects synchronously when they are the result of a sync render', async () => {
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ describe('ReactFlushSync', () => {
|
||||
test('do not flush passive effects synchronously after render in legacy mode', async () => {
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ describe('ReactFlushSync', () => {
|
||||
function App({step}) {
|
||||
useEffect(() => {
|
||||
currentStep = step;
|
||||
Scheduler.unstable_yieldValue('Effect: ' + step);
|
||||
Scheduler.log('Effect: ' + step);
|
||||
}, [step]);
|
||||
return <Text text={step} />;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ describe('ReactFlushSync', () => {
|
||||
test("do not flush passive effects synchronously when they aren't the result of a sync render", async () => {
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ describe('ReactFlushSync', () => {
|
||||
test('does not flush pending passive effects', async () => {
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('ReactHooks', () => {
|
||||
const {useState, useLayoutEffect} = React;
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ describe('ReactHooks', () => {
|
||||
setCounter2 = _setCounter2;
|
||||
|
||||
const text = `${counter1}, ${counter2}`;
|
||||
Scheduler.unstable_yieldValue(`Parent: ${text}`);
|
||||
Scheduler.log(`Parent: ${text}`);
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Effect: ${text}`);
|
||||
Scheduler.log(`Effect: ${text}`);
|
||||
});
|
||||
return <Child text={text} />;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ describe('ReactHooks', () => {
|
||||
const {useState, memo} = React;
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('ReactHooks', () => {
|
||||
setCounter2 = _setCounter2;
|
||||
|
||||
const text = `${counter1}, ${counter2} (${theme})`;
|
||||
Scheduler.unstable_yieldValue(`Parent: ${text}`);
|
||||
Scheduler.log(`Parent: ${text}`);
|
||||
return <Child text={text} />;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ describe('ReactHooks', () => {
|
||||
const [counter, _setCounter] = useState(0);
|
||||
setCounter = _setCounter;
|
||||
|
||||
Scheduler.unstable_yieldValue(`Count: ${counter}`);
|
||||
Scheduler.log(`Count: ${counter}`);
|
||||
return counter;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ describe('ReactHooks', () => {
|
||||
const [counter, _dispatch] = useReducer((s, a) => a, 0);
|
||||
dispatch = _dispatch;
|
||||
|
||||
Scheduler.unstable_yieldValue(`Count: ${counter}`);
|
||||
Scheduler.log(`Count: ${counter}`);
|
||||
return counter;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ describe('ReactHooks', () => {
|
||||
let setTheme;
|
||||
function ThemeProvider({children}) {
|
||||
const [theme, _setTheme] = useState('light');
|
||||
Scheduler.unstable_yieldValue('Theme: ' + theme);
|
||||
Scheduler.log('Theme: ' + theme);
|
||||
setTheme = _setTheme;
|
||||
return (
|
||||
<ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
|
||||
@@ -302,7 +302,7 @@ describe('ReactHooks', () => {
|
||||
}
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ describe('ReactHooks', () => {
|
||||
const theme = useContext(ThemeContext);
|
||||
|
||||
const text = `${counter} (${theme})`;
|
||||
Scheduler.unstable_yieldValue(`Parent: ${text}`);
|
||||
Scheduler.log(`Parent: ${text}`);
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Effect: ${text}`);
|
||||
Scheduler.log(`Effect: ${text}`);
|
||||
});
|
||||
return <Child text={text} />;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ describe('ReactHooks', () => {
|
||||
const {useState, useLayoutEffect} = React;
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -381,9 +381,9 @@ describe('ReactHooks', () => {
|
||||
function Parent() {
|
||||
const [counter, _setCounter] = useState(0);
|
||||
setCounter = _setCounter;
|
||||
Scheduler.unstable_yieldValue('Parent: ' + counter);
|
||||
Scheduler.log('Parent: ' + counter);
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect: ' + counter);
|
||||
Scheduler.log('Effect: ' + counter);
|
||||
});
|
||||
return <Child text={counter} />;
|
||||
}
|
||||
@@ -451,7 +451,7 @@ describe('ReactHooks', () => {
|
||||
const {useState} = React;
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ describe('ReactHooks', () => {
|
||||
function Parent() {
|
||||
const [counter, _setCounter] = useState(0);
|
||||
setCounter = _setCounter;
|
||||
Scheduler.unstable_yieldValue('Parent: ' + counter);
|
||||
Scheduler.log('Parent: ' + counter);
|
||||
return <Child text={counter} />;
|
||||
}
|
||||
|
||||
@@ -470,9 +470,7 @@ describe('ReactHooks', () => {
|
||||
|
||||
const update = value => {
|
||||
setCounter(previous => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Compute state (${previous} -> ${value})`,
|
||||
);
|
||||
Scheduler.log(`Compute state (${previous} -> ${value})`);
|
||||
return value;
|
||||
});
|
||||
};
|
||||
@@ -511,7 +509,7 @@ describe('ReactHooks', () => {
|
||||
const {useState} = React;
|
||||
|
||||
function Child({text}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + text);
|
||||
Scheduler.log('Child: ' + text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -519,7 +517,7 @@ describe('ReactHooks', () => {
|
||||
function Parent() {
|
||||
const [counter, _setCounter] = useState(1);
|
||||
setCounter = _setCounter;
|
||||
Scheduler.unstable_yieldValue('Parent: ' + counter);
|
||||
Scheduler.log('Parent: ' + counter);
|
||||
return <Child text={counter} />;
|
||||
}
|
||||
|
||||
@@ -531,9 +529,7 @@ describe('ReactHooks', () => {
|
||||
const update = compute => {
|
||||
setCounter(previous => {
|
||||
const value = compute(previous);
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Compute state (${previous} -> ${value})`,
|
||||
);
|
||||
Scheduler.log(`Compute state (${previous} -> ${value})`);
|
||||
return value;
|
||||
});
|
||||
};
|
||||
@@ -575,9 +571,7 @@ describe('ReactHooks', () => {
|
||||
const {useLayoutEffect} = React;
|
||||
function App(props) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Did commit: ' + props.dependencies.join(', '),
|
||||
);
|
||||
Scheduler.log('Did commit: ' + props.dependencies.join(', '));
|
||||
}, props.dependencies);
|
||||
return props.dependencies;
|
||||
}
|
||||
@@ -599,7 +593,7 @@ describe('ReactHooks', () => {
|
||||
function App({text, hasDeps}) {
|
||||
const resolvedText = useMemo(
|
||||
() => {
|
||||
Scheduler.unstable_yieldValue('Compute');
|
||||
Scheduler.log('Compute');
|
||||
return text.toUpperCase();
|
||||
},
|
||||
hasDeps ? null : [text],
|
||||
|
||||
+245
-289
File diff suppressed because it is too large
Load Diff
+153
-213
File diff suppressed because it is too large
Load Diff
+84
-88
@@ -69,31 +69,31 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
static getDerivedStateFromError(error) {
|
||||
Scheduler.unstable_yieldValue('getDerivedStateFromError');
|
||||
Scheduler.log('getDerivedStateFromError');
|
||||
return {error};
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
|
||||
Scheduler.log('ErrorBoundary (catch)');
|
||||
return <ErrorMessage error={this.state.error} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (try)');
|
||||
Scheduler.log('ErrorBoundary (try)');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function ErrorMessage({error}) {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage');
|
||||
Scheduler.log('ErrorMessage');
|
||||
return <span prop={`Caught an error: ${error.message}`} />;
|
||||
}
|
||||
|
||||
function Indirection({children}) {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return children || null;
|
||||
}
|
||||
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('throw');
|
||||
Scheduler.log('throw');
|
||||
throw new Error('oops!');
|
||||
}
|
||||
|
||||
@@ -167,31 +167,31 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('componentDidCatch');
|
||||
Scheduler.log('componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
|
||||
Scheduler.log('ErrorBoundary (catch)');
|
||||
return <ErrorMessage error={this.state.error} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (try)');
|
||||
Scheduler.log('ErrorBoundary (try)');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function ErrorMessage({error}) {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage');
|
||||
Scheduler.log('ErrorMessage');
|
||||
return <span prop={`Caught an error: ${error.message}`} />;
|
||||
}
|
||||
|
||||
function Indirection({children}) {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return children || null;
|
||||
}
|
||||
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('throw');
|
||||
Scheduler.log('throw');
|
||||
throw new Error('oops!');
|
||||
}
|
||||
|
||||
@@ -250,15 +250,15 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it("retries at a lower priority if there's additional pending work", async () => {
|
||||
function App(props) {
|
||||
if (props.isBroken) {
|
||||
Scheduler.unstable_yieldValue('error');
|
||||
Scheduler.log('error');
|
||||
throw new Error('Oops!');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('success');
|
||||
Scheduler.log('success');
|
||||
return <span prop="Everything is fine." />;
|
||||
}
|
||||
|
||||
function onCommit() {
|
||||
Scheduler.unstable_yieldValue('commit');
|
||||
Scheduler.log('commit');
|
||||
}
|
||||
|
||||
React.startTransition(() => {
|
||||
@@ -293,10 +293,10 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('does not include offscreen work when retrying after an error', async () => {
|
||||
function App(props) {
|
||||
if (props.isBroken) {
|
||||
Scheduler.unstable_yieldValue('error');
|
||||
Scheduler.log('error');
|
||||
throw new Error('Oops!');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('success');
|
||||
Scheduler.log('success');
|
||||
return (
|
||||
<>
|
||||
Everything is fine
|
||||
@@ -308,7 +308,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
|
||||
function onCommit() {
|
||||
Scheduler.unstable_yieldValue('commit');
|
||||
Scheduler.log('commit');
|
||||
}
|
||||
|
||||
React.startTransition(() => {
|
||||
@@ -358,17 +358,17 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
it('retries one more time before handling error', async () => {
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BadRender');
|
||||
Scheduler.log('BadRender');
|
||||
throw new Error('oops');
|
||||
}
|
||||
|
||||
function Sibling({unused}) {
|
||||
Scheduler.unstable_yieldValue('Sibling');
|
||||
Scheduler.log('Sibling');
|
||||
return <span prop="Sibling" />;
|
||||
}
|
||||
|
||||
function Parent({unused}) {
|
||||
Scheduler.unstable_yieldValue('Parent');
|
||||
Scheduler.log('Parent');
|
||||
return (
|
||||
<>
|
||||
<BadRender />
|
||||
@@ -378,9 +378,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
|
||||
React.startTransition(() => {
|
||||
ReactNoop.render(<Parent />, () =>
|
||||
Scheduler.unstable_yieldValue('commit'),
|
||||
);
|
||||
ReactNoop.render(<Parent />, () => Scheduler.log('commit'));
|
||||
});
|
||||
|
||||
// Render the bad component asynchronously
|
||||
@@ -397,12 +395,12 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
it('retries one more time if an error occurs during a render that expires midway through the tree', async () => {
|
||||
function Oops({unused}) {
|
||||
Scheduler.unstable_yieldValue('Oops');
|
||||
Scheduler.log('Oops');
|
||||
throw new Error('Oops');
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -458,7 +456,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
throw new Error(`Error ${++id}`);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BadMount');
|
||||
Scheduler.log('BadMount');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -466,14 +464,14 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {errorCount: 0};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue(`componentDidCatch: ${error.message}`);
|
||||
Scheduler.log(`componentDidCatch: ${error.message}`);
|
||||
this.setState(state => ({errorCount: state.errorCount + 1}));
|
||||
}
|
||||
render() {
|
||||
if (this.state.errorCount > 0) {
|
||||
return <span prop={`Number of errors: ${this.state.errorCount}`} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary');
|
||||
Scheduler.log('ErrorBoundary');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
@@ -535,23 +533,23 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
|
||||
Scheduler.log('ErrorBoundary componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render error');
|
||||
Scheduler.log('ErrorBoundary render error');
|
||||
return (
|
||||
<span prop={`Caught an error: ${this.state.error.message}.`} />
|
||||
);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render success');
|
||||
Scheduler.log('ErrorBoundary render success');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -585,23 +583,23 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
|
||||
Scheduler.log('ErrorBoundary componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render error');
|
||||
Scheduler.log('ErrorBoundary render error');
|
||||
return (
|
||||
<span prop={`Caught an error: ${this.state.error.message}.`} />
|
||||
);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render success');
|
||||
Scheduler.log('ErrorBoundary render success');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -634,23 +632,23 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
|
||||
Scheduler.log('ErrorBoundary componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render error');
|
||||
Scheduler.log('ErrorBoundary render error');
|
||||
return (
|
||||
<span prop={`Caught an error: ${this.state.error.message}.`} />
|
||||
);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render success');
|
||||
Scheduler.log('ErrorBoundary render success');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -683,17 +681,17 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('propagates an error from a noop error boundary during full deferred mounting', async () => {
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
|
||||
Scheduler.log('RethrowErrorBoundary componentDidCatch');
|
||||
throw error;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
|
||||
Scheduler.log('RethrowErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -721,17 +719,17 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('propagates an error from a noop error boundary during partial deferred mounting', async () => {
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
|
||||
Scheduler.log('RethrowErrorBoundary componentDidCatch');
|
||||
throw error;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
|
||||
Scheduler.log('RethrowErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -762,17 +760,17 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('propagates an error from a noop error boundary during synchronous mounting', () => {
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
|
||||
Scheduler.log('RethrowErrorBoundary componentDidCatch');
|
||||
throw error;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
|
||||
Scheduler.log('RethrowErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -802,17 +800,17 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('propagates an error from a noop error boundary during batched mounting', () => {
|
||||
class RethrowErrorBoundary extends React.Component {
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
|
||||
Scheduler.log('RethrowErrorBoundary componentDidCatch');
|
||||
throw error;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
|
||||
Scheduler.log('RethrowErrorBoundary render');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
@@ -890,12 +888,12 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
it('can schedule updates after uncaught error in render on mount', async () => {
|
||||
function BrokenRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
throw new Error('Hello');
|
||||
}
|
||||
|
||||
function Foo({unused}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -913,7 +911,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
it('can schedule updates after uncaught error in render on update', async () => {
|
||||
function BrokenRender({shouldThrow}) {
|
||||
Scheduler.unstable_yieldValue('BrokenRender');
|
||||
Scheduler.log('BrokenRender');
|
||||
if (shouldThrow) {
|
||||
throw new Error('Hello');
|
||||
}
|
||||
@@ -921,7 +919,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
|
||||
function Foo({unused}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -952,7 +950,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -970,7 +968,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('should not attempt to recover an unmounting error boundary', async () => {
|
||||
class Parent extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Parent componentWillUnmount');
|
||||
Scheduler.log('Parent componentWillUnmount');
|
||||
}
|
||||
render() {
|
||||
return <Boundary />;
|
||||
@@ -979,7 +977,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
class Boundary extends React.Component {
|
||||
componentDidCatch(e) {
|
||||
Scheduler.unstable_yieldValue(`Caught error: ${e.message}`);
|
||||
Scheduler.log(`Caught error: ${e.message}`);
|
||||
}
|
||||
render() {
|
||||
return <ThrowsOnUnmount />;
|
||||
@@ -988,7 +986,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
class ThrowsOnUnmount extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('ThrowsOnUnmount componentWillUnmount');
|
||||
Scheduler.log('ThrowsOnUnmount componentWillUnmount');
|
||||
throw new Error('unmount error');
|
||||
}
|
||||
render() {
|
||||
@@ -1339,9 +1337,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class BrokenRenderAndUnmount extends React.Component {
|
||||
state = {fail: false};
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'BrokenRenderAndUnmount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('BrokenRenderAndUnmount componentWillUnmount');
|
||||
}
|
||||
render() {
|
||||
inst = this;
|
||||
@@ -1354,7 +1350,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
class Parent extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Parent componentWillUnmount [!]');
|
||||
Scheduler.log('Parent componentWillUnmount [!]');
|
||||
throw new Error('One does not simply unmount me.');
|
||||
}
|
||||
render() {
|
||||
@@ -1396,7 +1392,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
it('does not interrupt unmounting if detaching a ref throws', async () => {
|
||||
class Bar extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Bar unmount');
|
||||
Scheduler.log('Bar unmount');
|
||||
}
|
||||
render() {
|
||||
return <span prop="Bar" />;
|
||||
@@ -1405,10 +1401,10 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
|
||||
function barRef(inst) {
|
||||
if (inst === null) {
|
||||
Scheduler.unstable_yieldValue('barRef detach');
|
||||
Scheduler.log('barRef detach');
|
||||
throw new Error('Detach error');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('barRef attach');
|
||||
Scheduler.log('barRef attach');
|
||||
}
|
||||
|
||||
function Foo(props) {
|
||||
@@ -1455,31 +1451,31 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
// Should not be called
|
||||
Scheduler.unstable_yieldValue('componentDidCatch');
|
||||
Scheduler.log('componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
|
||||
Scheduler.log('ErrorBoundary (catch)');
|
||||
return (
|
||||
<span
|
||||
prop={`Caught an error: ${this.state.error.nonStandardMessage}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (try)');
|
||||
Scheduler.log('ErrorBoundary (try)');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function Indirection({children}) {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return children;
|
||||
}
|
||||
|
||||
const notAnError = {nonStandardMessage: 'oops'};
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('BadRender');
|
||||
Scheduler.log('BadRender');
|
||||
throw notAnError;
|
||||
}
|
||||
|
||||
@@ -1526,31 +1522,31 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('componentDidCatch');
|
||||
Scheduler.log('componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
|
||||
Scheduler.log('ErrorBoundary (catch)');
|
||||
return <ErrorMessage error={this.state.error} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary (try)');
|
||||
Scheduler.log('ErrorBoundary (try)');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function ErrorMessage({error}) {
|
||||
Scheduler.unstable_yieldValue('ErrorMessage');
|
||||
Scheduler.log('ErrorMessage');
|
||||
return <span prop={`Caught an error: ${error.message}`} />;
|
||||
}
|
||||
|
||||
function BadRenderSibling({unused}) {
|
||||
Scheduler.unstable_yieldValue('BadRenderSibling');
|
||||
Scheduler.log('BadRenderSibling');
|
||||
return null;
|
||||
}
|
||||
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('throw');
|
||||
Scheduler.log('throw');
|
||||
throw new Error('oops!');
|
||||
}
|
||||
|
||||
@@ -1590,25 +1586,25 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
// where we checked for the existence of didUpdate instead of didMount, and
|
||||
// didMount was not defined.
|
||||
function BadRender({unused}) {
|
||||
Scheduler.unstable_yieldValue('throw');
|
||||
Scheduler.log('throw');
|
||||
throw new Error('oops!');
|
||||
}
|
||||
|
||||
class Parent extends React.Component {
|
||||
state = {error: null, other: false};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('did catch');
|
||||
Scheduler.log('did catch');
|
||||
this.setState({error});
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('did update');
|
||||
Scheduler.log('did update');
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('render error message');
|
||||
Scheduler.log('render error message');
|
||||
return <span prop={`Caught an error: ${this.state.error.message}`} />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
return <BadRender />;
|
||||
}
|
||||
}
|
||||
@@ -1636,7 +1632,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
render() {
|
||||
if (this.state.errorInfo) {
|
||||
Scheduler.unstable_yieldValue('render error message');
|
||||
Scheduler.log('render error message');
|
||||
return (
|
||||
<span
|
||||
prop={`Caught an error:${normalizeCodeLocInfo(
|
||||
@@ -1722,7 +1718,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
render() {
|
||||
if (this.state.errorInfo) {
|
||||
Scheduler.unstable_yieldValue('render error message');
|
||||
Scheduler.log('render error message');
|
||||
return (
|
||||
<span
|
||||
prop={`Caught an error:${normalizeCodeLocInfo(
|
||||
@@ -1793,7 +1789,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
const root = ReactNoop.createRoot();
|
||||
|
||||
function Oops({unused}) {
|
||||
Scheduler.unstable_yieldValue('Oops');
|
||||
Scheduler.log('Oops');
|
||||
throw Error('Oops');
|
||||
}
|
||||
|
||||
@@ -1832,7 +1828,7 @@ describe('ReactIncrementalErrorHandling', () => {
|
||||
}
|
||||
|
||||
function AllGood() {
|
||||
Scheduler.unstable_yieldValue('Everything is fine.');
|
||||
Scheduler.log('Everything is fine.');
|
||||
return 'Everything is fine.';
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -173,12 +173,10 @@ describe('ReactIncrementalErrorLogging', () => {
|
||||
this.setState({step: 1});
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentWillUnmount: ' + this.state.step,
|
||||
);
|
||||
Scheduler.log('componentWillUnmount: ' + this.state.step);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render: ' + this.state.step);
|
||||
Scheduler.log('render: ' + this.state.step);
|
||||
if (this.state.step > 0) {
|
||||
throw new Error('oops');
|
||||
}
|
||||
|
||||
+12
-33
@@ -51,14 +51,10 @@ describe('ReactIncrementalReflection', () => {
|
||||
}
|
||||
UNSAFE_componentWillMount() {
|
||||
instances.push(this);
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentWillMount: ' + this._isMounted(),
|
||||
);
|
||||
Scheduler.log('componentWillMount: ' + this._isMounted());
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentDidMount: ' + this._isMounted(),
|
||||
);
|
||||
Scheduler.log('componentDidMount: ' + this._isMounted());
|
||||
}
|
||||
render() {
|
||||
return <span />;
|
||||
@@ -95,18 +91,16 @@ describe('ReactIncrementalReflection', () => {
|
||||
instances.push(this);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentWillUnmount: ' + this._isMounted(),
|
||||
);
|
||||
Scheduler.log('componentWillUnmount: ' + this._isMounted());
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Component');
|
||||
Scheduler.log('Component');
|
||||
return <span />;
|
||||
}
|
||||
}
|
||||
|
||||
function Other() {
|
||||
Scheduler.unstable_yieldValue('Other');
|
||||
Scheduler.log('Other');
|
||||
return <span />;
|
||||
}
|
||||
|
||||
@@ -153,37 +147,22 @@ describe('ReactIncrementalReflection', () => {
|
||||
class Component extends React.Component {
|
||||
UNSAFE_componentWillMount() {
|
||||
classInstance = this;
|
||||
Scheduler.unstable_yieldValue([
|
||||
'componentWillMount',
|
||||
findInstance(this),
|
||||
]);
|
||||
Scheduler.log(['componentWillMount', findInstance(this)]);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue([
|
||||
'componentDidMount',
|
||||
findInstance(this),
|
||||
]);
|
||||
Scheduler.log(['componentDidMount', findInstance(this)]);
|
||||
}
|
||||
UNSAFE_componentWillUpdate() {
|
||||
Scheduler.unstable_yieldValue([
|
||||
'componentWillUpdate',
|
||||
findInstance(this),
|
||||
]);
|
||||
Scheduler.log(['componentWillUpdate', findInstance(this)]);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue([
|
||||
'componentDidUpdate',
|
||||
findInstance(this),
|
||||
]);
|
||||
Scheduler.log(['componentDidUpdate', findInstance(this)]);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue([
|
||||
'componentWillUnmount',
|
||||
findInstance(this),
|
||||
]);
|
||||
Scheduler.log(['componentWillUnmount', findInstance(this)]);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
return this.props.step < 2 ? (
|
||||
<span ref={ref => (this.span = ref)} />
|
||||
) : this.props.step === 2 ? (
|
||||
@@ -196,7 +175,7 @@ describe('ReactIncrementalReflection', () => {
|
||||
|
||||
function Sibling() {
|
||||
// Sibling is used to assert that we've rendered past the first component.
|
||||
Scheduler.unstable_yieldValue('render sibling');
|
||||
Scheduler.log('render sibling');
|
||||
return <span />;
|
||||
}
|
||||
|
||||
|
||||
+14
-18
@@ -97,7 +97,7 @@ describe('ReactIncrementalScheduling', () => {
|
||||
const {useEffect} = React;
|
||||
function Text({text}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
}, [text]);
|
||||
return text;
|
||||
}
|
||||
@@ -151,24 +151,22 @@ describe('ReactIncrementalScheduling', () => {
|
||||
state = {tick: 0};
|
||||
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidMount (before setState): ' + this.state.tick,
|
||||
);
|
||||
this.setState({tick: 1});
|
||||
// We're in a batch. Update hasn't flushed yet.
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentDidMount (after setState): ' + this.state.tick,
|
||||
);
|
||||
Scheduler.log('componentDidMount (after setState): ' + this.state.tick);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate: ' + this.state.tick);
|
||||
Scheduler.log('componentDidUpdate: ' + this.state.tick);
|
||||
if (this.state.tick === 2) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidUpdate (before setState): ' + this.state.tick,
|
||||
);
|
||||
this.setState({tick: 3});
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidUpdate (after setState): ' + this.state.tick,
|
||||
);
|
||||
// We're in a batch. Update hasn't flushed yet.
|
||||
@@ -176,7 +174,7 @@ describe('ReactIncrementalScheduling', () => {
|
||||
}
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render: ' + this.state.tick);
|
||||
Scheduler.log('render: ' + this.state.tick);
|
||||
instance = this;
|
||||
return <span prop={this.state.tick} />;
|
||||
}
|
||||
@@ -220,11 +218,11 @@ describe('ReactIncrementalScheduling', () => {
|
||||
|
||||
componentDidMount() {
|
||||
React.startTransition(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidMount (before setState): ' + this.state.tick,
|
||||
);
|
||||
this.setState({tick: 1});
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidMount (after setState): ' + this.state.tick,
|
||||
);
|
||||
});
|
||||
@@ -232,15 +230,13 @@ describe('ReactIncrementalScheduling', () => {
|
||||
|
||||
componentDidUpdate() {
|
||||
React.startTransition(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'componentDidUpdate: ' + this.state.tick,
|
||||
);
|
||||
Scheduler.log('componentDidUpdate: ' + this.state.tick);
|
||||
if (this.state.tick === 2) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidUpdate (before setState): ' + this.state.tick,
|
||||
);
|
||||
this.setState({tick: 3});
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'componentDidUpdate (after setState): ' + this.state.tick,
|
||||
);
|
||||
}
|
||||
@@ -248,7 +244,7 @@ describe('ReactIncrementalScheduling', () => {
|
||||
}
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render: ' + this.state.tick);
|
||||
Scheduler.log('render: ' + this.state.tick);
|
||||
instance = this;
|
||||
return <span prop={this.state.tick} />;
|
||||
}
|
||||
@@ -299,7 +295,7 @@ describe('ReactIncrementalScheduling', () => {
|
||||
});
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return <span prop={this.state.step} />;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-16
@@ -433,12 +433,12 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
|
||||
it('does not update child nodes if a flush is aborted', async () => {
|
||||
function Bar(props) {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return <span prop={props.text} />;
|
||||
}
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
@@ -482,12 +482,12 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
// @gate www
|
||||
it('preserves a previously rendered node when deprioritized', async () => {
|
||||
function Middle(props) {
|
||||
Scheduler.unstable_yieldValue('Middle');
|
||||
Scheduler.log('Middle');
|
||||
return <span prop={props.children} />;
|
||||
}
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<div>
|
||||
<LegacyHiddenDiv mode="hidden">
|
||||
@@ -508,9 +508,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
</div>,
|
||||
);
|
||||
|
||||
ReactNoop.render(<Foo text="bar" />, () =>
|
||||
Scheduler.unstable_yieldValue('commit'),
|
||||
);
|
||||
ReactNoop.render(<Foo text="bar" />, () => Scheduler.log('commit'));
|
||||
await waitFor(['Foo', 'commit']);
|
||||
expect(ReactNoop.getChildrenAsJSX()).toEqual(
|
||||
<div>
|
||||
@@ -533,7 +531,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
// @gate www
|
||||
it('can reuse side-effects after being preempted', async () => {
|
||||
function Bar(props) {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return <span prop={props.children} />;
|
||||
}
|
||||
|
||||
@@ -545,7 +543,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
);
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<LegacyHiddenDiv mode="hidden">
|
||||
{props.step === 0 ? (
|
||||
@@ -576,7 +574,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
// Make a quick update which will schedule low priority work to
|
||||
// update the middle content.
|
||||
ReactNoop.render(<Foo text="bar" step={1} />, () =>
|
||||
Scheduler.unstable_yieldValue('commit'),
|
||||
Scheduler.log('commit'),
|
||||
);
|
||||
await waitFor(['Foo', 'commit', 'Bar']);
|
||||
|
||||
@@ -617,7 +615,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
return this.props.children !== nextProps.children;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return <span prop={this.props.children} />;
|
||||
}
|
||||
}
|
||||
@@ -627,7 +625,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
return this.props.step !== nextProps.step;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Content');
|
||||
Scheduler.log('Content');
|
||||
return (
|
||||
<div>
|
||||
<Bar>{this.props.step === 0 ? 'Hi' : 'Hello'}</Bar>
|
||||
@@ -638,7 +636,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
}
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<LegacyHiddenDiv mode="hidden">
|
||||
<Content step={props.step} text={props.text} />
|
||||
@@ -696,7 +694,7 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
|
||||
it('can update a completed tree before it has a chance to commit', async () => {
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return <span prop={props.step} />;
|
||||
}
|
||||
React.startTransition(() => {
|
||||
@@ -998,12 +996,12 @@ describe('ReactIncrementalSideEffects', () => {
|
||||
}
|
||||
render() {
|
||||
barInstances.push(this);
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return <span prop={this.state.active ? 'X' : this.props.idx} />;
|
||||
}
|
||||
}
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<div>
|
||||
<span prop={props.tick} />
|
||||
|
||||
@@ -216,7 +216,7 @@ describe('ReactIncrementalTriangle', () => {
|
||||
}
|
||||
render() {
|
||||
if (yieldAfterEachRender) {
|
||||
Scheduler.unstable_yieldValue(this);
|
||||
Scheduler.log(this);
|
||||
}
|
||||
const {counter, remainingDepth} = this.props;
|
||||
return (
|
||||
|
||||
@@ -50,7 +50,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
class Foo extends React.Component {
|
||||
state = {};
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('commit');
|
||||
Scheduler.log('commit');
|
||||
React.startTransition(() => {
|
||||
// Has low priority
|
||||
this.setState({b: 'b'});
|
||||
@@ -99,13 +99,13 @@ describe('ReactIncrementalUpdates', () => {
|
||||
class Foo extends React.Component {
|
||||
state = {};
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
instance = this;
|
||||
return <div />;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
|
||||
function createUpdate(letter) {
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(letter);
|
||||
Scheduler.log(letter);
|
||||
return {
|
||||
[letter]: letter,
|
||||
};
|
||||
@@ -239,7 +239,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
|
||||
function createUpdate(letter) {
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(letter);
|
||||
Scheduler.log(letter);
|
||||
return {
|
||||
[letter]: letter,
|
||||
};
|
||||
@@ -340,16 +340,16 @@ describe('ReactIncrementalUpdates', () => {
|
||||
class Foo extends React.Component {
|
||||
state = {};
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('did mount');
|
||||
Scheduler.log('did mount');
|
||||
this.setState({a: 'a'}, () => {
|
||||
Scheduler.unstable_yieldValue('callback a');
|
||||
Scheduler.log('callback a');
|
||||
this.setState({b: 'b'}, () => {
|
||||
Scheduler.unstable_yieldValue('callback b');
|
||||
Scheduler.log('callback b');
|
||||
});
|
||||
});
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
@@ -371,11 +371,11 @@ describe('ReactIncrementalUpdates', () => {
|
||||
class Foo extends React.Component {
|
||||
state = {};
|
||||
UNSAFE_componentWillReceiveProps() {
|
||||
Scheduler.unstable_yieldValue('componentWillReceiveProps');
|
||||
Scheduler.log('componentWillReceiveProps');
|
||||
this.setState({b: 'b'});
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
instance = this;
|
||||
return <div />;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
class Foo extends React.Component {
|
||||
state = {};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('render');
|
||||
Scheduler.log('render');
|
||||
instance = this;
|
||||
return <div />;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
]);
|
||||
|
||||
instance.setState(function a() {
|
||||
Scheduler.unstable_yieldValue('setState updater');
|
||||
Scheduler.log('setState updater');
|
||||
this.setState({b: 'b'});
|
||||
return {a: 'a'};
|
||||
});
|
||||
@@ -526,10 +526,10 @@ describe('ReactIncrementalUpdates', () => {
|
||||
function App() {
|
||||
const [count, _setCount] = useState(0);
|
||||
setCount = _setCount;
|
||||
Scheduler.unstable_yieldValue('Render: ' + count);
|
||||
Scheduler.log('Render: ' + count);
|
||||
useLayoutEffect(() => {
|
||||
setCount(prevCount => prevCount + 1);
|
||||
Scheduler.unstable_yieldValue('Commit: ' + count);
|
||||
Scheduler.log('Commit: ' + count);
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
@@ -553,7 +553,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
|
||||
it('regression: does not expire soon due to previous flushSync', () => {
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -573,7 +573,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
|
||||
it('regression: does not expire soon due to previous expired work', () => {
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Committed: ' + log);
|
||||
Scheduler.log('Committed: ' + log);
|
||||
if (log === 'B') {
|
||||
// Right after B commits, schedule additional updates.
|
||||
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
|
||||
@@ -663,7 +663,7 @@ describe('ReactIncrementalUpdates', () => {
|
||||
this.setState(prevState => ({log: prevState.log + msg}));
|
||||
};
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Committed: ' + this.state.log);
|
||||
Scheduler.log('Committed: ' + this.state.log);
|
||||
if (this.state.log === 'B') {
|
||||
// Right after B commits, schedule additional updates.
|
||||
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('ReactInterleavedUpdates', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('ReactLazy', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -246,10 +246,10 @@ describe('ReactLazy', () => {
|
||||
it('mount and reorder', async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -334,7 +334,7 @@ describe('ReactLazy', () => {
|
||||
|
||||
it('resolves defaultProps without breaking memoization', async () => {
|
||||
function LazyImpl(props) {
|
||||
Scheduler.unstable_yieldValue('Lazy');
|
||||
Scheduler.log('Lazy');
|
||||
return (
|
||||
<>
|
||||
<Text text={props.siblingText} />
|
||||
@@ -482,42 +482,38 @@ describe('ReactLazy', () => {
|
||||
state = {};
|
||||
|
||||
static getDerivedStateFromProps(props) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`getDerivedStateFromProps: ${props.text}`,
|
||||
);
|
||||
Scheduler.log(`getDerivedStateFromProps: ${props.text}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
Scheduler.unstable_yieldValue(`constructor: ${this.props.text}`);
|
||||
Scheduler.log(`constructor: ${this.props.text}`);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`componentDidMount: ${this.props.text}`);
|
||||
Scheduler.log(`componentDidMount: ${this.props.text}`);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`componentDidUpdate: ${prevProps.text} -> ${this.props.text}`,
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`componentWillUnmount: ${this.props.text}`,
|
||||
);
|
||||
Scheduler.log(`componentWillUnmount: ${this.props.text}`);
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`shouldComponentUpdate: ${this.props.text} -> ${nextProps.text}`,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
getSnapshotBeforeUpdate(prevProps) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`getSnapshotBeforeUpdate: ${prevProps.text} -> ${this.props.text}`,
|
||||
);
|
||||
return null;
|
||||
@@ -586,19 +582,17 @@ describe('ReactLazy', () => {
|
||||
state = {};
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`UNSAFE_componentWillMount: ${this.props.text}`,
|
||||
);
|
||||
Scheduler.log(`UNSAFE_componentWillMount: ${this.props.text}`);
|
||||
}
|
||||
|
||||
UNSAFE_componentWillUpdate(nextProps) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`UNSAFE_componentWillUpdate: ${this.props.text} -> ${nextProps.text}`,
|
||||
);
|
||||
}
|
||||
|
||||
UNSAFE_componentWillReceiveProps(nextProps) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`UNSAFE_componentWillReceiveProps: ${this.props.text} -> ${nextProps.text}`,
|
||||
);
|
||||
}
|
||||
@@ -649,7 +643,7 @@ describe('ReactLazy', () => {
|
||||
|
||||
it('resolves defaultProps on the outer wrapper but warns', async () => {
|
||||
function T(props) {
|
||||
Scheduler.unstable_yieldValue(props.inner + ' ' + props.outer);
|
||||
Scheduler.log(props.inner + ' ' + props.outer);
|
||||
return props.inner + ' ' + props.outer;
|
||||
}
|
||||
T.defaultProps = {inner: 'Hi'};
|
||||
@@ -1022,7 +1016,7 @@ describe('ReactLazy', () => {
|
||||
it('includes lazy-loaded component in warning stack', async () => {
|
||||
const Foo = props => <div>{[<Text text="A" />, <Text text="B" />]}</div>;
|
||||
const LazyFoo = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Started loading');
|
||||
Scheduler.log('Started loading');
|
||||
return fakeImport(Foo);
|
||||
});
|
||||
|
||||
@@ -1062,7 +1056,7 @@ describe('ReactLazy', () => {
|
||||
}
|
||||
}
|
||||
const ForwardRefBar = React.forwardRef((props, ref) => {
|
||||
Scheduler.unstable_yieldValue('forwardRef');
|
||||
Scheduler.log('forwardRef');
|
||||
return <Bar ref={ref} />;
|
||||
});
|
||||
|
||||
@@ -1335,13 +1329,13 @@ describe('ReactLazy', () => {
|
||||
it('mount and reorder lazy types', async () => {
|
||||
class Child extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Did unmount: ' + this.props.label);
|
||||
Scheduler.log('Did unmount: ' + this.props.label);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -1357,20 +1351,20 @@ describe('ReactLazy', () => {
|
||||
}
|
||||
|
||||
const LazyChildA = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A');
|
||||
Scheduler.log('Init A');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
const LazyChildB = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B');
|
||||
Scheduler.log('Init B');
|
||||
return fakeImport(ChildB);
|
||||
});
|
||||
const LazyChildA2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A2');
|
||||
Scheduler.log('Init A2');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
let resolveB2;
|
||||
const LazyChildB2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B2');
|
||||
Scheduler.log('Init B2');
|
||||
return new Promise(r => {
|
||||
resolveB2 = r;
|
||||
});
|
||||
@@ -1423,10 +1417,10 @@ describe('ReactLazy', () => {
|
||||
it('mount and reorder lazy types (legacy mode)', async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -1442,19 +1436,19 @@ describe('ReactLazy', () => {
|
||||
}
|
||||
|
||||
const LazyChildA = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A');
|
||||
Scheduler.log('Init A');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
const LazyChildB = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B');
|
||||
Scheduler.log('Init B');
|
||||
return fakeImport(ChildB);
|
||||
});
|
||||
const LazyChildA2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A2');
|
||||
Scheduler.log('Init A2');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
const LazyChildB2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B2');
|
||||
Scheduler.log('Init B2');
|
||||
return fakeImport(ChildB);
|
||||
});
|
||||
|
||||
@@ -1496,10 +1490,10 @@ describe('ReactLazy', () => {
|
||||
it('mount and reorder lazy elements', async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -1508,22 +1502,22 @@ describe('ReactLazy', () => {
|
||||
|
||||
const ChildA = <Child key="A" label="A" />;
|
||||
const lazyChildA = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A');
|
||||
Scheduler.log('Init A');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
const ChildB = <Child key="B" label="B" />;
|
||||
const lazyChildB = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B');
|
||||
Scheduler.log('Init B');
|
||||
return fakeImport(ChildB);
|
||||
});
|
||||
const ChildA2 = <Child key="A" label="a" />;
|
||||
const lazyChildA2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A2');
|
||||
Scheduler.log('Init A2');
|
||||
return fakeImport(ChildA2);
|
||||
});
|
||||
const ChildB2 = <Child key="B" label="b" />;
|
||||
const lazyChildB2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B2');
|
||||
Scheduler.log('Init B2');
|
||||
return fakeImport(ChildB2);
|
||||
});
|
||||
|
||||
@@ -1567,10 +1561,10 @@ describe('ReactLazy', () => {
|
||||
it('mount and reorder lazy elements (legacy mode)', async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -1579,22 +1573,22 @@ describe('ReactLazy', () => {
|
||||
|
||||
const ChildA = <Child key="A" label="A" />;
|
||||
const lazyChildA = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A');
|
||||
Scheduler.log('Init A');
|
||||
return fakeImport(ChildA);
|
||||
});
|
||||
const ChildB = <Child key="B" label="B" />;
|
||||
const lazyChildB = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B');
|
||||
Scheduler.log('Init B');
|
||||
return fakeImport(ChildB);
|
||||
});
|
||||
const ChildA2 = <Child key="A" label="a" />;
|
||||
const lazyChildA2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init A2');
|
||||
Scheduler.log('Init A2');
|
||||
return fakeImport(ChildA2);
|
||||
});
|
||||
const ChildB2 = <Child key="B" label="b" />;
|
||||
const lazyChildB2 = lazy(() => {
|
||||
Scheduler.unstable_yieldValue('Init B2');
|
||||
Scheduler.log('Init B2');
|
||||
return fakeImport(ChildB2);
|
||||
});
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('memo', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span prop={props.text} />;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ describe('memo', () => {
|
||||
useEffect(() => {
|
||||
if (props !== prevProps.current) {
|
||||
prevProps.current = props;
|
||||
Scheduler.unstable_yieldValue('Props changed [SimpleMemo]');
|
||||
Scheduler.log('Props changed [SimpleMemo]');
|
||||
}
|
||||
}, [props]);
|
||||
|
||||
@@ -226,7 +226,7 @@ describe('memo', () => {
|
||||
useEffect(() => {
|
||||
if (props !== prevProps.current) {
|
||||
prevProps.current = props;
|
||||
Scheduler.unstable_yieldValue('Props changed [ComplexMemo]');
|
||||
Scheduler.log('Props changed [ComplexMemo]');
|
||||
}
|
||||
}, [props]);
|
||||
|
||||
@@ -246,9 +246,7 @@ describe('memo', () => {
|
||||
useEffect(() => {
|
||||
if (props !== prevProps.current) {
|
||||
prevProps.current = props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Props changed [MemoWithIndirection]',
|
||||
);
|
||||
Scheduler.log('Props changed [MemoWithIndirection]');
|
||||
}
|
||||
}, [props]);
|
||||
|
||||
@@ -336,7 +334,7 @@ describe('memo', () => {
|
||||
return <Text text={count} />;
|
||||
}
|
||||
Counter = memo(Counter, (oldProps, newProps) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Old count: ${oldProps.count}, New count: ${newProps.count}`,
|
||||
);
|
||||
return oldProps.count === newProps.count;
|
||||
|
||||
+39
-39
@@ -39,7 +39,7 @@ describe('ReactNewContext', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span prop={props.text} />;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ describe('ReactNewContext', () => {
|
||||
const ContextConsumer = getConsumer(Context);
|
||||
|
||||
function Provider(props) {
|
||||
Scheduler.unstable_yieldValue('Provider');
|
||||
Scheduler.log('Provider');
|
||||
return (
|
||||
<Context.Provider value={props.value}>
|
||||
{props.children}
|
||||
@@ -162,11 +162,11 @@ describe('ReactNewContext', () => {
|
||||
}
|
||||
|
||||
function Consumer(props) {
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
return (
|
||||
<ContextConsumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue('Consumer render prop');
|
||||
Scheduler.log('Consumer render prop');
|
||||
return <span prop={'Result: ' + value} />;
|
||||
}}
|
||||
</ContextConsumer>
|
||||
@@ -178,13 +178,13 @@ describe('ReactNewContext', () => {
|
||||
return false;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function App(props) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Provider value={props.value}>
|
||||
<Indirection>
|
||||
@@ -218,7 +218,7 @@ describe('ReactNewContext', () => {
|
||||
const ContextConsumer = getConsumer(Context);
|
||||
|
||||
function Provider(props) {
|
||||
Scheduler.unstable_yieldValue('Provider');
|
||||
Scheduler.log('Provider');
|
||||
return (
|
||||
<Context.Provider value={props.value}>
|
||||
{props.children}
|
||||
@@ -227,11 +227,11 @@ describe('ReactNewContext', () => {
|
||||
}
|
||||
|
||||
function Consumer(props) {
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
return (
|
||||
<ContextConsumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue('Consumer render prop');
|
||||
Scheduler.log('Consumer render prop');
|
||||
return <span prop={'Result: ' + value} />;
|
||||
}}
|
||||
</ContextConsumer>
|
||||
@@ -243,13 +243,13 @@ describe('ReactNewContext', () => {
|
||||
return false;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function App(props) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Provider value={props.value}>
|
||||
<Indirection>
|
||||
@@ -458,7 +458,7 @@ describe('ReactNewContext', () => {
|
||||
const ContextConsumer = getConsumer(Context);
|
||||
|
||||
function Provider(props) {
|
||||
Scheduler.unstable_yieldValue('Provider');
|
||||
Scheduler.log('Provider');
|
||||
return (
|
||||
<Context.Provider value={props.value}>
|
||||
{props.children}
|
||||
@@ -467,11 +467,11 @@ describe('ReactNewContext', () => {
|
||||
}
|
||||
|
||||
function Consumer(props) {
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
return (
|
||||
<ContextConsumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue('Consumer render prop');
|
||||
Scheduler.log('Consumer render prop');
|
||||
return <span prop={'Result: ' + value} />;
|
||||
}}
|
||||
</ContextConsumer>
|
||||
@@ -483,13 +483,13 @@ describe('ReactNewContext', () => {
|
||||
return false;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Indirection');
|
||||
Scheduler.log('Indirection');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function App(props) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Provider value={props.value}>
|
||||
<Indirection>
|
||||
@@ -583,7 +583,7 @@ describe('ReactNewContext', () => {
|
||||
class Child extends React.Component {
|
||||
state = {step: 0};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return (
|
||||
<span
|
||||
prop={`Context: ${this.props.context}, Step: ${this.state.step}`}
|
||||
@@ -597,7 +597,7 @@ describe('ReactNewContext', () => {
|
||||
<Context.Provider value={props.value}>
|
||||
<Consumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue('Consumer render prop');
|
||||
Scheduler.log('Consumer render prop');
|
||||
return <Child ref={inst => (child = inst)} context={value} />;
|
||||
}}
|
||||
</Consumer>
|
||||
@@ -624,24 +624,24 @@ describe('ReactNewContext', () => {
|
||||
const Consumer = getConsumer(Context);
|
||||
|
||||
function renderChildValue(value) {
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
return <span prop={value} />;
|
||||
}
|
||||
|
||||
function ChildWithInlineRenderCallback() {
|
||||
Scheduler.unstable_yieldValue('ChildWithInlineRenderCallback');
|
||||
Scheduler.log('ChildWithInlineRenderCallback');
|
||||
// Note: we are intentionally passing an inline arrow. Don't refactor.
|
||||
return <Consumer>{value => renderChildValue(value)}</Consumer>;
|
||||
}
|
||||
|
||||
function ChildWithCachedRenderCallback() {
|
||||
Scheduler.unstable_yieldValue('ChildWithCachedRenderCallback');
|
||||
Scheduler.log('ChildWithCachedRenderCallback');
|
||||
return <Consumer>{renderChildValue}</Consumer>;
|
||||
}
|
||||
|
||||
class PureIndirection extends React.PureComponent {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('PureIndirection');
|
||||
Scheduler.log('PureIndirection');
|
||||
return (
|
||||
<>
|
||||
<ChildWithInlineRenderCallback />
|
||||
@@ -653,7 +653,7 @@ describe('ReactNewContext', () => {
|
||||
|
||||
class App extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.props.value}>
|
||||
<PureIndirection />
|
||||
@@ -781,7 +781,7 @@ describe('ReactNewContext', () => {
|
||||
};
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.state.step}>
|
||||
<StaticContent />
|
||||
@@ -809,7 +809,7 @@ describe('ReactNewContext', () => {
|
||||
return (
|
||||
<ContextConsumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue('Consumer');
|
||||
Scheduler.log('Consumer');
|
||||
return <span prop={value} />;
|
||||
}}
|
||||
</ContextConsumer>
|
||||
@@ -872,7 +872,7 @@ describe('ReactNewContext', () => {
|
||||
const Context = React.createContext(0);
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -917,7 +917,7 @@ describe('ReactNewContext', () => {
|
||||
const Context = React.createContext(0);
|
||||
|
||||
function Foo(props) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -957,14 +957,14 @@ describe('ReactNewContext', () => {
|
||||
const Context = React.createContext(0);
|
||||
|
||||
function Child() {
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return <span prop="Child" />;
|
||||
}
|
||||
|
||||
const children = <Child />;
|
||||
|
||||
function App(props) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={props.value}>{children}</Context.Provider>
|
||||
);
|
||||
@@ -988,7 +988,7 @@ describe('ReactNewContext', () => {
|
||||
const Context = React.createContext(0);
|
||||
|
||||
function Child() {
|
||||
Scheduler.unstable_yieldValue('Child');
|
||||
Scheduler.log('Child');
|
||||
return <span prop="Child" />;
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ describe('ReactNewContext', () => {
|
||||
return {legacyValue: this.state.legacyValue};
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('LegacyProvider');
|
||||
Scheduler.log('LegacyProvider');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
@@ -1011,7 +1011,7 @@ describe('ReactNewContext', () => {
|
||||
class App extends React.Component {
|
||||
state = {value: 1};
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.state.value}>
|
||||
{this.props.children}
|
||||
@@ -1131,12 +1131,12 @@ describe('ReactNewContext', () => {
|
||||
};
|
||||
|
||||
renderConsumer = context => {
|
||||
Scheduler.unstable_yieldValue('App#renderConsumer');
|
||||
Scheduler.log('App#renderConsumer');
|
||||
return <span prop={this.state.text} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.props.value}>
|
||||
<Consumer>{this.renderConsumer}</Consumer>
|
||||
@@ -1274,12 +1274,12 @@ describe('ReactNewContext', () => {
|
||||
};
|
||||
|
||||
renderConsumer = context => {
|
||||
Scheduler.unstable_yieldValue('App#renderConsumer');
|
||||
Scheduler.log('App#renderConsumer');
|
||||
return <span prop={this.state.text} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.props.value}>
|
||||
<Consumer>{this.renderConsumer}</Consumer>
|
||||
@@ -1385,12 +1385,12 @@ describe('ReactNewContext', () => {
|
||||
};
|
||||
|
||||
renderConsumer = context => {
|
||||
Scheduler.unstable_yieldValue('App#renderConsumer');
|
||||
Scheduler.log('App#renderConsumer');
|
||||
return <span prop={this.state.text} />;
|
||||
};
|
||||
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Context.Provider value={this.props.value}>
|
||||
<Consumer>{this.renderConsumer}</Consumer>
|
||||
@@ -1512,7 +1512,7 @@ describe('ReactNewContext', () => {
|
||||
return false;
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue();
|
||||
Scheduler.log();
|
||||
if (this.props.depth >= this.props.maxDepth) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ describe('internal act()', () => {
|
||||
function App() {
|
||||
const [ctr, setCtr] = React.useState(0);
|
||||
async function someAsyncFunction() {
|
||||
Scheduler.unstable_yieldValue('stage 1');
|
||||
Scheduler.log('stage 1');
|
||||
await null;
|
||||
Scheduler.unstable_yieldValue('stage 2');
|
||||
Scheduler.log('stage 2');
|
||||
await null;
|
||||
setCtr(1);
|
||||
}
|
||||
|
||||
+52
-52
@@ -38,22 +38,22 @@ describe('ReactOffscreen', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span prop={props.text}>{props.children}</span>;
|
||||
}
|
||||
|
||||
function LoggedText({text, children}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`mount ${text}`);
|
||||
Scheduler.log(`mount ${text}`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`unmount ${text}`);
|
||||
Scheduler.log(`unmount ${text}`);
|
||||
};
|
||||
});
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`mount layout ${text}`);
|
||||
Scheduler.log(`mount layout ${text}`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`unmount layout ${text}`);
|
||||
Scheduler.log(`unmount layout ${text}`);
|
||||
};
|
||||
});
|
||||
return <Text text={text}>{children}</Text>;
|
||||
@@ -213,9 +213,9 @@ describe('ReactOffscreen', () => {
|
||||
it('mounts without layout effects when hidden', async () => {
|
||||
function Child({text}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount layout');
|
||||
Scheduler.log('Mount layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount layout');
|
||||
Scheduler.log('Unmount layout');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
@@ -251,9 +251,9 @@ describe('ReactOffscreen', () => {
|
||||
it('mounts/unmounts layout effects when visibility changes (starting visible)', async () => {
|
||||
function Child({text}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount layout');
|
||||
Scheduler.log('Mount layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount layout');
|
||||
Scheduler.log('Unmount layout');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
@@ -304,11 +304,11 @@ describe('ReactOffscreen', () => {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ describe('ReactOffscreen', () => {
|
||||
);
|
||||
});
|
||||
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
|
||||
await act(async () => {
|
||||
// Outer offscreen is visible.
|
||||
@@ -401,9 +401,9 @@ describe('ReactOffscreen', () => {
|
||||
it('mounts/unmounts layout effects when visibility changes (starting hidden)', async () => {
|
||||
function Child({text}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount layout');
|
||||
Scheduler.log('Mount layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount layout');
|
||||
Scheduler.log('Unmount layout');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
@@ -449,11 +449,11 @@ describe('ReactOffscreen', () => {
|
||||
const root = ReactNoop.createRoot();
|
||||
function Child({text}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount layout');
|
||||
Scheduler.log('Mount layout');
|
||||
return () => {
|
||||
// The child should not be hidden yet.
|
||||
expect(root).toMatchRenderedOutput(<span prop="Child" />);
|
||||
Scheduler.unstable_yieldValue('Unmount layout');
|
||||
Scheduler.log('Unmount layout');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
@@ -489,9 +489,9 @@ describe('ReactOffscreen', () => {
|
||||
// do anything to effects. Only used by www, as a temporary migration step.
|
||||
function Child({text}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount layout');
|
||||
Scheduler.log('Mount layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount layout');
|
||||
Scheduler.log('Unmount layout');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
@@ -818,7 +818,7 @@ describe('ReactOffscreen', () => {
|
||||
// the component isn't visible.
|
||||
await act(async () => {
|
||||
child.setState({text: 'B'}, () => {
|
||||
Scheduler.unstable_yieldValue('B update finished');
|
||||
Scheduler.log('B update finished');
|
||||
});
|
||||
});
|
||||
assertLog(['B']);
|
||||
@@ -834,7 +834,7 @@ describe('ReactOffscreen', () => {
|
||||
</Offscreen>,
|
||||
);
|
||||
child.setState({text: 'C'}, () => {
|
||||
Scheduler.unstable_yieldValue('C update finished');
|
||||
Scheduler.log('C update finished');
|
||||
});
|
||||
});
|
||||
assertLog(['C', 'B update finished', 'C update finished']);
|
||||
@@ -845,13 +845,13 @@ describe('ReactOffscreen', () => {
|
||||
it('does not call componentDidUpdate when reappearing a hidden class component', async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
render() {
|
||||
return 'Child';
|
||||
@@ -898,9 +898,9 @@ describe('ReactOffscreen', () => {
|
||||
async () => {
|
||||
function Child({label}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return label;
|
||||
@@ -951,10 +951,10 @@ describe('ReactOffscreen', () => {
|
||||
async () => {
|
||||
class Child extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Mount ' + this.props.label);
|
||||
Scheduler.log('Mount ' + this.props.label);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + this.props.label);
|
||||
Scheduler.log('Unmount ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return this.props.label;
|
||||
@@ -990,7 +990,7 @@ describe('ReactOffscreen', () => {
|
||||
// Reappear the component and also add some new siblings.
|
||||
await act(async () => {
|
||||
setStateB(null, () => {
|
||||
Scheduler.unstable_yieldValue('setState callback B');
|
||||
Scheduler.log('setState callback B');
|
||||
});
|
||||
root.render(
|
||||
<Offscreen mode="visible">
|
||||
@@ -1011,9 +1011,9 @@ describe('ReactOffscreen', () => {
|
||||
it('defer passive effects when prerendering a new Offscreen tree', async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return <Text text={label} />;
|
||||
@@ -1073,9 +1073,9 @@ describe('ReactOffscreen', () => {
|
||||
it('do not defer passive effects when prerendering a new LegacyHidden tree', async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return <Text text={label} />;
|
||||
@@ -1129,9 +1129,9 @@ describe('ReactOffscreen', () => {
|
||||
it('passive effects are connected and disconnected when the visibility changes', async () => {
|
||||
function Child({step}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Commit mount [${step}]`);
|
||||
Scheduler.log(`Commit mount [${step}]`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`Commit unmount [${step}]`);
|
||||
Scheduler.log(`Commit unmount [${step}]`);
|
||||
};
|
||||
}, [step]);
|
||||
return <Text text={step} />;
|
||||
@@ -1186,18 +1186,18 @@ describe('ReactOffscreen', () => {
|
||||
it('passive effects are unmounted on hide in the same order as during a deletion: parent before child', async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Child');
|
||||
Scheduler.log('Mount Child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Child');
|
||||
Scheduler.log('Unmount Child');
|
||||
};
|
||||
}, []);
|
||||
return <div>Hi</div>;
|
||||
}
|
||||
function Parent() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Parent');
|
||||
Scheduler.log('Mount Parent');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Parent');
|
||||
Scheduler.log('Unmount Parent');
|
||||
};
|
||||
}, []);
|
||||
return <Child />;
|
||||
@@ -1244,9 +1244,9 @@ describe('ReactOffscreen', () => {
|
||||
it.skip("don't defer passive effects when prerendering in a tree whose effects are already connected", async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return <Text text={label} />;
|
||||
@@ -1300,9 +1300,9 @@ describe('ReactOffscreen', () => {
|
||||
it('does not mount effects when prerendering a nested Offscreen boundary', async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return <Text text={label} />;
|
||||
@@ -1378,9 +1378,9 @@ describe('ReactOffscreen', () => {
|
||||
it('reveal an outer Offscreen boundary without revealing an inner one', async () => {
|
||||
function Child({label}) {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + label);
|
||||
Scheduler.log('Mount ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount ' + label);
|
||||
Scheduler.log('Unmount ' + label);
|
||||
};
|
||||
}, [label]);
|
||||
return <Text text={label} />;
|
||||
@@ -1819,15 +1819,15 @@ describe('ReactOffscreen', () => {
|
||||
function Child() {
|
||||
spanRef = useRef(null);
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Child');
|
||||
Scheduler.log('Mount Child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Child');
|
||||
Scheduler.log('Unmount Child');
|
||||
};
|
||||
});
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Layout Child');
|
||||
Scheduler.log('Mount Layout Child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Layout Child');
|
||||
Scheduler.log('Unmount Layout Child');
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1974,9 +1974,9 @@ describe('ReactOffscreen', () => {
|
||||
it('batches multiple attach and detach calls scheduled from an event handler', async () => {
|
||||
function Child() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('attach child');
|
||||
Scheduler.log('attach child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('detach child');
|
||||
Scheduler.log('detach child');
|
||||
};
|
||||
}, []);
|
||||
return 'child';
|
||||
@@ -2028,9 +2028,9 @@ describe('ReactOffscreen', () => {
|
||||
it('batches multiple attach and detach calls scheduled from an effect', async () => {
|
||||
function Child() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('attach child');
|
||||
Scheduler.log('attach child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('detach child');
|
||||
Scheduler.log('detach child');
|
||||
};
|
||||
}, []);
|
||||
return 'child';
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('ReactOffscreen', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
throw record.value;
|
||||
@@ -63,7 +63,7 @@ describe('ReactOffscreen', () => {
|
||||
return record.value;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
const thenable = {
|
||||
pings: [],
|
||||
then(resolve) {
|
||||
@@ -86,13 +86,13 @@ describe('ReactOffscreen', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text}) {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -427,11 +427,9 @@ describe('ReactOffscreen', () => {
|
||||
// Inner and outer values are always updated simultaneously, so they
|
||||
// should always be consistent.
|
||||
if (inner !== outer) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Tearing! Inner and outer are inconsistent!',
|
||||
);
|
||||
Scheduler.log('Tearing! Inner and outer are inconsistent!');
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Inner and outer are consistent');
|
||||
Scheduler.log('Inner and outer are consistent');
|
||||
}
|
||||
}, [inner, outer]);
|
||||
|
||||
|
||||
+13
-17
@@ -60,25 +60,21 @@ describe('ReactSchedulerIntegration', () => {
|
||||
const {useEffect, useLayoutEffect} = React;
|
||||
function Effects({step}) {
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Layout Effect');
|
||||
Scheduler.log('Layout Effect');
|
||||
Scheduler.unstable_scheduleCallback(NormalPriority, () =>
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Scheduled Normal Callback from Layout Effect',
|
||||
),
|
||||
Scheduler.log('Scheduled Normal Callback from Layout Effect'),
|
||||
);
|
||||
});
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Passive Effect');
|
||||
Scheduler.log('Passive Effect');
|
||||
});
|
||||
return null;
|
||||
}
|
||||
function CleanupEffect() {
|
||||
useLayoutEffect(() => () => {
|
||||
Scheduler.unstable_yieldValue('Cleanup Layout Effect');
|
||||
Scheduler.log('Cleanup Layout Effect');
|
||||
Scheduler.unstable_scheduleCallback(NormalPriority, () =>
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Scheduled Normal Callback from Cleanup Layout Effect',
|
||||
),
|
||||
Scheduler.log('Scheduled Normal Callback from Cleanup Layout Effect'),
|
||||
);
|
||||
});
|
||||
return null;
|
||||
@@ -107,9 +103,9 @@ describe('ReactSchedulerIntegration', () => {
|
||||
root.render('Initial');
|
||||
await waitForAll([]);
|
||||
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('B'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('C'));
|
||||
|
||||
// Schedule a React render. React will request a paint after committing it.
|
||||
React.startTransition(() => {
|
||||
@@ -119,8 +115,8 @@ describe('ReactSchedulerIntegration', () => {
|
||||
// Advance time just to be sure the next tasks have lower priority
|
||||
Scheduler.unstable_advanceTime(2000);
|
||||
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('E'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('D'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('E'));
|
||||
|
||||
// Flush everything up to the next paint. Should yield after the
|
||||
// React commit.
|
||||
@@ -131,7 +127,7 @@ describe('ReactSchedulerIntegration', () => {
|
||||
// @gate www
|
||||
it('idle updates are not blocked by offscreen work', async () => {
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -200,7 +196,7 @@ describe(
|
||||
...actual,
|
||||
unstable_shouldYield() {
|
||||
if (logDuringShouldYield) {
|
||||
actual.unstable_yieldValue('shouldYield');
|
||||
actual.log('shouldYield');
|
||||
}
|
||||
return actual.unstable_shouldYield();
|
||||
},
|
||||
@@ -273,7 +269,7 @@ describe(
|
||||
// Scheduler API. That being said, feel free to rewrite or delete this
|
||||
// test if/when the API changes.
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,16 +86,16 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -142,10 +142,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
readText(text);
|
||||
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
}, []);
|
||||
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
});
|
||||
|
||||
|
||||
@@ -47,16 +47,12 @@ describe('ReactSuspense', () => {
|
||||
listeners = [{resolve, reject}];
|
||||
setTimeout(() => {
|
||||
if (textResourceShouldFail) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise rejected [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise rejected [${text}]`);
|
||||
status = 'rejected';
|
||||
value = new Error('Failed to load: ' + text);
|
||||
listeners.forEach(listener => listener.reject(value));
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise resolved [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise resolved [${text}]`);
|
||||
status = 'resolved';
|
||||
value = text;
|
||||
listeners.forEach(listener => listener.resolve(value));
|
||||
@@ -85,7 +81,7 @@ describe('ReactSuspense', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -93,13 +89,13 @@ describe('ReactSuspense', () => {
|
||||
const text = props.text;
|
||||
try {
|
||||
TextResource.read([props.text, props.ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -107,12 +103,12 @@ describe('ReactSuspense', () => {
|
||||
|
||||
it('suspends rendering and continues later', async () => {
|
||||
function Bar(props) {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return props.children;
|
||||
}
|
||||
|
||||
function Foo({renderBar}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{renderBar ? (
|
||||
@@ -226,10 +222,10 @@ describe('ReactSuspense', () => {
|
||||
|
||||
function Async() {
|
||||
if (!didResolve) {
|
||||
Scheduler.unstable_yieldValue('Suspend!');
|
||||
Scheduler.log('Suspend!');
|
||||
throw thenable;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Async');
|
||||
Scheduler.log('Async');
|
||||
return 'Async';
|
||||
}
|
||||
|
||||
@@ -277,7 +273,7 @@ describe('ReactSuspense', () => {
|
||||
|
||||
it('throttles fallback committing globally', async () => {
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
<AsyncText text="A" ms={200} />
|
||||
@@ -332,7 +328,7 @@ describe('ReactSuspense', () => {
|
||||
|
||||
it('does not throttle fallback committing for too long', async () => {
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
<AsyncText text="A" ms={200} />
|
||||
@@ -389,10 +385,10 @@ describe('ReactSuspense', () => {
|
||||
it('mounts a lazy class component in non-concurrent mode', async () => {
|
||||
class Class extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
|
||||
Scheduler.log('Did update: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -429,13 +425,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -484,13 +480,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -542,13 +538,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -599,13 +595,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -649,11 +645,11 @@ describe('ReactSuspense', () => {
|
||||
|
||||
it('re-fires layout effects when re-showing Suspense', async () => {
|
||||
function TextWithLayout(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('create layout');
|
||||
Scheduler.log('create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('destroy layout');
|
||||
Scheduler.log('destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return props.text;
|
||||
@@ -692,13 +688,13 @@ describe('ReactSuspense', () => {
|
||||
it('a mounted class component can suspend without losing state', async () => {
|
||||
class TextWithLifecycle extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
|
||||
Scheduler.log(`Mount [${this.props.text}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
|
||||
Scheduler.log(`Update [${this.props.text}]`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
|
||||
Scheduler.log(`Unmount [${this.props.text}]`);
|
||||
}
|
||||
render() {
|
||||
return <Text {...this.props} />;
|
||||
@@ -709,19 +705,13 @@ describe('ReactSuspense', () => {
|
||||
class AsyncTextWithLifecycle extends React.Component {
|
||||
state = {step: 1};
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Mount [${this.props.text}:${this.state.step}]`,
|
||||
);
|
||||
Scheduler.log(`Mount [${this.props.text}:${this.state.step}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Update [${this.props.text}:${this.state.step}]`,
|
||||
);
|
||||
Scheduler.log(`Update [${this.props.text}:${this.state.step}]`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Unmount [${this.props.text}:${this.state.step}]`,
|
||||
);
|
||||
Scheduler.log(`Unmount [${this.props.text}:${this.state.step}]`);
|
||||
}
|
||||
render() {
|
||||
instance = this;
|
||||
@@ -729,13 +719,13 @@ describe('ReactSuspense', () => {
|
||||
const ms = this.props.ms;
|
||||
try {
|
||||
TextResource.read([text, ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -896,20 +886,20 @@ describe('ReactSuspense', () => {
|
||||
it('suspends in a class that has componentWillUnmount and is then deleted', () => {
|
||||
class AsyncTextWithUnmount extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('will unmount');
|
||||
Scheduler.log('will unmount');
|
||||
}
|
||||
render() {
|
||||
const text = this.props.text;
|
||||
const ms = this.props.ms;
|
||||
try {
|
||||
TextResource.read([text, ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -939,18 +929,18 @@ describe('ReactSuspense', () => {
|
||||
const text = props.text;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Did commit: ' + text);
|
||||
Scheduler.log('Did commit: ' + text);
|
||||
}, [text]);
|
||||
|
||||
try {
|
||||
TextResource.read([props.text, props.ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1158,13 +1148,13 @@ describe('ReactSuspense', () => {
|
||||
const fullText = `${text}:${step}`;
|
||||
try {
|
||||
TextResource.read([fullText, ms]);
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return fullText;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${fullText}]`);
|
||||
Scheduler.log(`Suspend! [${fullText}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${fullText}]`);
|
||||
Scheduler.log(`Error! [${fullText}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1290,13 +1280,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1343,13 +1333,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1399,13 +1389,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1455,13 +1445,13 @@ describe('ReactSuspense', () => {
|
||||
const text = useContext(ValueContext);
|
||||
try {
|
||||
TextResource.read([text, 1000]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -1508,9 +1498,7 @@ describe('ReactSuspense', () => {
|
||||
return (
|
||||
<ValueContext.Consumer>
|
||||
{value => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Received context value [${value}]`,
|
||||
);
|
||||
Scheduler.log(`Received context value [${value}]`);
|
||||
if (value === 'default') return <Text text="default" />;
|
||||
throw promiseThatNeverResolves;
|
||||
}}
|
||||
|
||||
+120
-154
@@ -47,10 +47,10 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render: catch');
|
||||
Scheduler.log('ErrorBoundary render: catch');
|
||||
return this.props.fallback;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary render: try');
|
||||
Scheduler.log('ErrorBoundary render: try');
|
||||
return this.props.children;
|
||||
}
|
||||
};
|
||||
@@ -112,16 +112,16 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend:${text}`);
|
||||
Scheduler.log(`Suspend:${text}`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error:${text}`);
|
||||
Scheduler.log(`Error:${text}`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend:${text}`);
|
||||
Scheduler.log(`Suspend:${text}`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -145,17 +145,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
}
|
||||
|
||||
function Text({children = null, text}) {
|
||||
Scheduler.unstable_yieldValue(`Text:${text} render`);
|
||||
Scheduler.log(`Text:${text} render`);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Text:${text} create layout`);
|
||||
Scheduler.log(`Text:${text} create layout`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`Text:${text} destroy layout`);
|
||||
Scheduler.log(`Text:${text} destroy layout`);
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Text:${text} create passive`);
|
||||
Scheduler.log(`Text:${text} create passive`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`Text:${text} destroy passive`);
|
||||
Scheduler.log(`Text:${text} destroy passive`);
|
||||
};
|
||||
}, []);
|
||||
return <span prop={text}>{children}</span>;
|
||||
@@ -163,17 +163,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
|
||||
function AsyncText({children = null, text}) {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(`AsyncText:${text} render`);
|
||||
Scheduler.log(`AsyncText:${text} render`);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`AsyncText:${text} create layout`);
|
||||
Scheduler.log(`AsyncText:${text} create layout`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`AsyncText:${text} destroy layout`);
|
||||
Scheduler.log(`AsyncText:${text} destroy layout`);
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`AsyncText:${text} create passive`);
|
||||
Scheduler.log(`AsyncText:${text} create passive`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`AsyncText:${text} destroy passive`);
|
||||
Scheduler.log(`AsyncText:${text} destroy passive`);
|
||||
};
|
||||
}, []);
|
||||
return <span prop={text}>{children}</span>;
|
||||
@@ -209,37 +209,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
class ClassText extends React.Component {
|
||||
componentDidMount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
|
||||
Scheduler.log(`ClassText:${text} componentDidMount`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
|
||||
Scheduler.log(`ClassText:${text} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassText:${text} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`ClassText:${text} componentWillUnmount`);
|
||||
}
|
||||
render() {
|
||||
const {children, text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} render`);
|
||||
Scheduler.log(`ClassText:${text} render`);
|
||||
return <span prop={text}>{children}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -330,37 +328,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
class ClassText extends React.Component {
|
||||
componentDidMount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
|
||||
Scheduler.log(`ClassText:${text} componentDidMount`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
|
||||
Scheduler.log(`ClassText:${text} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassText:${text} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`ClassText:${text} componentWillUnmount`);
|
||||
}
|
||||
render() {
|
||||
const {children, text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} render`);
|
||||
Scheduler.log(`ClassText:${text} render`);
|
||||
return <span prop={text}>{children}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -451,17 +447,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should not be destroyed or recreated in legacy roots', async () => {
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -582,17 +578,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should be destroyed and recreated for function components', async () => {
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -720,37 +716,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
class ClassText extends React.Component {
|
||||
componentDidMount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
|
||||
Scheduler.log(`ClassText:${text} componentDidMount`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
|
||||
Scheduler.log(`ClassText:${text} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassText:${text} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`ClassText:${text} componentWillUnmount`);
|
||||
}
|
||||
render() {
|
||||
const {children, text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} render`);
|
||||
Scheduler.log(`ClassText:${text} render`);
|
||||
return <span prop={text}>{children}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -869,17 +863,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should be destroyed and recreated when nested below host components', async () => {
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -996,17 +990,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
const MemoizedText = React.memo(Text, () => true);
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create passive');
|
||||
Scheduler.log('App create passive');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy passive');
|
||||
Scheduler.log('App destroy passive');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -1853,28 +1847,26 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
|
||||
class ThrowsInDidMount extends React.Component {
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInDidMount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('ThrowsInDidMount componentWillUnmount');
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInDidMount componentDidMount');
|
||||
Scheduler.log('ThrowsInDidMount componentDidMount');
|
||||
if (componentDidMountShouldThrow) {
|
||||
throw Error('expected');
|
||||
}
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInDidMount render');
|
||||
Scheduler.log('ThrowsInDidMount render');
|
||||
return <span prop="ThrowsInDidMount" />;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -1993,28 +1985,24 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
it('are properly handled for componentWillUnmount', async () => {
|
||||
class ThrowsInWillUnmount extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInWillUnmount componentDidMount',
|
||||
);
|
||||
Scheduler.log('ThrowsInWillUnmount componentDidMount');
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInWillUnmount componentWillUnmount',
|
||||
);
|
||||
Scheduler.log('ThrowsInWillUnmount componentWillUnmount');
|
||||
throw Error('expected');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInWillUnmount render');
|
||||
Scheduler.log('ThrowsInWillUnmount render');
|
||||
return <span prop="ThrowsInWillUnmount" />;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -2108,29 +2096,25 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
let useLayoutEffectShouldThrow = false;
|
||||
|
||||
function ThrowsInLayoutEffect() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInLayoutEffect render');
|
||||
Scheduler.log('ThrowsInLayoutEffect render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInLayoutEffect useLayoutEffect create',
|
||||
);
|
||||
Scheduler.log('ThrowsInLayoutEffect useLayoutEffect create');
|
||||
if (useLayoutEffectShouldThrow) {
|
||||
throw Error('expected');
|
||||
}
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInLayoutEffect useLayoutEffect destroy',
|
||||
);
|
||||
Scheduler.log('ThrowsInLayoutEffect useLayoutEffect destroy');
|
||||
};
|
||||
}, []);
|
||||
return <span prop="ThrowsInLayoutEffect" />;
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -2249,13 +2233,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate replayFailedUnitOfWorkWithInvokeGuardedCallback
|
||||
it('are properly handled for layout effect destruction', async () => {
|
||||
function ThrowsInLayoutEffectDestroy() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInLayoutEffectDestroy render');
|
||||
Scheduler.log('ThrowsInLayoutEffectDestroy render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInLayoutEffectDestroy useLayoutEffect create',
|
||||
);
|
||||
Scheduler.log('ThrowsInLayoutEffectDestroy useLayoutEffect create');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'ThrowsInLayoutEffectDestroy useLayoutEffect destroy',
|
||||
);
|
||||
throw Error('expected');
|
||||
@@ -2265,11 +2247,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -2363,21 +2345,19 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
class ClassText extends React.Component {
|
||||
componentDidMount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
|
||||
Scheduler.log(`ClassText:${text} componentDidMount`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
|
||||
Scheduler.log(`ClassText:${text} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassText:${text} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`ClassText:${text} componentWillUnmount`);
|
||||
}
|
||||
render() {
|
||||
const {children, text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} render`);
|
||||
Scheduler.log(`ClassText:${text} render`);
|
||||
return <span prop={text}>{children}</span>;
|
||||
}
|
||||
}
|
||||
@@ -2511,21 +2491,19 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
class ClassText extends React.Component {
|
||||
componentDidMount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
|
||||
Scheduler.log(`ClassText:${text} componentDidMount`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
|
||||
Scheduler.log(`ClassText:${text} componentDidUpdate`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
const {text} = this.props;
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassText:${text} componentWillUnmount`,
|
||||
);
|
||||
Scheduler.log(`ClassText:${text} componentWillUnmount`);
|
||||
}
|
||||
render() {
|
||||
const {children, text} = this.props;
|
||||
Scheduler.unstable_yieldValue(`ClassText:${text} render`);
|
||||
Scheduler.log(`ClassText:${text} render`);
|
||||
return <span prop={text}>{children}</span>;
|
||||
}
|
||||
}
|
||||
@@ -2533,7 +2511,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
let textToRead = null;
|
||||
|
||||
function Suspender() {
|
||||
Scheduler.unstable_yieldValue(`Suspender "${textToRead}" render`);
|
||||
Scheduler.log(`Suspender "${textToRead}" render`);
|
||||
if (textToRead !== null) {
|
||||
readText(textToRead);
|
||||
}
|
||||
@@ -2663,22 +2641,20 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
|
||||
const manualRef = React.useMemo(() => ({current: null}), []);
|
||||
const refCallback = React.useCallback(value => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`RefCheckerOuter refCallback value? ${value != null}`,
|
||||
);
|
||||
Scheduler.log(`RefCheckerOuter refCallback value? ${value != null}`);
|
||||
manualRef.current = value;
|
||||
}, []);
|
||||
|
||||
Scheduler.unstable_yieldValue(`RefCheckerOuter render`);
|
||||
Scheduler.log(`RefCheckerOuter render`);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefCheckerOuter create layout refObject? ${
|
||||
refObject.current != null
|
||||
} refCallback? ${manualRef.current != null}`,
|
||||
);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefCheckerOuter destroy layout refObject? ${
|
||||
refObject.current != null
|
||||
} refCallback? ${manualRef.current != null}`,
|
||||
@@ -2699,15 +2675,15 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
}
|
||||
|
||||
function RefCheckerInner({forwardedRef, text}) {
|
||||
Scheduler.unstable_yieldValue(`RefCheckerInner:${text} render`);
|
||||
Scheduler.log(`RefCheckerInner:${text} render`);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefCheckerInner:${text} create layout ref? ${
|
||||
forwardedRef.current != null
|
||||
}`,
|
||||
);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefCheckerInner:${text} destroy layout ref? ${
|
||||
forwardedRef.current != null
|
||||
}`,
|
||||
@@ -2721,15 +2697,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
it('should not be cleared within legacy roots', async () => {
|
||||
class ClassComponent extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassComponent:${this.props.prop} render`,
|
||||
);
|
||||
Scheduler.log(`ClassComponent:${this.props.prop} render`);
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children}) {
|
||||
Scheduler.unstable_yieldValue(`App render`);
|
||||
Scheduler.log(`App render`);
|
||||
return (
|
||||
<Suspense fallback={<Text text="Fallback" />}>
|
||||
{children}
|
||||
@@ -2806,7 +2780,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should be cleared and reset for host components', async () => {
|
||||
function App({children}) {
|
||||
Scheduler.unstable_yieldValue(`App render`);
|
||||
Scheduler.log(`App render`);
|
||||
return (
|
||||
<Suspense fallback={<Text text="Fallback" />}>
|
||||
{children}
|
||||
@@ -2909,15 +2883,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
it('should be cleared and reset for class components', async () => {
|
||||
class ClassComponent extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`ClassComponent:${this.props.prop} render`,
|
||||
);
|
||||
Scheduler.log(`ClassComponent:${this.props.prop} render`);
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function App({children}) {
|
||||
Scheduler.unstable_yieldValue(`App render`);
|
||||
Scheduler.log(`App render`);
|
||||
return (
|
||||
<Suspense fallback={<Text text="Fallback" />}>
|
||||
{children}
|
||||
@@ -3008,7 +2980,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should be cleared and reset for function components with useImperativeHandle', async () => {
|
||||
const FunctionComponent = React.forwardRef((props, ref) => {
|
||||
Scheduler.unstable_yieldValue('FunctionComponent render');
|
||||
Scheduler.log('FunctionComponent render');
|
||||
React.useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
@@ -3021,7 +2993,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
FunctionComponent.displayName = 'FunctionComponent';
|
||||
|
||||
function App({children}) {
|
||||
Scheduler.unstable_yieldValue(`App render`);
|
||||
Scheduler.log(`App render`);
|
||||
return (
|
||||
<Suspense fallback={<Text text="Fallback" />}>
|
||||
{children}
|
||||
@@ -3112,13 +3084,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('should not reset for user-managed values', async () => {
|
||||
function RefChecker({forwardedRef}) {
|
||||
Scheduler.unstable_yieldValue(`RefChecker render`);
|
||||
Scheduler.log(`RefChecker render`);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefChecker create layout ref? ${forwardedRef.current === 'test'}`,
|
||||
);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`RefChecker destroy layout ref? ${
|
||||
forwardedRef.current === 'test'
|
||||
}`,
|
||||
@@ -3130,15 +3102,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
|
||||
function App({children = null}) {
|
||||
const ref = React.useRef('test');
|
||||
Scheduler.unstable_yieldValue(`App render`);
|
||||
Scheduler.log(`App render`);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`App create layout ref? ${ref.current === 'test'}`,
|
||||
);
|
||||
Scheduler.log(`App create layout ref? ${ref.current === 'test'}`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`App destroy layout ref? ${ref.current === 'test'}`,
|
||||
);
|
||||
Scheduler.log(`App destroy layout ref? ${ref.current === 'test'}`);
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
@@ -3213,11 +3181,9 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
let useRefCallbackShouldThrow = false;
|
||||
|
||||
function ThrowsInRefCallback() {
|
||||
Scheduler.unstable_yieldValue('ThrowsInRefCallback render');
|
||||
Scheduler.log('ThrowsInRefCallback render');
|
||||
const refCallback = React.useCallback(value => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'ThrowsInRefCallback refCallback ref? ' + !!value,
|
||||
);
|
||||
Scheduler.log('ThrowsInRefCallback refCallback ref? ' + !!value);
|
||||
if (useRefCallbackShouldThrow) {
|
||||
throw Error('expected');
|
||||
}
|
||||
@@ -3226,11 +3192,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
|
||||
}
|
||||
|
||||
function App({children = null}) {
|
||||
Scheduler.unstable_yieldValue('App render');
|
||||
Scheduler.log('App render');
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App create layout');
|
||||
Scheduler.log('App create layout');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('App destroy layout');
|
||||
Scheduler.log('App destroy layout');
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
|
||||
+23
-23
@@ -45,7 +45,7 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
}
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return props.text;
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
<span
|
||||
ref={node => {
|
||||
if (node) {
|
||||
Scheduler.unstable_yieldValue('Ref mount: ' + label);
|
||||
Scheduler.log('Ref mount: ' + label);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Ref unmount: ' + label);
|
||||
Scheduler.log('Ref unmount: ' + label);
|
||||
}
|
||||
}}>
|
||||
<Text text={label} />
|
||||
@@ -120,9 +120,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
<span
|
||||
ref={node => {
|
||||
if (node) {
|
||||
Scheduler.unstable_yieldValue('Ref mount: ' + label);
|
||||
Scheduler.log('Ref mount: ' + label);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Ref unmount: ' + label);
|
||||
Scheduler.log('Ref unmount: ' + label);
|
||||
}
|
||||
}}>
|
||||
<Text text={label} />
|
||||
@@ -168,10 +168,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
it('does not call componentWillUnmount twice when hidden child is removed', async () => {
|
||||
class ChildA extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
|
||||
Scheduler.log('Will unmount: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -180,10 +180,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
|
||||
class ChildB extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
|
||||
Scheduler.log('Will unmount: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -226,18 +226,18 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
it('does not destroy layout effects twice when parent suspense is removed', async () => {
|
||||
function ChildA({label}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + label);
|
||||
Scheduler.log('Did mount: ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + label);
|
||||
Scheduler.log('Will unmount: ' + label);
|
||||
};
|
||||
}, []);
|
||||
return <Text text={label} />;
|
||||
}
|
||||
function ChildB({label}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + label);
|
||||
Scheduler.log('Did mount: ' + label);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + label);
|
||||
Scheduler.log('Will unmount: ' + label);
|
||||
};
|
||||
}, []);
|
||||
return <Text text={label} />;
|
||||
@@ -284,9 +284,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
<span
|
||||
ref={node => {
|
||||
if (node) {
|
||||
Scheduler.unstable_yieldValue('Ref mount: ' + label);
|
||||
Scheduler.log('Ref mount: ' + label);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Ref unmount: ' + label);
|
||||
Scheduler.log('Ref unmount: ' + label);
|
||||
}
|
||||
}}>
|
||||
<Text text={label} />
|
||||
@@ -299,9 +299,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
<span
|
||||
ref={node => {
|
||||
if (node) {
|
||||
Scheduler.unstable_yieldValue('Ref mount: ' + label);
|
||||
Scheduler.log('Ref mount: ' + label);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue('Ref unmount: ' + label);
|
||||
Scheduler.log('Ref unmount: ' + label);
|
||||
}
|
||||
}}>
|
||||
<Text text={label} />
|
||||
@@ -350,10 +350,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
it('does not call componentWillUnmount twice when parent suspense is removed', async () => {
|
||||
class ChildA extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
|
||||
Scheduler.log('Will unmount: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -362,10 +362,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
|
||||
class ChildB extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
|
||||
Scheduler.log('Did mount: ' + this.props.label);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
|
||||
Scheduler.log('Will unmount: ' + this.props.label);
|
||||
}
|
||||
render() {
|
||||
return <Text text={this.props.label} />;
|
||||
@@ -414,9 +414,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
|
||||
|
||||
function Child() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount');
|
||||
Scheduler.log('Mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount');
|
||||
Scheduler.log('Unmount');
|
||||
};
|
||||
}, []);
|
||||
return <Text text="Child" />;
|
||||
|
||||
@@ -87,16 +87,16 @@ describe('ReactSuspenseFallback', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -120,14 +120,14 @@ describe('ReactSuspenseFallback', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span prop={text} />;
|
||||
}
|
||||
|
||||
function AsyncText({text, showVersion}) {
|
||||
const version = readText(text);
|
||||
const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return <span prop={fullText} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('ReactSuspenseFuzz', () => {
|
||||
};
|
||||
const timeoutID = setTimeout(() => {
|
||||
pendingTasks.delete(task);
|
||||
Scheduler.unstable_yieldValue(task.label);
|
||||
Scheduler.log(task.label);
|
||||
setStep(i + 1);
|
||||
}, remountAfter);
|
||||
pendingTasks.add(task);
|
||||
@@ -87,7 +87,7 @@ describe('ReactSuspenseFuzz', () => {
|
||||
};
|
||||
const timeoutID = setTimeout(() => {
|
||||
pendingTasks.delete(task);
|
||||
Scheduler.unstable_yieldValue(task.label);
|
||||
Scheduler.log(task.label);
|
||||
setStep([i + 1, suspendFor]);
|
||||
}, beginAfter);
|
||||
pendingTasks.add(task);
|
||||
@@ -117,24 +117,24 @@ describe('ReactSuspenseFuzz', () => {
|
||||
setTimeout(() => {
|
||||
cache.set(fullText, fullText);
|
||||
pendingTasks.delete(task);
|
||||
Scheduler.unstable_yieldValue(task.label);
|
||||
Scheduler.log(task.label);
|
||||
resolve();
|
||||
}, delay);
|
||||
},
|
||||
};
|
||||
cache.set(fullText, thenable);
|
||||
Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
|
||||
Scheduler.log(`Suspended! [${fullText}]`);
|
||||
throw thenable;
|
||||
} else if (typeof resolvedText.then === 'function') {
|
||||
const thenable = resolvedText;
|
||||
Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
|
||||
Scheduler.log(`Suspended! [${fullText}]`);
|
||||
throw thenable;
|
||||
}
|
||||
} else {
|
||||
resolvedText = fullText;
|
||||
}
|
||||
|
||||
Scheduler.unstable_yieldValue(resolvedText);
|
||||
Scheduler.log(resolvedText);
|
||||
return resolvedText;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('ReactSuspenseList', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span>{props.text}</span>;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('ReactSuspenseList', () => {
|
||||
let resolved = false;
|
||||
const Component = function () {
|
||||
if (!resolved) {
|
||||
Scheduler.unstable_yieldValue('Suspend! [' + text + ']');
|
||||
Scheduler.log('Suspend! [' + text + ']');
|
||||
throw promise;
|
||||
}
|
||||
return <Text text={text} />;
|
||||
@@ -2607,7 +2607,7 @@ describe('ReactSuspenseList', () => {
|
||||
function TwoPass({text}) {
|
||||
const [pass, setPass] = React.useState(0);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + text);
|
||||
Scheduler.log('Mount ' + text);
|
||||
setPass(1);
|
||||
}, []);
|
||||
return <Text text={pass === 0 ? 'First Pass ' + text : text} />;
|
||||
@@ -2619,7 +2619,7 @@ describe('ReactSuspenseList', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<SuspenseList revealOrder="forwards" tail="hidden">
|
||||
<Suspense fallback={<Text text="Loading A" />}>
|
||||
@@ -2668,7 +2668,7 @@ describe('ReactSuspenseList', () => {
|
||||
function TwoPass({text}) {
|
||||
const [pass, setPass] = React.useState(0);
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount ' + text);
|
||||
Scheduler.log('Mount ' + text);
|
||||
setPass(1);
|
||||
}, []);
|
||||
return <Text text={pass === 0 ? 'First Pass ' + text : text} />;
|
||||
@@ -2680,7 +2680,7 @@ describe('ReactSuspenseList', () => {
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<SuspenseList revealOrder="forwards">
|
||||
<Suspense fallback={<Text text="Loading A" />}>
|
||||
@@ -2747,7 +2747,7 @@ describe('ReactSuspenseList', () => {
|
||||
const onRender = jest.fn();
|
||||
|
||||
const Fallback = () => {
|
||||
Scheduler.unstable_yieldValue('Fallback');
|
||||
Scheduler.log('Fallback');
|
||||
Scheduler.unstable_advanceTime(3);
|
||||
return <span>Loading...</span>;
|
||||
};
|
||||
@@ -2765,7 +2765,7 @@ describe('ReactSuspenseList', () => {
|
||||
}
|
||||
|
||||
function App({addRow, suspendTail}) {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Profiler id="root" onRender={onRender}>
|
||||
<SuspenseList revealOrder="forwards">
|
||||
|
||||
@@ -53,16 +53,12 @@ describe('ReactSuspensePlaceholder', () => {
|
||||
listeners = [{resolve, reject}];
|
||||
setTimeout(() => {
|
||||
if (textResourceShouldFail) {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise rejected [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise rejected [${text}]`);
|
||||
status = 'rejected';
|
||||
value = new Error('Failed to load: ' + text);
|
||||
listeners.forEach(listener => listener.reject(value));
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Promise resolved [${text}]`,
|
||||
);
|
||||
Scheduler.log(`Promise resolved [${text}]`);
|
||||
status = 'resolved';
|
||||
value = text;
|
||||
listeners.forEach(listener => listener.resolve(value));
|
||||
@@ -92,7 +88,7 @@ describe('ReactSuspensePlaceholder', () => {
|
||||
|
||||
function Text({fakeRenderDuration = 0, text = 'Text'}) {
|
||||
Scheduler.unstable_advanceTime(fakeRenderDuration);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -100,13 +96,13 @@ describe('ReactSuspensePlaceholder', () => {
|
||||
Scheduler.unstable_advanceTime(fakeRenderDuration);
|
||||
try {
|
||||
TextResource.read([text, ms]);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
} catch (promise) {
|
||||
if (typeof promise.then === 'function') {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
}
|
||||
throw promise;
|
||||
}
|
||||
@@ -116,7 +112,7 @@ describe('ReactSuspensePlaceholder', () => {
|
||||
class HiddenText extends React.PureComponent {
|
||||
render() {
|
||||
const text = this.props.text;
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span hidden={true}>{text}</span>;
|
||||
}
|
||||
}
|
||||
@@ -281,19 +277,19 @@ describe('ReactSuspensePlaceholder', () => {
|
||||
onRender = jest.fn();
|
||||
|
||||
const Fallback = () => {
|
||||
Scheduler.unstable_yieldValue('Fallback');
|
||||
Scheduler.log('Fallback');
|
||||
Scheduler.unstable_advanceTime(10);
|
||||
return 'Loading...';
|
||||
};
|
||||
|
||||
const Suspending = () => {
|
||||
Scheduler.unstable_yieldValue('Suspending');
|
||||
Scheduler.log('Suspending');
|
||||
Scheduler.unstable_advanceTime(2);
|
||||
return <AsyncText ms={1000} text="Loaded" fakeRenderDuration={1} />;
|
||||
};
|
||||
|
||||
App = ({shouldSuspend, text = 'Text', textRenderDuration = 5}) => {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return (
|
||||
<Profiler id="root" onRender={onRender}>
|
||||
<Suspense fallback={<Fallback />}>
|
||||
|
||||
+65
-77
@@ -91,16 +91,16 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -124,14 +124,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span prop={text} />;
|
||||
}
|
||||
|
||||
function AsyncText({text, showVersion}) {
|
||||
const version = readText(text);
|
||||
const fullText = showVersion ? `${text} [v${version}]` : text;
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return <span prop={fullText} />;
|
||||
}
|
||||
|
||||
@@ -194,12 +194,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('does not restart rendering for initial render', async () => {
|
||||
function Bar(props) {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return props.children;
|
||||
}
|
||||
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<>
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
@@ -260,12 +260,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('suspends rendering and continues later', async () => {
|
||||
function Bar(props) {
|
||||
Scheduler.unstable_yieldValue('Bar');
|
||||
Scheduler.log('Bar');
|
||||
return props.children;
|
||||
}
|
||||
|
||||
function Foo({renderBar}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{renderBar ? (
|
||||
@@ -1153,10 +1153,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
it('flushes all expired updates in a single batch', async () => {
|
||||
class Foo extends React.Component {
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
|
||||
Scheduler.log('Commit: ' + this.props.text);
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
|
||||
Scheduler.log('Commit: ' + this.props.text);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@@ -1292,7 +1292,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
// Update.
|
||||
text.current.setState({step: 2}, () =>
|
||||
Scheduler.unstable_yieldValue('Update did commit'),
|
||||
Scheduler.log('Update did commit'),
|
||||
);
|
||||
|
||||
expect(ReactNoop.flushNextYield()).toEqual([
|
||||
@@ -1328,10 +1328,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
it('does not re-render siblings in loose mode', async () => {
|
||||
class TextWithLifecycle extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
|
||||
Scheduler.log(`Mount [${this.props.text}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
|
||||
Scheduler.log(`Update [${this.props.text}]`);
|
||||
}
|
||||
render() {
|
||||
return <Text {...this.props} />;
|
||||
@@ -1340,10 +1340,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
class AsyncTextWithLifecycle extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
|
||||
Scheduler.log(`Mount [${this.props.text}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
|
||||
Scheduler.log(`Update [${this.props.text}]`);
|
||||
}
|
||||
render() {
|
||||
return <AsyncText {...this.props} />;
|
||||
@@ -1361,7 +1361,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
}
|
||||
|
||||
ReactNoop.renderLegacySyncRoot(<App />, () =>
|
||||
Scheduler.unstable_yieldValue('Commit root'),
|
||||
Scheduler.log('Commit root'),
|
||||
);
|
||||
assertLog([
|
||||
'A',
|
||||
@@ -1405,15 +1405,15 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const text = props.text;
|
||||
Scheduler.unstable_yieldValue('constructor');
|
||||
Scheduler.log('constructor');
|
||||
readText(text);
|
||||
this.state = {text};
|
||||
}
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(this.state.text);
|
||||
Scheduler.log(this.state.text);
|
||||
return <span prop={this.state.text} />;
|
||||
}
|
||||
}
|
||||
@@ -1486,7 +1486,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
const child = useRef(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(ReactNoop.getPendingChildrenAsJSX());
|
||||
Scheduler.log(ReactNoop.getPendingChildrenAsJSX());
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -1530,9 +1530,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
const child = useRef(null);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Child is hidden: ' + child.current.hidden,
|
||||
);
|
||||
Scheduler.log('Child is hidden: ' + child.current.hidden);
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -1622,9 +1620,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount');
|
||||
Scheduler.log('Mount');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount');
|
||||
Scheduler.log('Unmount');
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -1656,13 +1654,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
it('does not call lifecycles of a suspended component', async () => {
|
||||
class TextWithLifecycle extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
|
||||
Scheduler.log(`Mount [${this.props.text}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
|
||||
Scheduler.log(`Update [${this.props.text}]`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
|
||||
Scheduler.log(`Unmount [${this.props.text}]`);
|
||||
}
|
||||
render() {
|
||||
return <Text {...this.props} />;
|
||||
@@ -1671,18 +1669,18 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
class AsyncTextWithLifecycle extends React.Component {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
|
||||
Scheduler.log(`Mount [${this.props.text}]`);
|
||||
}
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
|
||||
Scheduler.log(`Update [${this.props.text}]`);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
|
||||
Scheduler.log(`Unmount [${this.props.text}]`);
|
||||
}
|
||||
render() {
|
||||
const text = this.props.text;
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span prop={text} />;
|
||||
}
|
||||
}
|
||||
@@ -1697,9 +1695,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
);
|
||||
}
|
||||
|
||||
ReactNoop.renderLegacySyncRoot(<App />, () =>
|
||||
Scheduler.unstable_yieldValue('Commit root'),
|
||||
);
|
||||
ReactNoop.renderLegacySyncRoot(<App />, () => Scheduler.log('Commit root'));
|
||||
assertLog([
|
||||
'A',
|
||||
'Suspend! [B]',
|
||||
@@ -1726,17 +1722,15 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
it('does not call lifecycles of a suspended component (hooks)', async () => {
|
||||
function TextWithLifecycle(props) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Layout Effect [${props.text}]`);
|
||||
Scheduler.log(`Layout Effect [${props.text}]`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Destroy Layout Effect [${props.text}]`,
|
||||
);
|
||||
Scheduler.log(`Destroy Layout Effect [${props.text}]`);
|
||||
};
|
||||
}, [props.text]);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Effect [${props.text}]`);
|
||||
Scheduler.log(`Effect [${props.text}]`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`Destroy Effect [${props.text}]`);
|
||||
Scheduler.log(`Destroy Effect [${props.text}]`);
|
||||
};
|
||||
}, [props.text]);
|
||||
return <Text {...props} />;
|
||||
@@ -1744,22 +1738,20 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
function AsyncTextWithLifecycle(props) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Layout Effect [${props.text}]`);
|
||||
Scheduler.log(`Layout Effect [${props.text}]`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`Destroy Layout Effect [${props.text}]`,
|
||||
);
|
||||
Scheduler.log(`Destroy Layout Effect [${props.text}]`);
|
||||
};
|
||||
}, [props.text]);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`Effect [${props.text}]`);
|
||||
Scheduler.log(`Effect [${props.text}]`);
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue(`Destroy Effect [${props.text}]`);
|
||||
Scheduler.log(`Destroy Effect [${props.text}]`);
|
||||
};
|
||||
}, [props.text]);
|
||||
const text = props.text;
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return <span prop={text} />;
|
||||
}
|
||||
|
||||
@@ -1774,7 +1766,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
}
|
||||
|
||||
ReactNoop.renderLegacySyncRoot(<App text="B" />, () =>
|
||||
Scheduler.unstable_yieldValue('Commit root'),
|
||||
Scheduler.log('Commit root'),
|
||||
);
|
||||
assertLog([
|
||||
'A',
|
||||
@@ -1821,7 +1813,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
// Update
|
||||
ReactNoop.renderLegacySyncRoot(<App text="B2" />, () =>
|
||||
Scheduler.unstable_yieldValue('Commit root'),
|
||||
Scheduler.log('Commit root'),
|
||||
);
|
||||
|
||||
assertLog([
|
||||
@@ -1861,7 +1853,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('suspends for longer if something took a long (CPU bound) time to render', async () => {
|
||||
function Foo({renderContent}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{renderContent ? <AsyncText text="A" /> : null}
|
||||
@@ -1917,7 +1909,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('does not suspends if a fallback has been shown for a long time', async () => {
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
<AsyncText text="A" />
|
||||
@@ -1978,7 +1970,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('does suspend if a fallback has been shown for a short time', async () => {
|
||||
function Foo() {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
<AsyncText text="A" />
|
||||
@@ -2033,7 +2025,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('does not suspend for very long after a higher priority update', async () => {
|
||||
function Foo({renderContent}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
{renderContent ? <AsyncText text="A" /> : null}
|
||||
@@ -2245,7 +2237,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache && enableSuspenseAvoidThisFallback
|
||||
it('shows the parent fallback if the inner fallback should be avoided', async () => {
|
||||
function Foo({showC}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Initial load..." />}>
|
||||
<Suspense
|
||||
@@ -2304,7 +2296,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('does not show the parent fallback if the inner fallback is not defined', async () => {
|
||||
function Foo({showC}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Initial load..." />}>
|
||||
<Suspense>
|
||||
@@ -2369,7 +2361,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('favors showing the inner fallback for nested top level avoided fallback', async () => {
|
||||
function Foo({showB}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense
|
||||
unstable_avoidThisFallback={true}
|
||||
@@ -2401,7 +2393,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache && enableSuspenseAvoidThisFallback
|
||||
it('keeps showing an avoided parent fallback if it is already showing', async () => {
|
||||
function Foo({showB}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Initial load..." />}>
|
||||
<Suspense
|
||||
@@ -2443,7 +2435,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache
|
||||
it('keeps showing an undefined fallback if it is already showing', async () => {
|
||||
function Foo({showB}) {
|
||||
Scheduler.unstable_yieldValue('Foo');
|
||||
Scheduler.log('Foo');
|
||||
return (
|
||||
<Suspense fallback={<Text text="Initial load..." />}>
|
||||
<Suspense fallback={undefined}>
|
||||
@@ -3053,7 +3045,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
foo = this;
|
||||
|
||||
if (this.state.suspend) {
|
||||
Scheduler.unstable_yieldValue('Suspend!');
|
||||
Scheduler.log('Suspend!');
|
||||
throw thenable;
|
||||
}
|
||||
|
||||
@@ -3091,12 +3083,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache && enableLegacyHidden
|
||||
it('should not render hidden content while suspended on higher pri', async () => {
|
||||
function Offscreen() {
|
||||
Scheduler.unstable_yieldValue('Offscreen');
|
||||
Scheduler.log('Offscreen');
|
||||
return 'Offscreen';
|
||||
}
|
||||
function App({showContent}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<>
|
||||
@@ -3141,12 +3133,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// @gate enableLegacyCache && enableLegacyHidden
|
||||
it('should be able to unblock higher pri content before suspended hidden', async () => {
|
||||
function Offscreen() {
|
||||
Scheduler.unstable_yieldValue('Offscreen');
|
||||
Scheduler.log('Offscreen');
|
||||
return 'Offscreen';
|
||||
}
|
||||
function App({showContent}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
@@ -3589,11 +3581,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// This will log if the component commits in an inconsistent state
|
||||
useEffect(() => {
|
||||
if (text === outerText) {
|
||||
Scheduler.unstable_yieldValue('Commit Child');
|
||||
Scheduler.log('Commit Child');
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'FIXME: Texts are inconsistent (tearing)',
|
||||
);
|
||||
Scheduler.log('FIXME: Texts are inconsistent (tearing)');
|
||||
}
|
||||
}, [text, outerText]);
|
||||
|
||||
@@ -3725,11 +3715,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
// This will log if the component commits in an inconsistent state
|
||||
useEffect(() => {
|
||||
if (text === outerText) {
|
||||
Scheduler.unstable_yieldValue('Commit Child');
|
||||
Scheduler.log('Commit Child');
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(
|
||||
'FIXME: Texts are inconsistent (tearing)',
|
||||
);
|
||||
Scheduler.log('FIXME: Texts are inconsistent (tearing)');
|
||||
}
|
||||
}, [text, outerText]);
|
||||
|
||||
@@ -4014,9 +4002,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
function Child() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Child');
|
||||
Scheduler.log('Mount Child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Child');
|
||||
Scheduler.log('Unmount Child');
|
||||
};
|
||||
}, []);
|
||||
return <span prop="Child" />;
|
||||
@@ -4062,9 +4050,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
|
||||
function Child() {
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Mount Child');
|
||||
Scheduler.log('Mount Child');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Unmount Child');
|
||||
Scheduler.log('Unmount Child');
|
||||
};
|
||||
}, []);
|
||||
return <span prop="Child" />;
|
||||
|
||||
+11
-11
@@ -54,7 +54,7 @@ describe('ReactThenable', () => {
|
||||
// getAsyncText is completely uncached — it performs a new async operation
|
||||
// every time it's called. During a transition, React should be able to
|
||||
// unwrap it anyway.
|
||||
Scheduler.unstable_yieldValue(`Async text requested [${text}]`);
|
||||
Scheduler.log(`Async text requested [${text}]`);
|
||||
return new Promise(resolve => {
|
||||
const requests = pendingTextRequests.get(text);
|
||||
if (requests !== undefined) {
|
||||
@@ -67,7 +67,7 @@ describe('ReactThenable', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ describe('ReactThenable', () => {
|
||||
if (fulfilled) {
|
||||
return <Text text="Async" />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Suspend!');
|
||||
Scheduler.log('Suspend!');
|
||||
throw Promise.resolve().then(() => {
|
||||
Scheduler.unstable_yieldValue('Resolve in microtask');
|
||||
Scheduler.log('Resolve in microtask');
|
||||
fulfilled = true;
|
||||
});
|
||||
}
|
||||
@@ -121,9 +121,9 @@ describe('ReactThenable', () => {
|
||||
if (fulfilled) {
|
||||
return <Text text="Async" />;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Suspend!');
|
||||
Scheduler.log('Suspend!');
|
||||
throw Promise.resolve().then(() => {
|
||||
Scheduler.unstable_yieldValue('Resolve in microtask');
|
||||
Scheduler.log('Resolve in microtask');
|
||||
fulfilled = true;
|
||||
});
|
||||
}
|
||||
@@ -160,7 +160,7 @@ describe('ReactThenable', () => {
|
||||
if (i++ > 50) {
|
||||
throw new Error('Infinite loop detected');
|
||||
}
|
||||
Scheduler.unstable_yieldValue('Suspend!');
|
||||
Scheduler.log('Suspend!');
|
||||
// This thenable should never be thrown because it already fulfilled.
|
||||
// But if it is thrown, React should handle it gracefully.
|
||||
throw thenable;
|
||||
@@ -381,7 +381,7 @@ describe('ReactThenable', () => {
|
||||
try {
|
||||
use(Promise.resolve('Async'));
|
||||
} catch (e) {
|
||||
Scheduler.unstable_yieldValue('Suspend! [Async]');
|
||||
Scheduler.log('Suspend! [Async]');
|
||||
throw e;
|
||||
}
|
||||
throw new Error('Oops!');
|
||||
@@ -730,7 +730,7 @@ describe('ReactThenable', () => {
|
||||
const [childShouldSuspend, _setChildShouldSuspend] = useState(false);
|
||||
setChildShouldSuspend = _setChildShouldSuspend;
|
||||
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`childShouldSuspend: ${childShouldSuspend}, showChild: ${showChild}`,
|
||||
);
|
||||
return showChild ? (
|
||||
@@ -795,7 +795,7 @@ describe('ReactThenable', () => {
|
||||
// This computes the uppercased version of some text. Pretend it's an
|
||||
// expensive operation that we want to reuse.
|
||||
const uppercaseText = useMemo(() => {
|
||||
Scheduler.unstable_yieldValue('Compute uppercase: ' + text);
|
||||
Scheduler.log('Compute uppercase: ' + text);
|
||||
return text.toUpperCase();
|
||||
}, [text]);
|
||||
|
||||
@@ -807,7 +807,7 @@ describe('ReactThenable', () => {
|
||||
// is to show that you can suspend in the middle of a sequence of hooks
|
||||
// without breaking anything.
|
||||
const sparklingText = useMemo(() => {
|
||||
Scheduler.unstable_yieldValue('Add sparkles: ' + exclamatoryText);
|
||||
Scheduler.log('Add sparkles: ' + exclamatoryText);
|
||||
return `✨ ${exclamatoryText} ✨`;
|
||||
}, [exclamatoryText]);
|
||||
|
||||
|
||||
@@ -108,16 +108,16 @@ describe('ReactTransition', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error! [${text}]`);
|
||||
Scheduler.log(`Error! [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return textCache.version;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
|
||||
Scheduler.log(`Suspend! [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -141,13 +141,13 @@ describe('ReactTransition', () => {
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
function AsyncText({text}) {
|
||||
readText(text);
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -622,9 +622,7 @@ describe('ReactTransition', () => {
|
||||
function Parent({children}) {
|
||||
const [shouldHideInParent, _setShouldHideInParent] = useState(false);
|
||||
setShouldHideInParent = _setShouldHideInParent;
|
||||
Scheduler.unstable_yieldValue(
|
||||
'shouldHideInParent: ' + shouldHideInParent,
|
||||
);
|
||||
Scheduler.log('shouldHideInParent: ' + shouldHideInParent);
|
||||
if (shouldHideInParent) {
|
||||
return <Text text="(empty)" />;
|
||||
}
|
||||
@@ -782,7 +780,7 @@ describe('ReactTransition', () => {
|
||||
updateNormalPri = () => setNormalPri(n => n + 1);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -834,7 +832,7 @@ describe('ReactTransition', () => {
|
||||
updateNormalPri = () => setNormalPri(n => n + 1);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -897,7 +895,7 @@ describe('ReactTransition', () => {
|
||||
updateNormalPri = () => setNormalPri(n => n + 1);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit');
|
||||
Scheduler.log('Commit');
|
||||
});
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -112,16 +112,16 @@ describe('ReactInteractionTracing', () => {
|
||||
if (record !== undefined) {
|
||||
switch (record.status) {
|
||||
case 'pending':
|
||||
Scheduler.unstable_yieldValue(`Suspend [${text}]`);
|
||||
Scheduler.log(`Suspend [${text}]`);
|
||||
throw record.value;
|
||||
case 'rejected':
|
||||
Scheduler.unstable_yieldValue(`Error [${text}]`);
|
||||
Scheduler.log(`Error [${text}]`);
|
||||
throw record.value;
|
||||
case 'resolved':
|
||||
return record.value;
|
||||
}
|
||||
} else {
|
||||
Scheduler.unstable_yieldValue(`Suspend [${text}]`);
|
||||
Scheduler.log(`Suspend [${text}]`);
|
||||
|
||||
const thenable = {
|
||||
pings: [],
|
||||
@@ -146,12 +146,12 @@ describe('ReactInteractionTracing', () => {
|
||||
|
||||
function AsyncText({text}) {
|
||||
const fullText = readText(text);
|
||||
Scheduler.unstable_yieldValue(fullText);
|
||||
Scheduler.log(fullText);
|
||||
return fullText;
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -183,18 +183,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it(' should not call callbacks when transition is not defined', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -206,12 +204,12 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -266,18 +264,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace basic interaction', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -326,12 +322,10 @@ describe('ReactInteractionTracing', () => {
|
||||
it('multiple updates in transition callback should only result in one transitionStart/transitionComplete call', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -391,18 +385,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace interactions for async roots', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -469,18 +461,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace multiple separate root interactions', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -578,18 +568,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace multiple intertwined root interactions', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -695,18 +683,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('trace interaction with nested and sibling suspense boundaries', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -813,18 +799,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('trace interactions with the same child suspense boundaries', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -979,18 +963,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace basic interaction with tracing markers', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1002,12 +984,12 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1065,12 +1047,10 @@ describe('ReactInteractionTracing', () => {
|
||||
it('should correctly trace interactions for tracing markers', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1082,12 +1062,12 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1176,12 +1156,10 @@ describe('ReactInteractionTracing', () => {
|
||||
it('trace interaction with multiple tracing markers', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1193,12 +1171,12 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1304,18 +1282,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it.skip('warn and calls marker incomplete if name changes before transition completes', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1327,7 +1303,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -1337,14 +1313,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1420,18 +1396,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('marker incomplete for tree with parent and sibling tracing markers', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1443,7 +1417,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -1453,14 +1427,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1576,18 +1550,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('marker gets deleted', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1599,7 +1571,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -1609,14 +1581,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1711,18 +1683,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('Suspense boundary added by the transition is deleted', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1734,7 +1704,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -1744,14 +1714,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1869,18 +1839,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('Suspense boundary not added by the transition is deleted ', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1892,7 +1860,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -1902,14 +1870,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -1979,18 +1947,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('marker incomplete gets called properly if child suspense marker is not part of it', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2002,7 +1968,7 @@ describe('ReactInteractionTracing', () => {
|
||||
pending,
|
||||
) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
@@ -2012,14 +1978,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2118,12 +2084,10 @@ describe('ReactInteractionTracing', () => {
|
||||
it('warns when marker name changes', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2133,14 +2097,14 @@ describe('ReactInteractionTracing', () => {
|
||||
startTime,
|
||||
deletions,
|
||||
) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
|
||||
deletions,
|
||||
)}])`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2212,17 +2176,15 @@ describe('ReactInteractionTracing', () => {
|
||||
it('offscreen trees should not stop transition from completing', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2282,18 +2244,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('discrete events', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2344,18 +2304,16 @@ describe('ReactInteractionTracing', () => {
|
||||
it('multiple commits happen before a paint', async () => {
|
||||
const transitionCallbacks = {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
`onTransitionStart(${name}, ${startTime})`,
|
||||
);
|
||||
Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
|
||||
);
|
||||
},
|
||||
@@ -2420,18 +2378,18 @@ describe('ReactInteractionTracing', () => {
|
||||
const getTransitionCallbacks = transitionName => {
|
||||
return {
|
||||
onTransitionStart: (name, startTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionStart(${name}, ${startTime}) /${transitionName}/`,
|
||||
);
|
||||
},
|
||||
onTransitionProgress: (name, startTime, endTime, pending) => {
|
||||
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}]) /${transitionName}/`,
|
||||
);
|
||||
},
|
||||
onTransitionComplete: (name, startTime, endTime) => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`onTransitionComplete(${name}, ${startTime}, ${endTime}) /${transitionName}/`,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('ReactUpdatePriority', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('ReactUpdatePriority', () => {
|
||||
const [defaultState, _setDefaultState] = useState(1);
|
||||
setDefaultState = _setDefaultState;
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Idle update');
|
||||
Scheduler.log('Idle update');
|
||||
setIdleState(2);
|
||||
}, []);
|
||||
return <Text text={`Idle: ${idleState}, Default: ${defaultState}`} />;
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('updaters', () => {
|
||||
isDevToolsPresent: true,
|
||||
onCommitRoot: jest.fn(fiberRoot => {
|
||||
if (onCommitRootShouldYield) {
|
||||
Scheduler.unstable_yieldValue('onCommitRoot');
|
||||
Scheduler.log('onCommitRoot');
|
||||
}
|
||||
const schedulerTags = [];
|
||||
const schedulerTypes = [];
|
||||
@@ -199,7 +199,7 @@ describe('updaters', () => {
|
||||
};
|
||||
const CascadingChild = ({cascade}) => {
|
||||
const [count, setCount] = React.useState(0);
|
||||
Scheduler.unstable_yieldValue(`CascadingChild ${count}`);
|
||||
Scheduler.log(`CascadingChild ${count}`);
|
||||
React.useLayoutEffect(() => {
|
||||
if (cascade === 'active') {
|
||||
setCount(prevCount => prevCount + 1);
|
||||
@@ -348,7 +348,7 @@ describe('updaters', () => {
|
||||
}
|
||||
}
|
||||
const Yield = ({value}) => {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
};
|
||||
const BrokenRender = () => {
|
||||
@@ -387,7 +387,7 @@ describe('updaters', () => {
|
||||
const SyncPriorityUpdater = () => {
|
||||
const [count, setCount] = React.useState(0);
|
||||
triggerSyncPriorityUpdate = () => setCount(prevCount => prevCount + 1);
|
||||
Scheduler.unstable_yieldValue(`SyncPriorityUpdater ${count}`);
|
||||
Scheduler.log(`SyncPriorityUpdater ${count}`);
|
||||
return <Yield value={`HighPriority ${count}`} />;
|
||||
};
|
||||
const LowPriorityUpdater = () => {
|
||||
@@ -397,11 +397,11 @@ describe('updaters', () => {
|
||||
setCount(prevCount => prevCount + 1);
|
||||
});
|
||||
};
|
||||
Scheduler.unstable_yieldValue(`LowPriorityUpdater ${count}`);
|
||||
Scheduler.log(`LowPriorityUpdater ${count}`);
|
||||
return <Yield value={`LowPriority ${count}`} />;
|
||||
};
|
||||
const Yield = ({value}) => {
|
||||
Scheduler.unstable_yieldValue(`Yield ${value}`);
|
||||
Scheduler.log(`Yield ${value}`);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ describe('StrictEffectsMode', () => {
|
||||
it('should not double invoke effects in legacy mode', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -61,13 +61,13 @@ describe('StrictEffectsMode', () => {
|
||||
it('double invoking for effects works properly', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -114,13 +114,13 @@ describe('StrictEffectsMode', () => {
|
||||
it('multiple effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect One mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect One unmount');
|
||||
Scheduler.log('useEffect One mount');
|
||||
return () => Scheduler.log('useEffect One unmount');
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect Two mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect Two unmount');
|
||||
Scheduler.log('useEffect Two mount');
|
||||
return () => Scheduler.log('useEffect Two unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -167,15 +167,13 @@ describe('StrictEffectsMode', () => {
|
||||
it('multiple layout effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
|
||||
function App({text}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect One mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect One unmount');
|
||||
Scheduler.log('useLayoutEffect One mount');
|
||||
return () => Scheduler.log('useLayoutEffect One unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect Two mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect Two unmount');
|
||||
Scheduler.log('useLayoutEffect Two mount');
|
||||
return () => Scheduler.log('useLayoutEffect Two unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -222,11 +220,11 @@ describe('StrictEffectsMode', () => {
|
||||
it('useEffect and useLayoutEffect is called twice when there is no unmount', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
Scheduler.log('useEffect mount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -269,17 +267,17 @@ describe('StrictEffectsMode', () => {
|
||||
|
||||
componentDidMount() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -305,15 +303,15 @@ describe('StrictEffectsMode', () => {
|
||||
it('double invoking works for class components', () => {
|
||||
class App extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -354,15 +352,15 @@ describe('StrictEffectsMode', () => {
|
||||
it('should not double invoke class lifecycles in legacy mode', () => {
|
||||
class App extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -384,16 +382,16 @@ describe('StrictEffectsMode', () => {
|
||||
if (state !== 1) {
|
||||
setState(1);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -436,13 +434,12 @@ describe('StrictEffectsMode', () => {
|
||||
let _setShowChild;
|
||||
function Child() {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Child useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('Child useEffect unmount');
|
||||
Scheduler.log('Child useEffect mount');
|
||||
return () => Scheduler.log('Child useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Child useLayoutEffect mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('Child useLayoutEffect unmount');
|
||||
Scheduler.log('Child useLayoutEffect mount');
|
||||
return () => Scheduler.log('Child useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return null;
|
||||
@@ -452,13 +449,12 @@ describe('StrictEffectsMode', () => {
|
||||
const [showChild, setShowChild] = React.useState(false);
|
||||
_setShowChild = setShowChild;
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('App useEffect unmount');
|
||||
Scheduler.log('App useEffect mount');
|
||||
return () => Scheduler.log('App useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App useLayoutEffect mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('App useLayoutEffect unmount');
|
||||
Scheduler.log('App useLayoutEffect mount');
|
||||
return () => Scheduler.log('App useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return showChild && <Child />;
|
||||
@@ -513,11 +509,11 @@ describe('StrictEffectsMode', () => {
|
||||
it('classes and functions are double invoked together correctly', () => {
|
||||
class ClassChild extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -527,12 +523,12 @@ describe('StrictEffectsMode', () => {
|
||||
|
||||
function FunctionChild({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
+52
-59
@@ -40,13 +40,13 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('should not double invoke effects in legacy mode', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -62,15 +62,15 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('should not double invoke class lifecycles in legacy mode', () => {
|
||||
class App extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -89,9 +89,8 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('should flush double-invoked effects within the same frame as layout effects if there are no passive effects', async () => {
|
||||
function ComponentWithEffects({label}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`useLayoutEffect mount "${label}"`);
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue(`useLayoutEffect unmount "${label}"`);
|
||||
Scheduler.log(`useLayoutEffect mount "${label}"`);
|
||||
return () => Scheduler.log(`useLayoutEffect unmount "${label}"`);
|
||||
});
|
||||
|
||||
return label;
|
||||
@@ -138,15 +137,13 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('should double invoke effects only for newly mounted components', async () => {
|
||||
function ComponentWithEffects({label}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`useEffect mount "${label}"`);
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue(`useEffect unmount "${label}"`);
|
||||
Scheduler.log(`useEffect mount "${label}"`);
|
||||
return () => Scheduler.log(`useEffect unmount "${label}"`);
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue(`useLayoutEffect mount "${label}"`);
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue(`useLayoutEffect unmount "${label}"`);
|
||||
Scheduler.log(`useLayoutEffect mount "${label}"`);
|
||||
return () => Scheduler.log(`useLayoutEffect unmount "${label}"`);
|
||||
});
|
||||
|
||||
return label;
|
||||
@@ -200,13 +197,13 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('double invoking for effects for modern roots', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -245,13 +242,13 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('multiple effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect One mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect One unmount');
|
||||
Scheduler.log('useEffect One mount');
|
||||
return () => Scheduler.log('useEffect One unmount');
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect Two mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect Two unmount');
|
||||
Scheduler.log('useEffect Two mount');
|
||||
return () => Scheduler.log('useEffect Two unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -291,15 +288,13 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('multiple layout effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
|
||||
function App({text}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect One mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect One unmount');
|
||||
Scheduler.log('useLayoutEffect One mount');
|
||||
return () => Scheduler.log('useLayoutEffect One unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect Two mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect Two unmount');
|
||||
Scheduler.log('useLayoutEffect Two mount');
|
||||
return () => Scheduler.log('useLayoutEffect Two unmount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -339,11 +334,11 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('useEffect and useLayoutEffect is called twice when there is no unmount', () => {
|
||||
function App({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
Scheduler.log('useEffect mount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
});
|
||||
|
||||
return text;
|
||||
@@ -403,17 +398,17 @@ describe('StrictEffectsMode defaults', () => {
|
||||
|
||||
componentDidMount() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.test();
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -435,15 +430,15 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('double invoking works for class components', () => {
|
||||
class App extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
Scheduler.unstable_yieldValue('componentDidUpdate');
|
||||
Scheduler.log('componentDidUpdate');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -481,16 +476,16 @@ describe('StrictEffectsMode defaults', () => {
|
||||
if (state !== 1) {
|
||||
setState(1);
|
||||
}
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -518,13 +513,12 @@ describe('StrictEffectsMode defaults', () => {
|
||||
let _setShowChild;
|
||||
function Child() {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Child useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('Child useEffect unmount');
|
||||
Scheduler.log('Child useEffect mount');
|
||||
return () => Scheduler.log('Child useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Child useLayoutEffect mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('Child useLayoutEffect unmount');
|
||||
Scheduler.log('Child useLayoutEffect mount');
|
||||
return () => Scheduler.log('Child useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return null;
|
||||
@@ -534,13 +528,12 @@ describe('StrictEffectsMode defaults', () => {
|
||||
const [showChild, setShowChild] = React.useState(false);
|
||||
_setShowChild = setShowChild;
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('App useEffect unmount');
|
||||
Scheduler.log('App useEffect mount');
|
||||
return () => Scheduler.log('App useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App useLayoutEffect mount');
|
||||
return () =>
|
||||
Scheduler.unstable_yieldValue('App useLayoutEffect unmount');
|
||||
Scheduler.log('App useLayoutEffect mount');
|
||||
return () => Scheduler.log('App useLayoutEffect unmount');
|
||||
});
|
||||
|
||||
return showChild && <Child />;
|
||||
@@ -580,11 +573,11 @@ describe('StrictEffectsMode defaults', () => {
|
||||
it('classes and functions are double invoked together correctly', () => {
|
||||
class ClassChild extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
Scheduler.unstable_yieldValue('componentDidMount');
|
||||
Scheduler.log('componentDidMount');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
Scheduler.unstable_yieldValue('componentWillUnmount');
|
||||
Scheduler.log('componentWillUnmount');
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -594,12 +587,12 @@ describe('StrictEffectsMode defaults', () => {
|
||||
|
||||
function FunctionChild({text}) {
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useEffect unmount');
|
||||
Scheduler.log('useEffect mount');
|
||||
return () => Scheduler.log('useEffect unmount');
|
||||
});
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('useLayoutEffect mount');
|
||||
return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
|
||||
Scheduler.log('useLayoutEffect mount');
|
||||
return () => Scheduler.log('useLayoutEffect unmount');
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
+10
-10
@@ -51,7 +51,7 @@ describe('useEffectEvent', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span prop={props.text} />;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('useEffectEvent', () => {
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
|
||||
Scheduler.log('Effect: by ' + incrementBy * 2);
|
||||
increment(incrementBy * 2);
|
||||
}, [incrementBy]);
|
||||
|
||||
@@ -398,7 +398,7 @@ describe('useEffectEvent', () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
|
||||
Scheduler.log('Effect: by ' + incrementBy * 2);
|
||||
increment(incrementBy * 2);
|
||||
}, [incrementBy]);
|
||||
|
||||
@@ -503,7 +503,7 @@ describe('useEffectEvent', () => {
|
||||
const [count, increment] = useCount(incrementBy);
|
||||
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
|
||||
Scheduler.log('Effect: by ' + incrementBy * 2);
|
||||
increment(incrementBy * 2);
|
||||
}, [incrementBy]);
|
||||
|
||||
@@ -588,14 +588,14 @@ describe('useEffectEvent', () => {
|
||||
it('is mutated before all other effects', async () => {
|
||||
function Counter({value}) {
|
||||
useInsertionEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect value: ' + value);
|
||||
Scheduler.log('Effect value: ' + value);
|
||||
increment();
|
||||
}, [value]);
|
||||
|
||||
// This is defined after the insertion effect, but it should
|
||||
// update the event fn _before_ the insertion effect fires.
|
||||
const increment = useEffectEvent(() => {
|
||||
Scheduler.unstable_yieldValue('Event value: ' + value);
|
||||
Scheduler.log('Event value: ' + value);
|
||||
});
|
||||
|
||||
return <></>;
|
||||
@@ -612,7 +612,7 @@ describe('useEffectEvent', () => {
|
||||
it("doesn't provide a stable identity", async () => {
|
||||
function Counter({shouldRender, value}) {
|
||||
const onClick = useEffectEvent(() => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'onClick, shouldRender=' + shouldRender + ', value=' + value,
|
||||
);
|
||||
});
|
||||
@@ -662,7 +662,7 @@ describe('useEffectEvent', () => {
|
||||
() => {
|
||||
// Log when the effect fires. In the test below, we'll assert that this
|
||||
// only happens during initial render, not during updates.
|
||||
Scheduler.unstable_yieldValue('Commit new event handler');
|
||||
Scheduler.log('Commit new event handler');
|
||||
committedEventHandler = event;
|
||||
return () => {
|
||||
committedEventHandler = null;
|
||||
@@ -727,7 +727,7 @@ describe('useEffectEvent', () => {
|
||||
|
||||
function ChatRoom({roomId, theme}) {
|
||||
const onConnected = useEffectEvent(() => {
|
||||
Scheduler.unstable_yieldValue('Connected! theme: ' + theme);
|
||||
Scheduler.log('Connected! theme: ' + theme);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -815,7 +815,7 @@ describe('useEffectEvent', () => {
|
||||
const numberOfItems = items.length;
|
||||
|
||||
const onVisit = useEffectEvent(visitedUrl => {
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
'url: ' + visitedUrl + ', numberOfItems: ' + numberOfItems,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ describe('useMutableSource', () => {
|
||||
|
||||
function Component({getSnapshot, label, mutableSource, subscribe}) {
|
||||
const snapshot = useMutableSource(mutableSource, getSnapshot, subscribe);
|
||||
Scheduler.unstable_yieldValue(`${label}:${snapshot}`);
|
||||
Scheduler.log(`${label}:${snapshot}`);
|
||||
return <div>{`${label}:${snapshot}`}</div>;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ describe('useMutableSource', () => {
|
||||
/>
|
||||
</>,
|
||||
'root',
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitFor(['a:one', 'b:one', 'Sync effect']);
|
||||
|
||||
@@ -197,7 +197,7 @@ describe('useMutableSource', () => {
|
||||
/>
|
||||
</>,
|
||||
'root',
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:two', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -237,7 +237,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
// Do enough work to read from one component
|
||||
@@ -272,7 +272,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
|
||||
// Finish rendering
|
||||
@@ -309,7 +309,7 @@ describe('useMutableSource', () => {
|
||||
mutableSource={mutableSourceA}
|
||||
subscribe={defaultSubscribe}
|
||||
/>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:a-one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -327,7 +327,7 @@ describe('useMutableSource', () => {
|
||||
mutableSource={mutableSourceB}
|
||||
subscribe={defaultSubscribe}
|
||||
/>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:b-one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -375,7 +375,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={subscribeA}
|
||||
/>,
|
||||
'root',
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:a-one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -392,7 +392,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={subscribeB}
|
||||
/>,
|
||||
'root',
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:a-one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -430,7 +430,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'b:one', 'Sync effect']);
|
||||
|
||||
@@ -459,7 +459,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
assertLog(['a:one', 'b:one', 'Sync effect']);
|
||||
@@ -483,7 +483,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'Sync effect']);
|
||||
|
||||
@@ -502,7 +502,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'b:one', 'Sync effect']);
|
||||
});
|
||||
@@ -529,7 +529,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'b:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -562,7 +562,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
assertLog(['a:new:two', 'b:new:two', 'Sync effect']);
|
||||
@@ -590,7 +590,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'b:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -623,7 +623,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={defaultSubscribe}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
assertLog(['a:new:two', 'b:new:two', 'Sync effect']);
|
||||
@@ -657,7 +657,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={subscribeB}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:a:one', 'b:b:one', 'Sync effect']);
|
||||
|
||||
@@ -690,7 +690,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={subscribeA}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:a:one', 'Sync effect']);
|
||||
|
||||
@@ -718,7 +718,7 @@ describe('useMutableSource', () => {
|
||||
subscribe={subscribeB}
|
||||
/>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
await waitFor(['a:a:one', 'b:b:one']);
|
||||
@@ -746,7 +746,7 @@ describe('useMutableSource', () => {
|
||||
mutableSource={mutableSource}
|
||||
subscribe={defaultSubscribe}
|
||||
/>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitFor(['only:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -782,7 +782,7 @@ describe('useMutableSource', () => {
|
||||
|
||||
await act(async () => {
|
||||
ReactNoop.render(<WrapperWithState />, () =>
|
||||
Scheduler.unstable_yieldValue('Sync effect'),
|
||||
Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -873,7 +873,7 @@ describe('useMutableSource', () => {
|
||||
<WrapperWithState />
|
||||
</React.Profiler>
|
||||
</>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['a:one', 'b:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -914,7 +914,7 @@ describe('useMutableSource', () => {
|
||||
|
||||
await act(async () => {
|
||||
ReactNoop.render(<WrapperWithState />, () =>
|
||||
Scheduler.unstable_yieldValue('Sync effect'),
|
||||
Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -973,14 +973,12 @@ describe('useMutableSource', () => {
|
||||
getSnapshot,
|
||||
defaultSubscribe,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(`${id}:${name}`);
|
||||
Scheduler.log(`${id}:${name}`);
|
||||
return <li>{name}</li>;
|
||||
}
|
||||
|
||||
await act(async () => {
|
||||
ReactNoop.render(<FriendsList />, () =>
|
||||
Scheduler.unstable_yieldValue('Sync effect'),
|
||||
);
|
||||
ReactNoop.render(<FriendsList />, () => Scheduler.log('Sync effect'));
|
||||
await waitForAll(['1:Foo', '2:Bar', 'Sync effect']);
|
||||
|
||||
// This mutation will cause the "Bar" component to throw,
|
||||
@@ -1004,7 +1002,7 @@ describe('useMutableSource', () => {
|
||||
|
||||
function Wrapper() {
|
||||
React.useLayoutEffect(() => () => {
|
||||
Scheduler.unstable_yieldValue('layout unmount');
|
||||
Scheduler.log('layout unmount');
|
||||
});
|
||||
return (
|
||||
<Component
|
||||
@@ -1018,7 +1016,7 @@ describe('useMutableSource', () => {
|
||||
|
||||
await act(async () => {
|
||||
ReactNoop.renderToRootWithID(<Wrapper />, 'root', () =>
|
||||
Scheduler.unstable_yieldValue('Sync effect'),
|
||||
Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitForAll(['only:one', 'Sync effect']);
|
||||
ReactNoop.flushPassiveEffects();
|
||||
@@ -1222,7 +1220,7 @@ describe('useMutableSource', () => {
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue(result);
|
||||
Scheduler.log(result);
|
||||
}, [result]);
|
||||
|
||||
return result;
|
||||
@@ -1296,9 +1294,9 @@ describe('useMutableSource', () => {
|
||||
defaultSubscribe,
|
||||
);
|
||||
|
||||
Scheduler.unstable_yieldValue('Render: ' + value);
|
||||
Scheduler.log('Render: ' + value);
|
||||
React.useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit: ' + value);
|
||||
Scheduler.log('Commit: ' + value);
|
||||
}, [value]);
|
||||
|
||||
return value;
|
||||
@@ -1436,12 +1434,12 @@ describe('useMutableSource', () => {
|
||||
getSnapshot,
|
||||
defaultSubscribe,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1513,7 +1511,7 @@ describe('useMutableSource', () => {
|
||||
function Read() {
|
||||
const fn = useMutableSource(mutableSource, getSnapshot, defaultSubscribe);
|
||||
const value = fn();
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1553,7 +1551,7 @@ describe('useMutableSource', () => {
|
||||
subscribe,
|
||||
);
|
||||
|
||||
Scheduler.unstable_yieldValue('Parent: ' + parentValue);
|
||||
Scheduler.log('Parent: ' + parentValue);
|
||||
|
||||
return (
|
||||
<Child
|
||||
@@ -1572,7 +1570,7 @@ describe('useMutableSource', () => {
|
||||
subscribe,
|
||||
);
|
||||
|
||||
Scheduler.unstable_yieldValue('Child: ' + childValue);
|
||||
Scheduler.log('Child: ' + childValue);
|
||||
|
||||
let result = `${parentValue}, ${childValue}`;
|
||||
|
||||
@@ -1585,7 +1583,7 @@ describe('useMutableSource', () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Commit: ' + result);
|
||||
Scheduler.log('Commit: ' + result);
|
||||
}, [result]);
|
||||
|
||||
return result;
|
||||
@@ -1648,7 +1646,7 @@ describe('useMutableSource', () => {
|
||||
defaultGetSnapshot,
|
||||
defaultSubscribe,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(`a:${snapshot}`);
|
||||
Scheduler.log(`a:${snapshot}`);
|
||||
React.useEffect(() => {
|
||||
committedA = snapshot;
|
||||
}, [snapshot]);
|
||||
@@ -1660,7 +1658,7 @@ describe('useMutableSource', () => {
|
||||
defaultGetSnapshot,
|
||||
defaultSubscribe,
|
||||
);
|
||||
Scheduler.unstable_yieldValue(`b:${snapshot}`);
|
||||
Scheduler.log(`b:${snapshot}`);
|
||||
React.useEffect(() => {
|
||||
committedB = snapshot;
|
||||
}, [snapshot]);
|
||||
@@ -1673,7 +1671,7 @@ describe('useMutableSource', () => {
|
||||
<React.Profiler id="root" onRender={onRender}>
|
||||
<ComponentA />
|
||||
</React.Profiler>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
});
|
||||
assertLog(['a:one', 'Sync effect']);
|
||||
@@ -1686,7 +1684,7 @@ describe('useMutableSource', () => {
|
||||
<ComponentA />
|
||||
<ComponentB />
|
||||
</React.Profiler>,
|
||||
() => Scheduler.unstable_yieldValue('Sync effect'),
|
||||
() => Scheduler.log('Sync effect'),
|
||||
);
|
||||
await waitFor(['a:one', 'b:one', 'Sync effect']);
|
||||
expect(source.listenerCount).toBe(1);
|
||||
|
||||
@@ -137,7 +137,7 @@ describe('useMutableSourceHydration', () => {
|
||||
|
||||
function Component({getSnapshot, label, mutableSource, subscribe}) {
|
||||
const snapshot = useMutableSource(mutableSource, getSnapshot, subscribe);
|
||||
Scheduler.unstable_yieldValue(`${label}:${snapshot}`);
|
||||
Scheduler.log(`${label}:${snapshot}`);
|
||||
return <div>{`${label}:${snapshot}`}</div>;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ describe('useMutableSourceHydration', () => {
|
||||
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
|
||||
mutableSources: [mutableSource],
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('Log error: ' + error.message);
|
||||
Scheduler.log('Log error: ' + error.message);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -264,7 +264,7 @@ describe('useMutableSourceHydration', () => {
|
||||
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
|
||||
mutableSources: [mutableSource],
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('Log error: ' + error.message);
|
||||
Scheduler.log('Log error: ' + error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -348,7 +348,7 @@ describe('useMutableSourceHydration', () => {
|
||||
ReactDOMClient.hydrateRoot(container, fragment, {
|
||||
mutableSources: [mutableSource],
|
||||
onRecoverableError(error) {
|
||||
Scheduler.unstable_yieldValue('Log error: ' + error.message);
|
||||
Scheduler.log('Log error: ' + error.message);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('useRef', () => {
|
||||
});
|
||||
|
||||
function Text(props) {
|
||||
Scheduler.unstable_yieldValue(props.text);
|
||||
Scheduler.log(props.text);
|
||||
return <span prop={props.text} />;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ describe('useRef', () => {
|
||||
function App() {
|
||||
ping = useDebouncedCallback(
|
||||
value => {
|
||||
Scheduler.unstable_yieldValue('ping: ' + value);
|
||||
Scheduler.log('ping: ' + value);
|
||||
},
|
||||
100,
|
||||
[],
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('useSyncExternalStore', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('useSyncExternalStore', () => {
|
||||
const aText = refA.current;
|
||||
const bText = refB.current;
|
||||
const cText = refC.current;
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Children observed during layout: A${aText}B${bText}C${cText}`,
|
||||
);
|
||||
});
|
||||
|
||||
+4
-4
@@ -2423,7 +2423,7 @@ describe('ReactFresh', () => {
|
||||
const AppV1 = prepare(() => {
|
||||
function Hello() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Hello#layout');
|
||||
Scheduler.log('Hello#layout');
|
||||
});
|
||||
const [val, setVal] = React.useState(0);
|
||||
return (
|
||||
@@ -2436,7 +2436,7 @@ describe('ReactFresh', () => {
|
||||
|
||||
return function App({offscreen}) {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('App#layout');
|
||||
Scheduler.log('App#layout');
|
||||
});
|
||||
return (
|
||||
<LegacyHiddenDiv mode={offscreen ? 'hidden' : 'visible'}>
|
||||
@@ -2457,7 +2457,7 @@ describe('ReactFresh', () => {
|
||||
patch(() => {
|
||||
function Hello() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Hello#layout');
|
||||
Scheduler.log('Hello#layout');
|
||||
});
|
||||
const [val, setVal] = React.useState(0);
|
||||
return (
|
||||
@@ -2496,7 +2496,7 @@ describe('ReactFresh', () => {
|
||||
patch(() => {
|
||||
function Hello() {
|
||||
React.useLayoutEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Hello#layout');
|
||||
Scheduler.log('Hello#layout');
|
||||
});
|
||||
const [val, setVal] = React.useState(0);
|
||||
return (
|
||||
|
||||
@@ -83,9 +83,9 @@ describe('ReactTestRenderer.act()', () => {
|
||||
// This component will keep updating itself until step === 3
|
||||
const [step, proceed] = useReducer(s => (s === 3 ? 3 : s + 1), 1);
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Effect');
|
||||
Scheduler.log('Effect');
|
||||
alreadyResolvedPromise.then(() => {
|
||||
Scheduler.unstable_yieldValue('Microtask');
|
||||
Scheduler.log('Microtask');
|
||||
proceed();
|
||||
});
|
||||
});
|
||||
|
||||
+3
-133
@@ -15,7 +15,6 @@ let ReactTestRenderer;
|
||||
let Scheduler;
|
||||
let waitForAll;
|
||||
let waitFor;
|
||||
let assertLog;
|
||||
|
||||
describe('ReactTestRendererAsync', () => {
|
||||
beforeEach(() => {
|
||||
@@ -28,7 +27,6 @@ describe('ReactTestRendererAsync', () => {
|
||||
const InternalTestUtils = require('internal-test-utils');
|
||||
waitForAll = InternalTestUtils.waitForAll;
|
||||
waitFor = InternalTestUtils.waitFor;
|
||||
assertLog = InternalTestUtils.assertLog;
|
||||
});
|
||||
|
||||
it('flushAll flushes all work', async () => {
|
||||
@@ -57,7 +55,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
|
||||
it('flushAll returns array of yielded values', async () => {
|
||||
function Child(props) {
|
||||
Scheduler.unstable_yieldValue(props.children);
|
||||
Scheduler.log(props.children);
|
||||
return props.children;
|
||||
}
|
||||
function Parent(props) {
|
||||
@@ -83,7 +81,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
|
||||
it('flushThrough flushes until the expected values is yielded', async () => {
|
||||
function Child(props) {
|
||||
Scheduler.unstable_yieldValue(props.children);
|
||||
Scheduler.log(props.children);
|
||||
return props.children;
|
||||
}
|
||||
function Parent(props) {
|
||||
@@ -115,7 +113,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
|
||||
it('supports high priority interruptions', async () => {
|
||||
function Child(props) {
|
||||
Scheduler.unstable_yieldValue(props.children);
|
||||
Scheduler.log(props.children);
|
||||
return props.children;
|
||||
}
|
||||
|
||||
@@ -155,132 +153,4 @@ describe('ReactTestRendererAsync', () => {
|
||||
// Only the higher priority properties have been committed
|
||||
expect(renderer.toJSON()).toEqual(['A:2', 'B:2']);
|
||||
});
|
||||
|
||||
describe('Jest matchers', () => {
|
||||
it('toFlushAndYieldThrough', () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.unstable_yieldValue(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
ReactTestRenderer.create(
|
||||
<div>
|
||||
<Yield id="foo" />
|
||||
<Yield id="bar" />
|
||||
<Yield id="baz" />
|
||||
</div>,
|
||||
{
|
||||
unstable_isConcurrent: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
expect(Scheduler).toFlushAndYieldThrough(['foo', 'baz']),
|
||||
).toThrow('// deep equality');
|
||||
});
|
||||
|
||||
it('toFlushAndYield', () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.unstable_yieldValue(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
const renderer = ReactTestRenderer.create(
|
||||
<div>
|
||||
<Yield id="foo" />
|
||||
<Yield id="bar" />
|
||||
<Yield id="baz" />
|
||||
</div>,
|
||||
{
|
||||
unstable_isConcurrent: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrowError(
|
||||
'// deep equality',
|
||||
);
|
||||
|
||||
renderer.update(
|
||||
<div>
|
||||
<Yield id="foo" />
|
||||
<Yield id="bar" />
|
||||
<Yield id="baz" />
|
||||
</div>,
|
||||
);
|
||||
|
||||
expect(() => expect(Scheduler).toFlushAndYield(['foo', 'baz'])).toThrow(
|
||||
'// deep equality',
|
||||
);
|
||||
});
|
||||
|
||||
it('toFlushAndThrow', () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.unstable_yieldValue(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
function BadRender() {
|
||||
throw new Error('Oh no!');
|
||||
}
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<Yield id="A" />
|
||||
<Yield id="B" />
|
||||
<BadRender />
|
||||
<Yield id="C" />
|
||||
<Yield id="D" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const renderer = ReactTestRenderer.create(<App />, {
|
||||
unstable_isConcurrent: true,
|
||||
});
|
||||
|
||||
expect(Scheduler).toFlushAndThrow('Oh no!');
|
||||
assertLog(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);
|
||||
|
||||
renderer.update(<App />);
|
||||
|
||||
expect(Scheduler).toFlushAndThrow('Oh no!');
|
||||
assertLog(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);
|
||||
|
||||
renderer.update(<App />);
|
||||
expect(Scheduler).toFlushAndThrow('Oh no!');
|
||||
});
|
||||
});
|
||||
|
||||
it('toHaveYielded', () => {
|
||||
const Yield = ({id}) => {
|
||||
Scheduler.unstable_yieldValue(id);
|
||||
return id;
|
||||
};
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
<Yield id="A" />
|
||||
<Yield id="B" />
|
||||
<Yield id="C" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
ReactTestRenderer.create(<App />);
|
||||
expect(() => expect(Scheduler).toHaveYielded(['A', 'B'])).toThrow(
|
||||
'// deep equality',
|
||||
);
|
||||
});
|
||||
|
||||
it('flush methods throw if log is not empty', () => {
|
||||
ReactTestRenderer.create(<div />, {
|
||||
unstable_isConcurrent: true,
|
||||
});
|
||||
Scheduler.unstable_yieldValue('Something');
|
||||
expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrow(
|
||||
'Log of yielded values is not empty.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,7 +202,7 @@ describe(`onRender`, () => {
|
||||
const callback = jest.fn();
|
||||
|
||||
const Yield = ({value}) => {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -233,7 +233,7 @@ describe(`onRender`, () => {
|
||||
return {
|
||||
...ActualScheduler,
|
||||
unstable_now: function mockUnstableNow() {
|
||||
ActualScheduler.unstable_yieldValue('read current time');
|
||||
ActualScheduler.log('read current time');
|
||||
return ActualScheduler.unstable_now();
|
||||
},
|
||||
};
|
||||
@@ -244,7 +244,7 @@ describe(`onRender`, () => {
|
||||
loadModules();
|
||||
|
||||
// Clear yields in case the current time is read during initialization.
|
||||
Scheduler.unstable_clearYields();
|
||||
Scheduler.unstable_clearLog();
|
||||
|
||||
ReactTestRenderer.create(
|
||||
<div>
|
||||
@@ -665,7 +665,7 @@ describe(`onRender`, () => {
|
||||
}
|
||||
}, [didMount, didMountAndUpdate]);
|
||||
|
||||
Scheduler.unstable_yieldValue(`${didMount}:${didMountAndUpdate}`);
|
||||
Scheduler.log(`${didMount}:${didMountAndUpdate}`);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -698,7 +698,7 @@ describe(`onRender`, () => {
|
||||
React.useLayoutEffect(() => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(didMount);
|
||||
Scheduler.log(didMount);
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ describe(`onRender`, () => {
|
||||
|
||||
const Yield = ({renderTime}) => {
|
||||
Scheduler.unstable_advanceTime(renderTime);
|
||||
Scheduler.unstable_yieldValue('Yield:' + renderTime);
|
||||
Scheduler.log('Yield:' + renderTime);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -771,7 +771,7 @@ describe(`onRender`, () => {
|
||||
|
||||
const Yield = ({renderTime}) => {
|
||||
Scheduler.unstable_advanceTime(renderTime);
|
||||
Scheduler.unstable_yieldValue('Yield:' + renderTime);
|
||||
Scheduler.log('Yield:' + renderTime);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -823,7 +823,7 @@ describe(`onRender`, () => {
|
||||
|
||||
const Yield = ({renderTime}) => {
|
||||
Scheduler.unstable_advanceTime(renderTime);
|
||||
Scheduler.unstable_yieldValue('Yield:' + renderTime);
|
||||
Scheduler.log('Yield:' + renderTime);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -879,7 +879,7 @@ describe(`onRender`, () => {
|
||||
|
||||
const Yield = ({renderTime}) => {
|
||||
Scheduler.unstable_advanceTime(renderTime);
|
||||
Scheduler.unstable_yieldValue('Yield:' + renderTime);
|
||||
Scheduler.log('Yield:' + renderTime);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -962,7 +962,7 @@ describe(`onRender`, () => {
|
||||
|
||||
const Yield = ({renderTime}) => {
|
||||
Scheduler.unstable_advanceTime(renderTime);
|
||||
Scheduler.unstable_yieldValue('Yield:' + renderTime);
|
||||
Scheduler.log('Yield:' + renderTime);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -972,9 +972,7 @@ describe(`onRender`, () => {
|
||||
render() {
|
||||
first = this;
|
||||
Scheduler.unstable_advanceTime(this.state.renderTime);
|
||||
Scheduler.unstable_yieldValue(
|
||||
'FirstComponent:' + this.state.renderTime,
|
||||
);
|
||||
Scheduler.log('FirstComponent:' + this.state.renderTime);
|
||||
return <Yield renderTime={4} />;
|
||||
}
|
||||
}
|
||||
@@ -984,9 +982,7 @@ describe(`onRender`, () => {
|
||||
render() {
|
||||
second = this;
|
||||
Scheduler.unstable_advanceTime(this.state.renderTime);
|
||||
Scheduler.unstable_yieldValue(
|
||||
'SecondComponent:' + this.state.renderTime,
|
||||
);
|
||||
Scheduler.log('SecondComponent:' + this.state.renderTime);
|
||||
return <Yield renderTime={7} />;
|
||||
}
|
||||
}
|
||||
@@ -2375,7 +2371,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
React.useLayoutEffect(() => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(`Component:${didMount}`);
|
||||
Scheduler.log(`Component:${didMount}`);
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -2404,7 +2400,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
setDidMount(true);
|
||||
});
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(`Component:${didMount}`);
|
||||
Scheduler.log(`Component:${didMount}`);
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -2435,7 +2431,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
React.useLayoutEffect(() => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(`Component:${didMount}`);
|
||||
Scheduler.log(`Component:${didMount}`);
|
||||
return didMount;
|
||||
}
|
||||
const onNestedUpdateScheduledOne = jest.fn();
|
||||
@@ -2476,7 +2472,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
function ComponentRootOne() {
|
||||
const [state, setState] = React.useState(false);
|
||||
setStateRef.current = setState;
|
||||
Scheduler.unstable_yieldValue(`ComponentRootOne:${state}`);
|
||||
Scheduler.log(`ComponentRootOne:${state}`);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -2484,7 +2480,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
React.useLayoutEffect(() => {
|
||||
setStateRef.current(true);
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue('ComponentRootTwo');
|
||||
Scheduler.log('ComponentRootTwo');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2524,7 +2520,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
React.useEffect(() => {
|
||||
setDidMount(true);
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(`Component:${didMount}`);
|
||||
Scheduler.log(`Component:${didMount}`);
|
||||
return didMount;
|
||||
}
|
||||
|
||||
@@ -2550,7 +2546,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
function Component() {
|
||||
const [state, setState] = React.useState(false);
|
||||
updateFnRef.current = () => setState(true);
|
||||
Scheduler.unstable_yieldValue(`Component:${state}`);
|
||||
Scheduler.log(`Component:${state}`);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -2580,7 +2576,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
if (state === false) {
|
||||
setState(true);
|
||||
}
|
||||
Scheduler.unstable_yieldValue(`Component:${state}`);
|
||||
Scheduler.log(`Component:${state}`);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -2611,7 +2607,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
setRefDetached(true);
|
||||
}
|
||||
}, []);
|
||||
Scheduler.unstable_yieldValue(`Component:${refAttached}:${refDetached}`);
|
||||
Scheduler.log(`Component:${refAttached}:${refDetached}`);
|
||||
return mountChild ? <div ref={refSetter} /> : null;
|
||||
}
|
||||
|
||||
@@ -2656,7 +2652,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
}
|
||||
render() {
|
||||
const {value} = this.state;
|
||||
Scheduler.unstable_yieldValue(`Component:${value}`);
|
||||
Scheduler.log(`Component:${value}`);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -2694,7 +2690,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
render() {
|
||||
const {scheduleNestedUpdate} = this.props;
|
||||
const {nestedUpdateSheduled} = this.state;
|
||||
Scheduler.unstable_yieldValue(
|
||||
Scheduler.log(
|
||||
`Component:${scheduleNestedUpdate}:${nestedUpdateSheduled}`,
|
||||
);
|
||||
return nestedUpdateSheduled;
|
||||
@@ -2740,7 +2736,7 @@ describe(`onNestedUpdateScheduled`, () => {
|
||||
render() {
|
||||
const {value} = this.state;
|
||||
updateFnRef.current = () => this.setState({value: true});
|
||||
Scheduler.unstable_yieldValue(`Component:${value}`);
|
||||
Scheduler.log(`Component:${value}`);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ describe('ReactProfiler DevTools integration', () => {
|
||||
|
||||
it('regression test: #17159', async () => {
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('forwardRef', () => {
|
||||
it('should work without a ref to be forwarded', async () => {
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(this.props.value);
|
||||
Scheduler.log(this.props.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ describe('forwardRef', () => {
|
||||
it('should forward a ref for a single child', async () => {
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(this.props.value);
|
||||
Scheduler.log(this.props.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ describe('forwardRef', () => {
|
||||
it('should forward a ref for multiple children', async () => {
|
||||
class Child extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(this.props.value);
|
||||
Scheduler.log(this.props.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ describe('forwardRef', () => {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue(this.props.value);
|
||||
Scheduler.log(this.props.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -142,29 +142,29 @@ describe('forwardRef', () => {
|
||||
class ErrorBoundary extends React.Component {
|
||||
state = {error: null};
|
||||
componentDidCatch(error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary.componentDidCatch');
|
||||
Scheduler.log('ErrorBoundary.componentDidCatch');
|
||||
this.setState({error});
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary.render: catch');
|
||||
Scheduler.log('ErrorBoundary.render: catch');
|
||||
return null;
|
||||
}
|
||||
Scheduler.unstable_yieldValue('ErrorBoundary.render: try');
|
||||
Scheduler.log('ErrorBoundary.render: try');
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
class BadRender extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('BadRender throw');
|
||||
Scheduler.log('BadRender throw');
|
||||
throw new Error('oops!');
|
||||
}
|
||||
}
|
||||
|
||||
function Wrapper(props) {
|
||||
const forwardedRef = props.forwardedRef;
|
||||
Scheduler.unstable_yieldValue('Wrapper');
|
||||
Scheduler.log('Wrapper');
|
||||
return <BadRender {...props} ref={forwardedRef} />;
|
||||
}
|
||||
|
||||
@@ -201,24 +201,24 @@ describe('forwardRef', () => {
|
||||
|
||||
class Inner extends React.Component {
|
||||
render() {
|
||||
Scheduler.unstable_yieldValue('Inner');
|
||||
Scheduler.log('Inner');
|
||||
inst = this;
|
||||
return <div ref={this.props.forwardedRef} />;
|
||||
}
|
||||
}
|
||||
|
||||
function Middle(props) {
|
||||
Scheduler.unstable_yieldValue('Middle');
|
||||
Scheduler.log('Middle');
|
||||
return <Inner {...props} />;
|
||||
}
|
||||
|
||||
const Forward = React.forwardRef((props, ref) => {
|
||||
Scheduler.unstable_yieldValue('Forward');
|
||||
Scheduler.log('Forward');
|
||||
return <Middle {...props} forwardedRef={ref} />;
|
||||
});
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
return <Forward />;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('flushes work incrementally', async () => {
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('B'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('C'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('D'));
|
||||
|
||||
await waitFor(['A', 'B']);
|
||||
await waitFor(['C']);
|
||||
@@ -64,11 +64,11 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('cancels work', async () => {
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'));
|
||||
const callbackHandleB = scheduleCallback(NormalPriority, () =>
|
||||
Scheduler.unstable_yieldValue('B'),
|
||||
Scheduler.log('B'),
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('C'));
|
||||
|
||||
cancelCallback(callbackHandleB);
|
||||
|
||||
@@ -80,18 +80,14 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('executes the highest priority callbacks first', async () => {
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('B'));
|
||||
|
||||
// Yield before B is flushed
|
||||
await waitFor(['A']);
|
||||
|
||||
scheduleCallback(UserBlockingPriority, () =>
|
||||
Scheduler.unstable_yieldValue('C'),
|
||||
);
|
||||
scheduleCallback(UserBlockingPriority, () =>
|
||||
Scheduler.unstable_yieldValue('D'),
|
||||
);
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('C'));
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('D'));
|
||||
|
||||
// C and D should come first, because they are higher priority
|
||||
await waitForAll(['C', 'D', 'B']);
|
||||
@@ -100,15 +96,15 @@ describe('Scheduler', () => {
|
||||
it('expires work', async () => {
|
||||
scheduleCallback(NormalPriority, didTimeout => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue(`A (did timeout: ${didTimeout})`);
|
||||
Scheduler.log(`A (did timeout: ${didTimeout})`);
|
||||
});
|
||||
scheduleCallback(UserBlockingPriority, didTimeout => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue(`B (did timeout: ${didTimeout})`);
|
||||
Scheduler.log(`B (did timeout: ${didTimeout})`);
|
||||
});
|
||||
scheduleCallback(UserBlockingPriority, didTimeout => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue(`C (did timeout: ${didTimeout})`);
|
||||
Scheduler.log(`C (did timeout: ${didTimeout})`);
|
||||
});
|
||||
|
||||
// Advance time, but not by enough to expire any work
|
||||
@@ -118,11 +114,11 @@ describe('Scheduler', () => {
|
||||
// Schedule a few more callbacks
|
||||
scheduleCallback(NormalPriority, didTimeout => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue(`D (did timeout: ${didTimeout})`);
|
||||
Scheduler.log(`D (did timeout: ${didTimeout})`);
|
||||
});
|
||||
scheduleCallback(NormalPriority, didTimeout => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue(`E (did timeout: ${didTimeout})`);
|
||||
Scheduler.log(`E (did timeout: ${didTimeout})`);
|
||||
});
|
||||
|
||||
// Advance by just a bit more to expire the user blocking callbacks
|
||||
@@ -138,7 +134,7 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('has a default expiration of ~5 seconds', () => {
|
||||
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'));
|
||||
|
||||
Scheduler.unstable_advanceTime(4999);
|
||||
assertLog([]);
|
||||
@@ -151,11 +147,11 @@ describe('Scheduler', () => {
|
||||
it('continues working on same task after yielding', async () => {
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
});
|
||||
|
||||
let didYield = false;
|
||||
@@ -168,7 +164,7 @@ describe('Scheduler', () => {
|
||||
while (tasks.length > 0) {
|
||||
const [label, ms] = tasks.shift();
|
||||
Scheduler.unstable_advanceTime(ms);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
if (shouldYield()) {
|
||||
didYield = true;
|
||||
return C;
|
||||
@@ -180,11 +176,11 @@ describe('Scheduler', () => {
|
||||
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('D');
|
||||
Scheduler.log('D');
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('E');
|
||||
Scheduler.log('E');
|
||||
});
|
||||
|
||||
// Flush, then yield while in the middle of C.
|
||||
@@ -207,7 +203,7 @@ describe('Scheduler', () => {
|
||||
while (tasks.length > 0) {
|
||||
const [label, ms] = tasks.shift();
|
||||
Scheduler.unstable_advanceTime(ms);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
if (shouldYield()) {
|
||||
return work;
|
||||
}
|
||||
@@ -237,7 +233,7 @@ describe('Scheduler', () => {
|
||||
while (tasks.length > 0) {
|
||||
const [label, ms] = tasks.shift();
|
||||
Scheduler.unstable_advanceTime(ms);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
if (tasks.length > 0 && shouldYield()) {
|
||||
return work;
|
||||
}
|
||||
@@ -248,7 +244,7 @@ describe('Scheduler', () => {
|
||||
|
||||
scheduleCallback(UserBlockingPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('High pri');
|
||||
Scheduler.log('High pri');
|
||||
});
|
||||
|
||||
await waitForAll(['High pri', 'B', 'C', 'D']);
|
||||
@@ -269,13 +265,13 @@ describe('Scheduler', () => {
|
||||
const task = tasks.shift();
|
||||
const [label, ms] = task;
|
||||
Scheduler.unstable_advanceTime(ms);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
if (label === 'B') {
|
||||
// Schedule high pri work from inside another callback
|
||||
Scheduler.unstable_yieldValue('Schedule high pri');
|
||||
Scheduler.log('Schedule high pri');
|
||||
scheduleCallback(UserBlockingPriority, () => {
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('High pri');
|
||||
Scheduler.log('High pri');
|
||||
});
|
||||
}
|
||||
if (tasks.length > 0) {
|
||||
@@ -301,9 +297,9 @@ describe('Scheduler', () => {
|
||||
|
||||
it('cancelling a continuation', async () => {
|
||||
const task = scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Yield');
|
||||
Scheduler.log('Yield');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation');
|
||||
Scheduler.log('Continuation');
|
||||
};
|
||||
});
|
||||
|
||||
@@ -313,18 +309,10 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('top-level immediate callbacks fire in a subsequent task', () => {
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('A'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('B'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('C'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('D'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('A'));
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('B'));
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('C'));
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('D'));
|
||||
// Immediate callback hasn't fired, yet.
|
||||
assertLog([]);
|
||||
// They all flush immediately within the subsequent task.
|
||||
@@ -333,19 +321,13 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('nested immediate callbacks are added to the queue of immediate callbacks', () => {
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('A'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('A'));
|
||||
scheduleCallback(ImmediatePriority, () => {
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
// This callback should go to the end of the queue
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('C'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('C'));
|
||||
});
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue('D'),
|
||||
);
|
||||
scheduleCallback(ImmediatePriority, () => Scheduler.log('D'));
|
||||
assertLog([]);
|
||||
// C should flush at the end
|
||||
Scheduler.unstable_flushExpired();
|
||||
@@ -360,7 +342,7 @@ describe('Scheduler', () => {
|
||||
it('wrapped callbacks inherit the current priority', () => {
|
||||
const wrappedCallback = runWithPriority(NormalPriority, () =>
|
||||
wrapCallback(() => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -368,7 +350,7 @@ describe('Scheduler', () => {
|
||||
UserBlockingPriority,
|
||||
() =>
|
||||
wrapCallback(() => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -385,11 +367,11 @@ describe('Scheduler', () => {
|
||||
|
||||
runWithPriority(NormalPriority, () => {
|
||||
wrappedCallback = wrapCallback(() => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
});
|
||||
wrappedUserBlockingCallback = runWithPriority(UserBlockingPriority, () =>
|
||||
wrapCallback(() => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -403,14 +385,14 @@ describe('Scheduler', () => {
|
||||
|
||||
it("immediate callbacks fire even if there's an error", () => {
|
||||
scheduleCallback(ImmediatePriority, () => {
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
throw new Error('Oops A');
|
||||
});
|
||||
scheduleCallback(ImmediatePriority, () => {
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
});
|
||||
scheduleCallback(ImmediatePriority, () => {
|
||||
Scheduler.unstable_yieldValue('C');
|
||||
Scheduler.log('C');
|
||||
throw new Error('Oops C');
|
||||
});
|
||||
|
||||
@@ -436,16 +418,16 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('exposes the current priority level', () => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
runWithPriority(ImmediatePriority, () => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
runWithPriority(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
runWithPriority(UserBlockingPriority, () => {
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
});
|
||||
});
|
||||
Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
|
||||
Scheduler.log(getCurrentPriorityLevel());
|
||||
});
|
||||
|
||||
assertLog([
|
||||
@@ -495,25 +477,19 @@ describe('Scheduler', () => {
|
||||
}
|
||||
|
||||
scheduleCallback(ImmediatePriority, () =>
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Immediate: ' + inferPriorityFromCallstack(),
|
||||
),
|
||||
Scheduler.log('Immediate: ' + inferPriorityFromCallstack()),
|
||||
);
|
||||
scheduleCallback(UserBlockingPriority, () =>
|
||||
Scheduler.unstable_yieldValue(
|
||||
'UserBlocking: ' + inferPriorityFromCallstack(),
|
||||
),
|
||||
Scheduler.log('UserBlocking: ' + inferPriorityFromCallstack()),
|
||||
);
|
||||
scheduleCallback(NormalPriority, () =>
|
||||
Scheduler.unstable_yieldValue(
|
||||
'Normal: ' + inferPriorityFromCallstack(),
|
||||
),
|
||||
Scheduler.log('Normal: ' + inferPriorityFromCallstack()),
|
||||
);
|
||||
scheduleCallback(LowPriority, () =>
|
||||
Scheduler.unstable_yieldValue('Low: ' + inferPriorityFromCallstack()),
|
||||
Scheduler.log('Low: ' + inferPriorityFromCallstack()),
|
||||
);
|
||||
scheduleCallback(IdlePriority, () =>
|
||||
Scheduler.unstable_yieldValue('Idle: ' + inferPriorityFromCallstack()),
|
||||
Scheduler.log('Idle: ' + inferPriorityFromCallstack()),
|
||||
);
|
||||
|
||||
await waitForAll([
|
||||
@@ -528,13 +504,9 @@ describe('Scheduler', () => {
|
||||
|
||||
describe('delayed tasks', () => {
|
||||
it('schedules a delayed task', async () => {
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('A'),
|
||||
{
|
||||
delay: 1000,
|
||||
},
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
|
||||
delay: 1000,
|
||||
});
|
||||
|
||||
// Should flush nothing, because delay hasn't elapsed
|
||||
await waitForAll([]);
|
||||
@@ -552,37 +524,21 @@ describe('Scheduler', () => {
|
||||
});
|
||||
|
||||
it('schedules multiple delayed tasks', async () => {
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('C'),
|
||||
{
|
||||
delay: 300,
|
||||
},
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('C'), {
|
||||
delay: 300,
|
||||
});
|
||||
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('B'),
|
||||
{
|
||||
delay: 200,
|
||||
},
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('B'), {
|
||||
delay: 200,
|
||||
});
|
||||
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('D'),
|
||||
{
|
||||
delay: 400,
|
||||
},
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('D'), {
|
||||
delay: 400,
|
||||
});
|
||||
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('A'),
|
||||
{
|
||||
delay: 100,
|
||||
},
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
|
||||
delay: 100,
|
||||
});
|
||||
|
||||
// Should flush nothing, because delay hasn't elapsed
|
||||
await waitForAll([]);
|
||||
@@ -601,32 +557,28 @@ describe('Scheduler', () => {
|
||||
it('interleaves normal tasks and delayed tasks', async () => {
|
||||
// Schedule some high priority callbacks with a delay. When their delay
|
||||
// elapses, they will be the most important callback in the queue.
|
||||
scheduleCallback(
|
||||
UserBlockingPriority,
|
||||
() => Scheduler.unstable_yieldValue('Timer 2'),
|
||||
{delay: 300},
|
||||
);
|
||||
scheduleCallback(
|
||||
UserBlockingPriority,
|
||||
() => Scheduler.unstable_yieldValue('Timer 1'),
|
||||
{delay: 100},
|
||||
);
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 2'), {
|
||||
delay: 300,
|
||||
});
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 1'), {
|
||||
delay: 100,
|
||||
});
|
||||
|
||||
// Schedule some tasks at default priority.
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('C');
|
||||
Scheduler.log('C');
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
});
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('D');
|
||||
Scheduler.log('D');
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
});
|
||||
|
||||
@@ -638,16 +590,12 @@ describe('Scheduler', () => {
|
||||
it('interleaves delayed tasks with time-sliced tasks', async () => {
|
||||
// Schedule some high priority callbacks with a delay. When their delay
|
||||
// elapses, they will be the most important callback in the queue.
|
||||
scheduleCallback(
|
||||
UserBlockingPriority,
|
||||
() => Scheduler.unstable_yieldValue('Timer 2'),
|
||||
{delay: 300},
|
||||
);
|
||||
scheduleCallback(
|
||||
UserBlockingPriority,
|
||||
() => Scheduler.unstable_yieldValue('Timer 1'),
|
||||
{delay: 100},
|
||||
);
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 2'), {
|
||||
delay: 300,
|
||||
});
|
||||
scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 1'), {
|
||||
delay: 100,
|
||||
});
|
||||
|
||||
// Schedule a time-sliced task at default priority.
|
||||
const tasks = [
|
||||
@@ -661,7 +609,7 @@ describe('Scheduler', () => {
|
||||
const task = tasks.shift();
|
||||
const [label, ms] = task;
|
||||
Scheduler.unstable_advanceTime(ms);
|
||||
Scheduler.unstable_yieldValue(label);
|
||||
Scheduler.log(label);
|
||||
if (tasks.length > 0) {
|
||||
return work;
|
||||
}
|
||||
@@ -678,19 +626,15 @@ describe('Scheduler', () => {
|
||||
// Schedule several tasks with the same delay
|
||||
const options = {delay: 100};
|
||||
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('A'),
|
||||
options,
|
||||
);
|
||||
scheduleCallback(NormalPriority, () => Scheduler.log('A'), options);
|
||||
const taskB = scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('B'),
|
||||
() => Scheduler.log('B'),
|
||||
options,
|
||||
);
|
||||
const taskC = scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('C'),
|
||||
() => Scheduler.log('C'),
|
||||
options,
|
||||
);
|
||||
|
||||
@@ -722,11 +666,11 @@ describe('Scheduler', () => {
|
||||
|
||||
it('toFlushUntilNextPaint stops if a continuation is returned', async () => {
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Original Task');
|
||||
Scheduler.unstable_yieldValue('shouldYield: ' + shouldYield());
|
||||
Scheduler.unstable_yieldValue('Return a continuation');
|
||||
Scheduler.log('Original Task');
|
||||
Scheduler.log('shouldYield: ' + shouldYield());
|
||||
Scheduler.log('Return a continuation');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation Task');
|
||||
Scheduler.log('Continuation Task');
|
||||
};
|
||||
});
|
||||
|
||||
@@ -749,11 +693,11 @@ describe('Scheduler', () => {
|
||||
|
||||
it("toFlushAndYield keeps flushing even if there's a continuation", async () => {
|
||||
scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Original Task');
|
||||
Scheduler.unstable_yieldValue('shouldYield: ' + shouldYield());
|
||||
Scheduler.unstable_yieldValue('Return a continuation');
|
||||
Scheduler.log('Original Task');
|
||||
Scheduler.log('shouldYield: ' + shouldYield());
|
||||
Scheduler.log('Return a continuation');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation Task');
|
||||
Scheduler.log('Continuation Task');
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -270,19 +270,19 @@ describe('Scheduler', () => {
|
||||
NormalPriority,
|
||||
() => {
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
Scheduler.unstable_yieldValue('Yield 1');
|
||||
Scheduler.log('Yield 1');
|
||||
scheduleCallback(
|
||||
UserBlockingPriority,
|
||||
() => {
|
||||
Scheduler.unstable_yieldValue('Yield 2');
|
||||
Scheduler.log('Yield 2');
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
},
|
||||
{label: 'Bar'},
|
||||
);
|
||||
Scheduler.unstable_advanceTime(100);
|
||||
Scheduler.unstable_yieldValue('Yield 3');
|
||||
Scheduler.log('Yield 3');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Yield 4');
|
||||
Scheduler.log('Yield 4');
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
};
|
||||
},
|
||||
@@ -305,11 +305,11 @@ Task 1 [Normal] │ ████████░░░░░░░
|
||||
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
|
||||
|
||||
const task = scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Yield 1');
|
||||
Scheduler.log('Yield 1');
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
Scheduler.unstable_yieldValue('Yield 2');
|
||||
Scheduler.log('Yield 2');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation');
|
||||
Scheduler.log('Continuation');
|
||||
Scheduler.unstable_advanceTime(200);
|
||||
};
|
||||
});
|
||||
@@ -354,20 +354,20 @@ Task 1 [Normal] │██████🡐 errored
|
||||
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
|
||||
|
||||
const task1 = scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Yield 1');
|
||||
Scheduler.log('Yield 1');
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
Scheduler.unstable_yieldValue('Yield 2');
|
||||
Scheduler.log('Yield 2');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation');
|
||||
Scheduler.log('Continuation');
|
||||
Scheduler.unstable_advanceTime(200);
|
||||
};
|
||||
});
|
||||
const task2 = scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('Yield 3');
|
||||
Scheduler.log('Yield 3');
|
||||
Scheduler.unstable_advanceTime(300);
|
||||
Scheduler.unstable_yieldValue('Yield 4');
|
||||
Scheduler.log('Yield 4');
|
||||
return () => {
|
||||
Scheduler.unstable_yieldValue('Continuation');
|
||||
Scheduler.log('Continuation');
|
||||
Scheduler.unstable_advanceTime(200);
|
||||
};
|
||||
});
|
||||
@@ -397,7 +397,7 @@ Task 2 [Normal] │░░░░░░░░🡐 canceled
|
||||
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
|
||||
|
||||
const task = scheduleCallback(NormalPriority, () => {
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
Scheduler.unstable_advanceTime(1000);
|
||||
});
|
||||
await waitForAll(['A']);
|
||||
@@ -416,7 +416,7 @@ Task 1 [Normal] │████████████████
|
||||
scheduleCallback(
|
||||
NormalPriority,
|
||||
() => {
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
Scheduler.unstable_advanceTime(1000);
|
||||
},
|
||||
{label: 'A'},
|
||||
@@ -425,7 +425,7 @@ Task 1 [Normal] │████████████████
|
||||
const task = scheduleCallback(
|
||||
NormalPriority,
|
||||
() => {
|
||||
Scheduler.unstable_yieldValue('B');
|
||||
Scheduler.log('B');
|
||||
Scheduler.unstable_advanceTime(1000);
|
||||
},
|
||||
{label: 'B'},
|
||||
@@ -450,7 +450,7 @@ Task 2 [Normal] │ ░░░░░░░░🡐 canceled
|
||||
NormalPriority,
|
||||
() => {
|
||||
Scheduler.unstable_advanceTime(1000);
|
||||
Scheduler.unstable_yieldValue('A');
|
||||
Scheduler.log('A');
|
||||
},
|
||||
{
|
||||
delay: 1000,
|
||||
@@ -472,11 +472,9 @@ Task 1 [Normal] │ █████████
|
||||
|
||||
it('handles cancelling a delayed task', async () => {
|
||||
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
|
||||
const task = scheduleCallback(
|
||||
NormalPriority,
|
||||
() => Scheduler.unstable_yieldValue('A'),
|
||||
{delay: 1000},
|
||||
);
|
||||
const task = scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
|
||||
delay: 1000,
|
||||
});
|
||||
cancelCallback(task);
|
||||
await waitForAll([]);
|
||||
expect(stopProfilingAndPrintFlamegraph()).toEqual(
|
||||
|
||||
@@ -606,7 +606,7 @@ function unstable_flushAllWithoutAsserting(): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function unstable_clearYields(): Array<mixed> {
|
||||
function unstable_clearLog(): Array<mixed> {
|
||||
if (yieldedValues === null) {
|
||||
return [];
|
||||
}
|
||||
@@ -632,7 +632,7 @@ function unstable_flushAll(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function unstable_yieldValue(value: mixed): void {
|
||||
function log(value: mixed): void {
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
if (console.log.name === 'disabledLog' || disableYieldValue) {
|
||||
// If console.log has been patched, we assume we're in render
|
||||
@@ -687,11 +687,11 @@ export {
|
||||
unstable_flushAllWithoutAsserting,
|
||||
unstable_flushNumberOfYields,
|
||||
unstable_flushExpired,
|
||||
unstable_clearYields,
|
||||
unstable_clearLog,
|
||||
unstable_flushUntilNextPaint,
|
||||
unstable_hasPendingWork,
|
||||
unstable_flushAll,
|
||||
unstable_yieldValue,
|
||||
log,
|
||||
unstable_advanceTime,
|
||||
reset,
|
||||
setDisableYieldValue as unstable_setDisableYieldValue,
|
||||
|
||||
@@ -34,7 +34,7 @@ const {
|
||||
// on scheduler/unstable_mock, which we'll need inside act()
|
||||
// and for internal testing
|
||||
unstable_flushAllWithoutAsserting,
|
||||
unstable_yieldValue,
|
||||
log,
|
||||
unstable_setDisableYieldValue,
|
||||
} = ReactInternals.Scheduler;
|
||||
|
||||
@@ -57,6 +57,6 @@ export {
|
||||
unstable_IdlePriority,
|
||||
unstable_forceFrameRate,
|
||||
unstable_flushAllWithoutAsserting,
|
||||
unstable_yieldValue,
|
||||
log,
|
||||
unstable_setDisableYieldValue,
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('useSubscription', () => {
|
||||
|
||||
it('supports basic subscription pattern', async () => {
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('useSubscription', () => {
|
||||
|
||||
it('should support observable types like RxJS ReplaySubject', async () => {
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ describe('useSubscription', () => {
|
||||
|
||||
it('should unsubscribe from old sources and subscribe to new sources when memoized props change', async () => {
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ describe('useSubscription', () => {
|
||||
|
||||
it('should unsubscribe from old sources and subscribe to new sources when useCallback functions change', async () => {
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -274,12 +274,12 @@ describe('useSubscription', () => {
|
||||
const log = [];
|
||||
|
||||
function Grandchild({value}) {
|
||||
Scheduler.unstable_yieldValue('Grandchild: ' + value);
|
||||
Scheduler.log('Grandchild: ' + value);
|
||||
return null;
|
||||
}
|
||||
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + value);
|
||||
Scheduler.log('Child: ' + value);
|
||||
return <Grandchild value={value} />;
|
||||
}
|
||||
|
||||
@@ -377,12 +377,12 @@ describe('useSubscription', () => {
|
||||
const log = [];
|
||||
|
||||
function Grandchild({value}) {
|
||||
Scheduler.unstable_yieldValue('Grandchild: ' + value);
|
||||
Scheduler.log('Grandchild: ' + value);
|
||||
return null;
|
||||
}
|
||||
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue('Child: ' + value);
|
||||
Scheduler.log('Child: ' + value);
|
||||
return <Grandchild value={value} />;
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ describe('useSubscription', () => {
|
||||
|
||||
it('should guard against updates that happen after unmounting', () => {
|
||||
function Child({value = 'default'}) {
|
||||
Scheduler.unstable_yieldValue(value);
|
||||
Scheduler.log(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -593,7 +593,7 @@ describe('useSubscription', () => {
|
||||
|
||||
const Subscriber = ({id}) => {
|
||||
const value = useSubscription(subscription);
|
||||
Scheduler.unstable_yieldValue(`render:${id}:${value}`);
|
||||
Scheduler.log(`render:${id}:${value}`);
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('useSyncExternalStore (userspace shim, server rendering)', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
function App() {
|
||||
const value = useSyncExternalStore(store.subscribe, store.getState);
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Passive effect: ' + value);
|
||||
Scheduler.log('Passive effect: ' + value);
|
||||
}, [value]);
|
||||
return <Text text={value} />;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
// that changed the getSnapshot in Child2. Child2's effects haven't
|
||||
// fired yet, so it doesn't have access to the latest getSnapshot. So
|
||||
// it can't use the getSnapshot to bail out.
|
||||
Scheduler.unstable_yieldValue('Update B in commit phase');
|
||||
Scheduler.log('Update B in commit phase');
|
||||
store.set({a: value.a, b: 2});
|
||||
}
|
||||
}, [step]);
|
||||
@@ -397,7 +397,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
// that changed the getSnapshot in Child2. Child2's effects haven't
|
||||
// fired yet, so it doesn't have access to the latest getSnapshot. So
|
||||
// it can't use the getSnapshot to bail out.
|
||||
Scheduler.unstable_yieldValue('Update B in commit phase');
|
||||
Scheduler.log('Update B in commit phase');
|
||||
store.set({a: value.a, b: 2});
|
||||
}
|
||||
}, [step]);
|
||||
@@ -449,7 +449,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
const value = useSyncExternalStore(store.subscribe, store.getState);
|
||||
useLayoutEffect(() => {
|
||||
if (value === 1) {
|
||||
Scheduler.unstable_yieldValue('Reset back to 0');
|
||||
Scheduler.log('Reset back to 0');
|
||||
store.set(0);
|
||||
}
|
||||
}, [value]);
|
||||
@@ -629,12 +629,12 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
const store = createExternalStore({a: 0, b: 0});
|
||||
|
||||
function selector(state) {
|
||||
Scheduler.unstable_yieldValue('Selector');
|
||||
Scheduler.log('Selector');
|
||||
return state.a;
|
||||
}
|
||||
|
||||
function App() {
|
||||
Scheduler.unstable_yieldValue('App');
|
||||
Scheduler.log('App');
|
||||
const a = useSyncExternalStoreWithSelector(
|
||||
store.subscribe,
|
||||
store.getState,
|
||||
@@ -738,7 +738,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
() => 'server',
|
||||
);
|
||||
useEffect(() => {
|
||||
Scheduler.unstable_yieldValue('Passive effect: ' + text);
|
||||
Scheduler.log('Passive effect: ' + text);
|
||||
}, [text]);
|
||||
return (
|
||||
<div ref={ref}>
|
||||
@@ -838,7 +838,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
|
||||
|
||||
function App({step}) {
|
||||
const inlineSelector = state => {
|
||||
Scheduler.unstable_yieldValue('Inline selector');
|
||||
Scheduler.log('Inline selector');
|
||||
return [...state.items, 'C'];
|
||||
};
|
||||
const items = useSyncExternalStoreWithSelector(
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ describe('useSyncExternalStore (userspace shim, server rendering)', () => {
|
||||
});
|
||||
|
||||
function Text({text}) {
|
||||
Scheduler.unstable_yieldValue(text);
|
||||
Scheduler.log(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const JestReact = require('jest-react');
|
||||
const SchedulerMatchers = require('./schedulerTestMatchers');
|
||||
|
||||
// TODO: Move to ReactInternalTestUtils
|
||||
|
||||
function captureAssertion(fn) {
|
||||
// Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
|
||||
@@ -20,12 +21,13 @@ function captureAssertion(fn) {
|
||||
}
|
||||
|
||||
function assertYieldsWereCleared(Scheduler) {
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
const actualYields = Scheduler.unstable_clearLog();
|
||||
if (actualYields.length !== 0) {
|
||||
throw new Error(
|
||||
'Log of yielded values is not empty. ' +
|
||||
'Call expect(Scheduler).toHaveYielded(...) first.'
|
||||
const error = Error(
|
||||
'The event log is not empty. Call assertLog(...) first.'
|
||||
);
|
||||
Error.captureStackTrace(error, assertYieldsWereCleared);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +43,5 @@ function toMatchRenderedOutput(ReactNoop, expectedJSX) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
...SchedulerMatchers,
|
||||
toMatchRenderedOutput,
|
||||
};
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
function captureAssertion(fn) {
|
||||
// Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
|
||||
// assertion; if it throws, we capture the error and return it, so the stack
|
||||
// trace presented to the user points to the original assertion in the
|
||||
// test file.
|
||||
try {
|
||||
fn();
|
||||
} catch (error) {
|
||||
return {
|
||||
pass: false,
|
||||
message: () => error.message,
|
||||
};
|
||||
}
|
||||
return {pass: true};
|
||||
}
|
||||
|
||||
function assertYieldsWereCleared(Scheduler) {
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
|
||||
if (actualYields.length !== 0) {
|
||||
const error = Error(
|
||||
'Log of yielded values is not empty. ' +
|
||||
'Call expect(Scheduler).toHaveYielded(...) first.'
|
||||
);
|
||||
Error.captureStackTrace(error, assertYieldsWereCleared);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function toFlushAndYield(Scheduler, expectedYields) {
|
||||
assertYieldsWereCleared(Scheduler);
|
||||
Scheduler.unstable_flushAllWithoutAsserting();
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
return captureAssertion(() => {
|
||||
expect(actualYields).toEqual(expectedYields);
|
||||
});
|
||||
}
|
||||
|
||||
function toFlushAndYieldThrough(Scheduler, expectedYields) {
|
||||
assertYieldsWereCleared(Scheduler);
|
||||
Scheduler.unstable_flushNumberOfYields(expectedYields.length);
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
return captureAssertion(() => {
|
||||
expect(actualYields).toEqual(expectedYields);
|
||||
});
|
||||
}
|
||||
|
||||
function toFlushUntilNextPaint(Scheduler, expectedYields) {
|
||||
assertYieldsWereCleared(Scheduler);
|
||||
Scheduler.unstable_flushUntilNextPaint();
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
return captureAssertion(() => {
|
||||
expect(actualYields).toEqual(expectedYields);
|
||||
});
|
||||
}
|
||||
|
||||
function toFlushWithoutYielding(Scheduler) {
|
||||
return toFlushAndYield(Scheduler, []);
|
||||
}
|
||||
|
||||
function toFlushExpired(Scheduler, expectedYields) {
|
||||
assertYieldsWereCleared(Scheduler);
|
||||
Scheduler.unstable_flushExpired();
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
return captureAssertion(() => {
|
||||
expect(actualYields).toEqual(expectedYields);
|
||||
});
|
||||
}
|
||||
|
||||
function toHaveYielded(Scheduler, expectedYields) {
|
||||
return captureAssertion(() => {
|
||||
const actualYields = Scheduler.unstable_clearYields();
|
||||
expect(actualYields).toEqual(expectedYields);
|
||||
});
|
||||
}
|
||||
|
||||
function toFlushAndThrow(Scheduler, ...rest) {
|
||||
assertYieldsWereCleared(Scheduler);
|
||||
return captureAssertion(() => {
|
||||
expect(() => {
|
||||
Scheduler.unstable_flushAllWithoutAsserting();
|
||||
}).toThrow(...rest);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
toFlushAndYield,
|
||||
toFlushAndYieldThrough,
|
||||
toFlushUntilNextPaint,
|
||||
toFlushWithoutYielding,
|
||||
toFlushExpired,
|
||||
toHaveYielded,
|
||||
toFlushAndThrow,
|
||||
};
|
||||
@@ -73,12 +73,12 @@ Index: build/node_modules/react/umd/react.development.js
|
||||
*
|
||||
@@ -16,9 +16,9 @@
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||
@@ -132,12 +132,12 @@ Index: build/node_modules/react/cjs/react.development.js
|
||||
*
|
||||
@@ -19,9 +19,9 @@
|
||||
var checkPropTypes = require('prop-types/checkPropTypes');
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||
@@ -154,12 +154,12 @@ Index: build/node_modules/react-art/umd/react-art.development.js
|
||||
*
|
||||
@@ -20,9 +20,9 @@
|
||||
var _assign = ReactInternals.assign;
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
/**
|
||||
* Use invariant() to assert state which your program assumes to be true.
|
||||
*
|
||||
@@ -194,12 +194,12 @@ Index: build/node_modules/react-art/cjs/react-art.development.js
|
||||
*
|
||||
@@ -25,9 +25,9 @@
|
||||
var FastNoSideEffects = require('art/modes/fast-noSideEffects');
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
/**
|
||||
* Use invariant() to assert state which your program assumes to be true.
|
||||
*
|
||||
@@ -246,14 +246,14 @@ Index: build/node_modules/react-dom/umd/react-dom-server.browser.development.js
|
||||
*
|
||||
@@ -61,9 +61,9 @@
|
||||
// preserve the format and params in the www builds.
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
||||
|
||||
var _assign = ReactInternals.assign;
|
||||
Index: build/node_modules/react-dom/umd/react-dom.production.min.js
|
||||
===================================================================
|
||||
@@ -327,12 +327,12 @@ Index: build/node_modules/react-dom/umd/react-dom.development.js
|
||||
*
|
||||
@@ -19471,9 +19471,9 @@
|
||||
}
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
// TODO: This type is shared between the reconciler and ReactDOM, but will
|
||||
// eventually be lifted out to the renderer.
|
||||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
@@ -407,12 +407,12 @@ Index: build/node_modules/react-dom/cjs/react-dom-server.browser.development.js
|
||||
*
|
||||
@@ -65,9 +65,9 @@
|
||||
// preserve the format and params in the www builds.
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
/**
|
||||
* Similar to invariant but only logs a warning if the condition is not met.
|
||||
* This can be used to log issues in development environments in critical
|
||||
@@ -467,12 +467,12 @@ Index: build/node_modules/react-dom/cjs/react-dom-server.node.development.js
|
||||
*
|
||||
@@ -21,9 +21,9 @@
|
||||
var stream = require('stream');
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
/**
|
||||
* Use invariant() to assert state which your program assumes to be true.
|
||||
*
|
||||
@@ -511,12 +511,12 @@ Index: build/node_modules/react-dom/cjs/react-dom.development.js
|
||||
*
|
||||
@@ -19347,9 +19347,9 @@
|
||||
}
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
// TODO: This type is shared between the reconciler and ReactDOM, but will
|
||||
// eventually be lifted out to the renderer.
|
||||
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
@@ -694,14 +694,14 @@ Index: build/node_modules/react-test-renderer/umd/react-test-renderer.developmen
|
||||
*
|
||||
@@ -11622,9 +11622,9 @@
|
||||
}
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
Index: build/node_modules/react-test-renderer/umd/react-test-renderer.production.min.js
|
||||
===================================================================
|
||||
@@ -717,8 +717,8 @@ Index: build/node_modules/react-test-renderer/umd/react-test-renderer.production
|
||||
@@ -117,5 +117,5 @@
|
||||
!0===b.unstable_isConcurrent&&(d=!0));var e={children:[],createNodeMock:c,tag:"CONTAINER"},g=Gd(e,d,!1);null==g?n("215"):void 0;ac(a,g,null,null);a={root:void 0,toJSON:function(){if(null==g||null==g.current||null==e||0===e.children.length)return null;if(1===e.children.length)return bc(e.children[0]);var a=null;if(e.children&&e.children.length)for(var b=0;b<e.children.length;b++){var c=bc(e.children[b]);null!==c&&(null===a?a=[c]:a.push(c))}return a},toTree:function(){return null==g||null==g.current?
|
||||
null:sb(g.current)},update:function(a){null!=g&&null!=g.current&&ac(a,g,null,null)},unmount:function(){null!=g&&null!=g.current&&(ac(null,g,null,null),g=e=null)},getInstance:function(){if(null==g||null==g.current)return null;a:{var a=g.current;if(a.child)switch(a.child.tag){case 5:a=Ra(a.child.stateNode);break a;default:a=a.child.stateNode}else a=null}return a},unstable_flushAll:Ad,unstable_flushSync:function(a){Ab();a:{la?n("187"):void 0;var b=ob;ob=!0;try{b:{var c=Ia;Ia=1073741823;try{var d=a(void 0,
|
||||
void 0,void 0,void 0);break b}finally{Ia=c}d=void 0}break a}finally{ob=b,mb(1073741823,!1)}d=void 0}return d},unstable_flushNumberOfYields:Bd,unstable_clearYields:Ab};Object.defineProperty(a,"root",{configurable:!0,enumerable:!0,get:function(){if(null===g)throw Error("Can't access .root on unmounted test renderer");var a=cc(g.current);if(0===a.length)throw Error("Can't access .root on unmounted test renderer");return 1===a.length?a[0]:ec(g.current)}});return a},unstable_yield:function(a){I.push(a)},
|
||||
unstable_clearYields:Ab,unstable_batchedUpdates:function(a,b){if(jc)return a(b);jc=!0;try{return a(b)}finally{if(jc=!1,(null!==ub||null!==ic)&&ub&&(b=ub,a=ic,ic=ub=null,td(b),a))for(b=0;b<a.length;b++)td(a[b])}},unstable_setNowImplementation:function(a){jb=a}},gc=new WeakMap;(function(a){var b=a.findFiberByHostInstance;return Dd(V({},a,{findHostInstanceByFiber:function(a){a=zd(a);return null===a?null:a.stateNode},findFiberByHostInstance:function(a){return b?b(a):null}}))})({findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
void 0,void 0,void 0);break b}finally{Ia=c}d=void 0}break a}finally{ob=b,mb(1073741823,!1)}d=void 0}return d},unstable_flushNumberOfYields:Bd,unstable_clearLog:Ab};Object.defineProperty(a,"root",{configurable:!0,enumerable:!0,get:function(){if(null===g)throw Error("Can't access .root on unmounted test renderer");var a=cc(g.current);if(0===a.length)throw Error("Can't access .root on unmounted test renderer");return 1===a.length?a[0]:ec(g.current)}});return a},unstable_yield:function(a){I.push(a)},
|
||||
unstable_clearLog:Ab,unstable_batchedUpdates:function(a,b){if(jc)return a(b);jc=!0;try{return a(b)}finally{if(jc=!1,(null!==ub||null!==ic)&&ub&&(b=ub,a=ic,ic=ub=null,td(b),a))for(b=0;b<a.length;b++)td(a[b])}},unstable_setNowImplementation:function(a){jb=a}},gc=new WeakMap;(function(a){var b=a.findFiberByHostInstance;return Dd(V({},a,{findHostInstanceByFiber:function(a){a=zd(a);return null===a?null:a.stateNode},findFiberByHostInstance:function(a){return b?b(a):null}}))})({findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
-},bundleType:0,version:"16.6.1-canary-b3d1a81a9",rendererPackageName:"react-test-renderer"});var xd={default:wd},yd=xd&&wd||xd;return yd.default||yd});
|
||||
+},bundleType:0,version:"1.2.3",rendererPackageName:"react-test-renderer"});var xd={default:wd},yd=xd&&wd||xd;return yd.default||yd});
|
||||
Index: build/node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js
|
||||
@@ -756,14 +756,14 @@ Index: build/node_modules/react-test-renderer/cjs/react-test-renderer.developmen
|
||||
*
|
||||
@@ -11498,9 +11498,9 @@
|
||||
}
|
||||
|
||||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
|
||||
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
|
||||
+var ReactVersion = '1.2.3';
|
||||
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
Index: build/node_modules/react-test-renderer/cjs/react-test-renderer.production.min.js
|
||||
===================================================================
|
||||
@@ -779,8 +779,8 @@ Index: build/node_modules/react-test-renderer/cjs/react-test-renderer.production
|
||||
@@ -140,5 +140,5 @@
|
||||
var $d={create:function(a,b){var c=Nd.createNodeMock,d=!1;"object"===typeof b&&null!==b&&("function"===typeof b.createNodeMock&&(c=b.createNodeMock),!0===b.unstable_isConcurrent&&(d=!0));var e={children:[],createNodeMock:c,tag:"CONTAINER"},g=eb(e,d,!1);null==g?n("215"):void 0;Hd(a,g,null,null);a={root:void 0,toJSON:function(){if(null==g||null==g.current||null==e||0===e.children.length)return null;if(1===e.children.length)return Od(e.children[0]);var a=null;if(e.children&&e.children.length)for(var b=
|
||||
0;b<e.children.length;b++){var c=Od(e.children[b]);null!==c&&(null===a?a=[c]:a.push(c))}return a},toTree:function(){return null==g||null==g.current?null:Sd(g.current)},update:function(a){null!=g&&null!=g.current&&Hd(a,g,null,null)},unmount:function(){null!=g&&null!=g.current&&(Hd(null,g,null,null),g=e=null)},getInstance:function(){if(null==g||null==g.current)return null;a:{var a=g.current;if(a.child)switch(a.child.tag){case 5:a=Ea(a.child.stateNode);break a;default:a=a.child.stateNode}else a=null}return a},
|
||||
unstable_flushAll:za,unstable_flushSync:function(a){Ba();a:{pd?n("187"):void 0;var b=sd;sd=!0;try{b:{var c=Vc;Vc=1073741823;try{var d=a(void 0,void 0,void 0,void 0);break b}finally{Vc=c}d=void 0}break a}finally{sd=b,Dd(1073741823,!1)}d=void 0}return d},unstable_flushNumberOfYields:Aa,unstable_clearYields:Ba};Object.defineProperty(a,"root",{configurable:!0,enumerable:!0,get:function(){if(null===g)throw Error("Can't access .root on unmounted test renderer");var a=Vd(g.current);if(0===a.length)throw Error("Can't access .root on unmounted test renderer");
|
||||
return 1===a.length?a[0]:Wd(g.current)}});return a},unstable_yield:function(a){D.push(a)},unstable_clearYields:Ba,unstable_batchedUpdates:function(a,b){if(Ld)return a(b);Ld=!0;try{return a(b)}finally{if(Ld=!1,(null!==Id||null!==Jd)&&Id&&(b=Id,a=Jd,Jd=Id=null,Kd(b),a))for(b=0;b<a.length;b++)Kd(a[b])}},unstable_setNowImplementation:function(a){wa=a}},ae=new WeakMap;function Wd(a){var b=ae.get(a);void 0===b&&null!==a.alternate&&(b=ae.get(a.alternate));void 0===b&&(b=new Zd(a),ae.set(a,b));return b}
|
||||
unstable_flushAll:za,unstable_flushSync:function(a){Ba();a:{pd?n("187"):void 0;var b=sd;sd=!0;try{b:{var c=Vc;Vc=1073741823;try{var d=a(void 0,void 0,void 0,void 0);break b}finally{Vc=c}d=void 0}break a}finally{sd=b,Dd(1073741823,!1)}d=void 0}return d},unstable_flushNumberOfYields:Aa,unstable_clearLog:Ba};Object.defineProperty(a,"root",{configurable:!0,enumerable:!0,get:function(){if(null===g)throw Error("Can't access .root on unmounted test renderer");var a=Vd(g.current);if(0===a.length)throw Error("Can't access .root on unmounted test renderer");
|
||||
return 1===a.length?a[0]:Wd(g.current)}});return a},unstable_yield:function(a){D.push(a)},unstable_clearLog:Ba,unstable_batchedUpdates:function(a,b){if(Ld)return a(b);Ld=!0;try{return a(b)}finally{if(Ld=!1,(null!==Id||null!==Jd)&&Id&&(b=Id,a=Jd,Jd=Id=null,Kd(b),a))for(b=0;b<a.length;b++)Kd(a[b])}},unstable_setNowImplementation:function(a){wa=a}},ae=new WeakMap;function Wd(a){var b=ae.get(a);void 0===b&&null!==a.alternate&&(b=ae.get(a.alternate));void 0===b&&(b=new Zd(a),ae.set(a,b));return b}
|
||||
-(function(a){var b=a.findFiberByHostInstance;return Wa(m({},a,{findHostInstanceByFiber:function(a){a=va(a);return null===a?null:a.stateNode},findFiberByHostInstance:function(a){return b?b(a):null}}))})({findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()");},bundleType:0,version:"16.6.1-canary-b3d1a81a9",rendererPackageName:"react-test-renderer"});var be={default:$d},ce=be&&$d||be;module.exports=ce.default||ce;
|
||||
+(function(a){var b=a.findFiberByHostInstance;return Wa(m({},a,{findHostInstanceByFiber:function(a){a=va(a);return null===a?null:a.stateNode},findFiberByHostInstance:function(a){return b?b(a):null}}))})({findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()");},bundleType:0,version:"1.2.3",rendererPackageName:"react-test-renderer"});var be={default:$d},ce=be&&$d||be;module.exports=ce.default||ce;
|
||||
Index: build/node_modules/scheduler/cjs/scheduler.development.js
|
||||
|
||||
Reference in New Issue
Block a user