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.
Andrew Clark committed
Mar 6, 2023 at 11:09 UTC
1528c5ccdf5c61a08adab31116156df6503e26ce
99 files changed
+2286
-2889
packages/internal-test-utils/ReactInternalTestUtils.js
+6
-6
@@ -13,7 +13,7 @@ import {equals} from '@jest/expect-utils';
13
import enqueueTask from './enqueueTask';
14
15
function assertYieldsWereCleared(Scheduler) {
16
- const actualYields = Scheduler.unstable_clearYields();
16
+ const actualYields = Scheduler.unstable_clearLog();
17
if (actualYields.length !== 0) {
18
const error = Error(
19
'The event log is not empty. Call assertLog(...) first.',
@@ -45,14 +45,14 @@ export async function waitFor(expectedLog) {
45
SchedulerMock.unstable_flushNumberOfYields(
46
expectedLog.length - actualLog.length,
47
);
48
- actualLog.push(...SchedulerMock.unstable_clearYields());
48
+ actualLog.push(...SchedulerMock.unstable_clearLog());
49
if (expectedLog.length > actualLog.length) {
50
// Continue flushing until we've logged the expected number of items.
51
} else {
52
// Once we've reached the expected sequence, wait one more microtask to
53
// flush any remaining synchronous work.
54
await waitForMicrotasks();
55
- actualLog.push(...SchedulerMock.unstable_clearYields());
55
+ actualLog.push(...SchedulerMock.unstable_clearLog());
56
break;
57
}
58
} else {
@@ -91,7 +91,7 @@ export async function waitForAll(expectedLog) {
91
SchedulerMock.unstable_flushAllWithoutAsserting();
92
} while (true);
93
94
- const actualLog = SchedulerMock.unstable_clearYields();
94
+ const actualLog = SchedulerMock.unstable_clearLog();
95
if (equals(actualLog, expectedLog)) {
96
return;
97
}
@@ -166,7 +166,7 @@ export async function waitForPaint(expectedLog) {
166
await waitForMicrotasks();
167
}
168
169
- const actualLog = SchedulerMock.unstable_clearYields();
169
+ const actualLog = SchedulerMock.unstable_clearLog();
170
if (equals(actualLog, expectedLog)) {
171
return;
172
}
@@ -180,7 +180,7 @@ ${diff(expectedLog, actualLog)}
180
}
181
182
export function assertLog(expectedLog) {
183
- const actualLog = SchedulerMock.unstable_clearYields();
183
+ const actualLog = SchedulerMock.unstable_clearLog();
184
if (equals(actualLog, expectedLog)) {
185
return;
186
}
packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js
new
+160
@@ -0,0 +1,160 @@
1
+/**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails react-core
8
+ * @jest-environment node
9
+ */
10
+
11
+'use strict';
12
+
13
+const React = require('react');
14
+const {startTransition, useDeferredValue} = React;
15
+const ReactNoop = require('react-noop-renderer');
16
+const {
17
+ waitFor,
18
+ waitForAll,
19
+ waitForPaint,
20
+ waitForThrow,
21
+ assertLog,
22
+} = require('internal-test-utils');
23
+const act = require('jest-react').act;
24
+const Scheduler = require('scheduler/unstable_mock');
25
+
26
+describe('ReactInternalTestUtils', () => {
27
+ test('waitFor', async () => {
28
+ const Yield = ({id}) => {
29
+ Scheduler.log(id);
30
+ return id;
31
+ };
32
+
33
+ const root = ReactNoop.createRoot();
34
+ startTransition(() => {
35
+ root.render(
36
+ <div>
37
+ <Yield id="foo" />
38
+ <Yield id="bar" />
39
+ <Yield id="baz" />
40
+ </div>
41
+ );
42
+ });
43
+
44
+ await waitFor(['foo', 'bar']);
45
+ expect(root).toMatchRenderedOutput(null);
46
+ await waitFor(['baz']);
47
+ expect(root).toMatchRenderedOutput(null);
48
+ await waitForAll([]);
49
+ expect(root).toMatchRenderedOutput(<div>foobarbaz</div>);
50
+ });
51
+
52
+ test('waitForAll', async () => {
53
+ const Yield = ({id}) => {
54
+ Scheduler.log(id);
55
+ return id;
56
+ };
57
+
58
+ const root = ReactNoop.createRoot();
59
+ startTransition(() => {
60
+ root.render(
61
+ <div>
62
+ <Yield id="foo" />
63
+ <Yield id="bar" />
64
+ <Yield id="baz" />
65
+ </div>
66
+ );
67
+ });
68
+
69
+ await waitForAll(['foo', 'bar', 'baz']);
70
+ expect(root).toMatchRenderedOutput(<div>foobarbaz</div>);
71
+ });
72
+
73
+ test('waitForThrow', async () => {
74
+ const Yield = ({id}) => {
75
+ Scheduler.log(id);
76
+ return id;
77
+ };
78
+
79
+ function BadRender() {
80
+ throw new Error('Oh no!');
81
+ }
82
+
83
+ function App() {
84
+ return (
85
+ <div>
86
+ <Yield id="A" />
87
+ <Yield id="B" />
88
+ <BadRender />
89
+ <Yield id="C" />
90
+ <Yield id="D" />
91
+ </div>
92
+ );
93
+ }
94
+
95
+ const root = ReactNoop.createRoot();
96
+ root.render(<App />);
97
+
98
+ await waitForThrow('Oh no!');
99
+ assertLog([
100
+ 'A',
101
+ 'B',
102
+ 'C',
103
+ 'D',
104
+ // React will try one more time before giving up.
105
+ 'A',
106
+ 'B',
107
+ 'C',
108
+ 'D',
109
+ ]);
110
+ });
111
+
112
+ test('waitForPaint', async () => {
113
+ function App({prop}) {
114
+ const deferred = useDeferredValue(prop);
115
+ const text = `Urgent: ${prop}, Deferred: ${deferred}`;
116
+ Scheduler.log(text);
117
+ return text;
118
+ }
119
+
120
+ const root = ReactNoop.createRoot();
121
+ root.render(<App prop="A" />);
122
+
123
+ await waitForAll(['Urgent: A, Deferred: A']);
124
+ expect(root).toMatchRenderedOutput('Urgent: A, Deferred: A');
125
+
126
+ // This update will result in two separate paints: an urgent one, and a
127
+ // deferred one.
128
+ root.render(<App prop="B" />);
129
+ // Urgent paint
130
+ await waitForPaint(['Urgent: B, Deferred: A']);
131
+ expect(root).toMatchRenderedOutput('Urgent: B, Deferred: A');
132
+
133
+ // Deferred paint
134
+ await waitForPaint(['Urgent: B, Deferred: B']);
135
+ expect(root).toMatchRenderedOutput('Urgent: B, Deferred: B');
136
+ });
137
+
138
+ test('assertLog', async () => {
139
+ const Yield = ({id}) => {
140
+ Scheduler.log(id);
141
+ return id;
142
+ };
143
+
144
+ function App() {
145
+ return (
146
+ <div>
147
+ <Yield id="A" />
148
+ <Yield id="B" />
149
+ <Yield id="C" />
150
+ </div>
151
+ );
152
+ }
153
+
154
+ const root = ReactNoop.createRoot();
155
+ await act(async () => {
156
+ root.render(<App />);
157
+ });
158
+ assertLog(['A', 'B', 'C']);
159
+ });
160
+});
packages/jest-react/src/JestReact.js
+1
-1
@@ -29,7 +29,7 @@ function captureAssertion(fn) {
29
30
function assertYieldsWereCleared(root) {
31
const Scheduler = root._Scheduler;
32
- const actualYields = Scheduler.unstable_clearYields();
32
+ const actualYields = Scheduler.unstable_clearLog();
33
if (actualYields.length !== 0) {
34
const error = Error(
35
'Log of yielded values is not empty. ' +
packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js
+10
-14
@@ -54,16 +54,12 @@ describe('ReactCache', () => {
54
listeners = [{resolve, reject}];
55
setTimeout(() => {
56
if (textResourceShouldFail) {
57
- Scheduler.unstable_yieldValue(
58
- `Promise rejected [${text}]`,
59
- );
57
+ Scheduler.log(`Promise rejected [${text}]`);
58
status = 'rejected';
59
value = new Error('Failed to load: ' + text);
60
listeners.forEach(listener => listener.reject(value));
61
} else {
64
- Scheduler.unstable_yieldValue(
65
- `Promise resolved [${text}]`,
66
- );
62
+ Scheduler.log(`Promise resolved [${text}]`);
63
status = 'resolved';
64
value = text;
65
listeners.forEach(listener => listener.resolve(value));
@@ -93,7 +89,7 @@ describe('ReactCache', () => {
89
});
90
91
function Text(props) {
96
- Scheduler.unstable_yieldValue(props.text);
92
+ Scheduler.log(props.text);
93
return props.text;
94
}
95
@@ -101,13 +97,13 @@ describe('ReactCache', () => {
97
const text = props.text;
98
try {
99
TextResource.read([props.text, props.ms]);
104
- Scheduler.unstable_yieldValue(text);
100
+ Scheduler.log(text);
101
return text;
102
} catch (promise) {
103
if (typeof promise.then === 'function') {
108
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
104
+ Scheduler.log(`Suspend! [${text}]`);
105
} else {
110
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
106
+ Scheduler.log(`Error! [${text}]`);
107
}
108
throw promise;
109
}
@@ -171,7 +167,7 @@ describe('ReactCache', () => {
167
});
168
169
function App() {
174
- Scheduler.unstable_yieldValue('App');
170
+ Scheduler.log('App');
171
return BadTextResource.read(['Hi', 100]);
172
}
173
@@ -322,13 +318,13 @@ describe('ReactCache', () => {
318
const text = props.text;
319
try {
320
const actualText = BadTextResource.read([props.text, props.ms]);
325
- Scheduler.unstable_yieldValue(actualText);
321
+ Scheduler.log(actualText);
322
return actualText;
323
} catch (promise) {
324
if (typeof promise.then === 'function') {
329
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
325
+ Scheduler.log(`Suspend! [${text}]`);
326
} else {
331
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
327
+ Scheduler.log(`Error! [${text}]`);
328
}
329
throw promise;
330
}
packages/react-client/src/__tests__/ReactFlight-test.js
+4
-4
@@ -827,7 +827,7 @@ describe('ReactFlight', () => {
827
}
828
829
function ClientDoubler({el}) {
830
- Scheduler.unstable_yieldValue('ClientDoubler');
830
+ Scheduler.log('ClientDoubler');
831
return (
832
<>
833
{el}
@@ -1018,10 +1018,10 @@ describe('ReactFlight', () => {
1018
1019
function Bar() {
1020
if (!promise.unsuspend) {
1021
- Scheduler.unstable_yieldValue('suspended');
1021
+ Scheduler.log('suspended');
1022
throw promise;
1023
}
1024
- Scheduler.unstable_yieldValue('rendered');
1024
+ Scheduler.log('rendered');
1025
const context = React.useContext(ServerContext);
1026
return context;
1027
}
@@ -1055,7 +1055,7 @@ describe('ReactFlight', () => {
1055
);
1056
1057
function ClientBar() {
1058
- Scheduler.unstable_yieldValue('ClientBar');
1058
+ Scheduler.log('ClientBar');
1059
const context = React.useContext(ServerContext);
1060
return <span>{context}</span>;
1061
}
packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js
+43
-45
@@ -193,12 +193,12 @@ describe('Timeline profiler', () => {
193
194
it('should mark render yields', async () => {
195
function Bar() {
196
- Scheduler.unstable_yieldValue('Bar');
196
+ Scheduler.log('Bar');
197
return null;
198
}
199
200
function Foo() {
201
- Scheduler.unstable_yieldValue('Foo');
201
+ Scheduler.log('Foo');
202
return <Bar />;
203
}
204
@@ -908,37 +908,37 @@ describe('Timeline profiler', () => {
908
it('should mark passive and layout effects', async () => {
909
function ComponentWithEffects() {
910
React.useLayoutEffect(() => {
911
- Scheduler.unstable_yieldValue('layout 1 mount');
911
+ Scheduler.log('layout 1 mount');
912
return () => {
913
- Scheduler.unstable_yieldValue('layout 1 unmount');
913
+ Scheduler.log('layout 1 unmount');
914
};
915
}, []);
916
917
React.useEffect(() => {
918
- Scheduler.unstable_yieldValue('passive 1 mount');
918
+ Scheduler.log('passive 1 mount');
919
return () => {
920
- Scheduler.unstable_yieldValue('passive 1 unmount');
920
+ Scheduler.log('passive 1 unmount');
921
};
922
}, []);
923
924
React.useLayoutEffect(() => {
925
- Scheduler.unstable_yieldValue('layout 2 mount');
925
+ Scheduler.log('layout 2 mount');
926
return () => {
927
- Scheduler.unstable_yieldValue('layout 2 unmount');
927
+ Scheduler.log('layout 2 unmount');
928
};
929
}, []);
930
931
React.useEffect(() => {
932
- Scheduler.unstable_yieldValue('passive 2 mount');
932
+ Scheduler.log('passive 2 mount');
933
return () => {
934
- Scheduler.unstable_yieldValue('passive 2 unmount');
934
+ Scheduler.log('passive 2 unmount');
935
};
936
}, []);
937
938
React.useEffect(() => {
939
- Scheduler.unstable_yieldValue('passive 3 mount');
939
+ Scheduler.log('passive 3 mount');
940
return () => {
941
- Scheduler.unstable_yieldValue('passive 3 unmount');
941
+ Scheduler.log('passive 3 unmount');
942
};
943
}, []);
944
@@ -1327,12 +1327,12 @@ describe('Timeline profiler', () => {
1327
// @reactVersion >=18.0
1328
it('should mark render yields', async () => {
1329
function Bar() {
1330
- Scheduler.unstable_yieldValue('Bar');
1330
+ Scheduler.log('Bar');
1331
return null;
1332
}
1333
1334
function Foo() {
1335
- Scheduler.unstable_yieldValue('Foo');
1335
+ Scheduler.log('Foo');
1336
return <Bar />;
1337
}
1338
@@ -1363,7 +1363,7 @@ describe('Timeline profiler', () => {
1363
});
1364
1365
function Example() {
1366
- Scheduler.unstable_yieldValue(resolved ? 'resolved' : 'suspended');
1366
+ Scheduler.log(resolved ? 'resolved' : 'suspended');
1367
if (!resolved) {
1368
throw suspensePromise;
1369
}
@@ -1421,7 +1421,7 @@ describe('Timeline profiler', () => {
1421
});
1422
1423
function Example() {
1424
- Scheduler.unstable_yieldValue(rejected ? 'rejected' : 'suspended');
1424
+ Scheduler.log(rejected ? 'rejected' : 'suspended');
1425
if (!rejected) {
1426
throw suspensePromise;
1427
}
@@ -1479,7 +1479,7 @@ describe('Timeline profiler', () => {
1479
});
1480
1481
function Example() {
1482
- Scheduler.unstable_yieldValue(resolved ? 'resolved' : 'suspended');
1482
+ Scheduler.log(resolved ? 'resolved' : 'suspended');
1483
if (!resolved) {
1484
throw suspensePromise;
1485
}
@@ -1537,7 +1537,7 @@ describe('Timeline profiler', () => {
1537
});
1538
1539
function Example() {
1540
- Scheduler.unstable_yieldValue(rejected ? 'rejected' : 'suspended');
1540
+ Scheduler.log(rejected ? 'rejected' : 'suspended');
1541
if (!rejected) {
1542
throw suspensePromise;
1543
}
@@ -1591,9 +1591,7 @@ describe('Timeline profiler', () => {
1591
}
1592
render() {
1593
Scheduler.unstable_advanceTime(10);
1594
- Scheduler.unstable_yieldValue(
1595
- this.state.didMount ? 'update' : 'mount',
1596
- );
1594
+ Scheduler.log(this.state.didMount ? 'update' : 'mount');
1595
return null;
1596
}
1597
}
@@ -1652,7 +1650,7 @@ describe('Timeline profiler', () => {
1650
}
1651
render() {
1652
Scheduler.unstable_advanceTime(10);
1655
- Scheduler.unstable_yieldValue(forced ? 'force update' : 'mount');
1653
+ Scheduler.log(forced ? 'force update' : 'mount');
1654
return null;
1655
}
1656
}
@@ -1708,7 +1706,7 @@ describe('Timeline profiler', () => {
1706
this.setState({didRender: true});
1707
}
1708
Scheduler.unstable_advanceTime(10);
1711
- Scheduler.unstable_yieldValue(
1709
+ Scheduler.log(
1710
this.state.didRender ? 'second render' : 'first render',
1711
);
1712
return null;
@@ -1775,7 +1773,7 @@ describe('Timeline profiler', () => {
1773
class Example extends React.Component {
1774
render() {
1775
Scheduler.unstable_advanceTime(10);
1778
- Scheduler.unstable_yieldValue(forced ? 'force update' : 'render');
1776
+ Scheduler.log(forced ? 'force update' : 'render');
1777
if (!forced) {
1778
forced = true;
1779
this.forceUpdate();
@@ -1845,7 +1843,7 @@ describe('Timeline profiler', () => {
1843
setDidMount(true);
1844
}, []);
1845
Scheduler.unstable_advanceTime(10);
1848
- Scheduler.unstable_yieldValue(didMount ? 'update' : 'mount');
1846
+ Scheduler.log(didMount ? 'update' : 'mount');
1847
return didMount;
1848
}
1849
@@ -1909,7 +1907,7 @@ describe('Timeline profiler', () => {
1907
setDidMount(true);
1908
}, []);
1909
Scheduler.unstable_advanceTime(10);
1912
- Scheduler.unstable_yieldValue(didMount ? 'update' : 'mount');
1910
+ Scheduler.log(didMount ? 'update' : 'mount');
1911
return didMount;
1912
}
1913
@@ -1971,7 +1969,7 @@ describe('Timeline profiler', () => {
1969
if (!didRender) {
1970
setDidRender(true);
1971
}
1974
- Scheduler.unstable_yieldValue(didRender ? 'update' : 'mount');
1972
+ Scheduler.log(didRender ? 'update' : 'mount');
1973
return didRender;
1974
}
1975
@@ -2024,16 +2022,16 @@ describe('Timeline profiler', () => {
2022
render() {
2023
Scheduler.unstable_advanceTime(10);
2024
if (this.state.error) {
2027
- Scheduler.unstable_yieldValue('ErrorBoundary fallback');
2025
+ Scheduler.log('ErrorBoundary fallback');
2026
return null;
2027
}
2030
- Scheduler.unstable_yieldValue('ErrorBoundary render');
2028
+ Scheduler.log('ErrorBoundary render');
2029
return this.props.children;
2030
}
2031
}
2032
2033
function ExampleThatThrows() {
2036
- Scheduler.unstable_yieldValue('ExampleThatThrows');
2034
+ Scheduler.log('ExampleThatThrows');
2035
throw Error('Expected error');
2036
}
2037
@@ -2119,16 +2117,16 @@ describe('Timeline profiler', () => {
2117
render() {
2118
Scheduler.unstable_advanceTime(10);
2119
if (this.state.error) {
2122
- Scheduler.unstable_yieldValue('ErrorBoundary fallback');
2120
+ Scheduler.log('ErrorBoundary fallback');
2121
return null;
2122
}
2125
- Scheduler.unstable_yieldValue('ErrorBoundary render');
2123
+ Scheduler.log('ErrorBoundary render');
2124
return this.props.children;
2125
}
2126
}
2127
2128
function ExampleThatThrows() {
2131
- Scheduler.unstable_yieldValue('ExampleThatThrows');
2129
+ Scheduler.log('ExampleThatThrows');
2130
// eslint-disable-next-line no-throw-literal
2131
throw 'Expected error';
2132
}
@@ -2231,37 +2229,37 @@ describe('Timeline profiler', () => {
2229
it('should mark passive and layout effects', async () => {
2230
function ComponentWithEffects() {
2231
React.useLayoutEffect(() => {
2234
- Scheduler.unstable_yieldValue('layout 1 mount');
2232
+ Scheduler.log('layout 1 mount');
2233
return () => {
2236
- Scheduler.unstable_yieldValue('layout 1 unmount');
2234
+ Scheduler.log('layout 1 unmount');
2235
};
2236
}, []);
2237
2238
React.useEffect(() => {
2241
- Scheduler.unstable_yieldValue('passive 1 mount');
2239
+ Scheduler.log('passive 1 mount');
2240
return () => {
2243
- Scheduler.unstable_yieldValue('passive 1 unmount');
2241
+ Scheduler.log('passive 1 unmount');
2242
};
2243
}, []);
2244
2245
React.useLayoutEffect(() => {
2248
- Scheduler.unstable_yieldValue('layout 2 mount');
2246
+ Scheduler.log('layout 2 mount');
2247
return () => {
2250
- Scheduler.unstable_yieldValue('layout 2 unmount');
2248
+ Scheduler.log('layout 2 unmount');
2249
};
2250
}, []);
2251
2252
React.useEffect(() => {
2255
- Scheduler.unstable_yieldValue('passive 2 mount');
2253
+ Scheduler.log('passive 2 mount');
2254
return () => {
2257
- Scheduler.unstable_yieldValue('passive 2 unmount');
2255
+ Scheduler.log('passive 2 unmount');
2256
};
2257
}, []);
2258
2259
React.useEffect(() => {
2262
- Scheduler.unstable_yieldValue('passive 3 mount');
2260
+ Scheduler.log('passive 3 mount');
2261
return () => {
2264
- Scheduler.unstable_yieldValue('passive 3 unmount');
2262
+ Scheduler.log('passive 3 unmount');
2263
};
2264
}, []);
2265
@@ -2464,7 +2462,7 @@ describe('Timeline profiler', () => {
2462
2463
it('should generate component stacks for state update', async () => {
2464
function CommponentWithChildren({initialRender}) {
2467
- Scheduler.unstable_yieldValue('Render ComponentWithChildren');
2465
+ Scheduler.log('Render ComponentWithChildren');
2466
return <Child initialRender={initialRender} />;
2467
}
2468
@@ -2473,7 +2471,7 @@ describe('Timeline profiler', () => {
2471
if (!didRender) {
2472
setDidRender(true);
2473
}
2476
- Scheduler.unstable_yieldValue('Render Child');
2474
+ Scheduler.log('Render Child');
2475
return null;
2476
}
2477
packages/react-devtools-shared/src/__tests__/preprocessData-test.js
+11
-17
@@ -1352,7 +1352,7 @@ describe('Timeline profiler', () => {
1352
// @reactVersion >= 18.0
1353
it('should not warn when React finishes a previously long (async) update with a short (sync) update inside of an event', async () => {
1354
function Yield({id, value}) {
1355
- Scheduler.unstable_yieldValue(`${id}:${value}`);
1355
+ Scheduler.log(`${id}:${value}`);
1356
return null;
1357
}
1358
@@ -1415,9 +1415,7 @@ describe('Timeline profiler', () => {
1415
it('should not warn about short nested (state) updates during layout effects', async () => {
1416
function Component() {
1417
const [didMount, setDidMount] = React.useState(false);
1418
- Scheduler.unstable_yieldValue(
1419
- `Component ${didMount ? 'update' : 'mount'}`,
1420
- );
1418
+ Scheduler.log(`Component ${didMount ? 'update' : 'mount'}`);
1419
React.useLayoutEffect(() => {
1420
setDidMount(true);
1421
}, []);
@@ -1453,7 +1451,7 @@ describe('Timeline profiler', () => {
1451
this.forceUpdate();
1452
}
1453
render() {
1456
- Scheduler.unstable_yieldValue(
1454
+ Scheduler.log(
1455
`Component ${this._didMount ? 'update' : 'mount'}`,
1456
);
1457
return null;
@@ -1485,9 +1483,7 @@ describe('Timeline profiler', () => {
1483
it.skip('should warn about long nested (state) updates during layout effects', async () => {
1484
function Component() {
1485
const [didMount, setDidMount] = React.useState(false);
1488
- Scheduler.unstable_yieldValue(
1489
- `Component ${didMount ? 'update' : 'mount'}`,
1490
- );
1486
+ Scheduler.log(`Component ${didMount ? 'update' : 'mount'}`);
1487
// Fake a long render
1488
startTime += 20000;
1489
React.useLayoutEffect(() => {
@@ -1549,7 +1545,7 @@ describe('Timeline profiler', () => {
1545
this.forceUpdate();
1546
}
1547
render() {
1552
- Scheduler.unstable_yieldValue(
1548
+ Scheduler.log(
1549
`Component ${this._didMount ? 'update' : 'mount'}`,
1550
);
1551
return null;
@@ -1606,13 +1602,11 @@ describe('Timeline profiler', () => {
1602
// eslint-disable-next-line no-unused-vars
1603
const [isPending, startTransition] = React.useTransition();
1604
1609
- Scheduler.unstable_yieldValue(
1610
- `Component rendered with value ${value}`,
1611
- );
1605
+ Scheduler.log(`Component rendered with value ${value}`);
1606
1607
// Fake a long render
1608
if (value !== 0) {
1615
- Scheduler.unstable_yieldValue('Long render');
1609
+ Scheduler.log('Long render');
1610
startTime += 20000;
1611
}
1612
@@ -1677,13 +1671,13 @@ describe('Timeline profiler', () => {
1671
const [value, setValue] = React.useState(0);
1672
const deferredValue = React.useDeferredValue(value);
1673
1680
- Scheduler.unstable_yieldValue(
1674
+ Scheduler.log(
1675
`Component rendered with value ${value} and deferredValue ${deferredValue}`,
1676
);
1677
1678
// Fake a long render
1679
if (deferredValue !== 0) {
1686
- Scheduler.unstable_yieldValue('Long render');
1680
+ Scheduler.log('Long render');
1681
startTime += 20000;
1682
}
1683
@@ -1805,7 +1799,7 @@ describe('Timeline profiler', () => {
1799
}
1800
1801
function Component({shouldSuspend}) {
1808
- Scheduler.unstable_yieldValue(`Component ${shouldSuspend}`);
1802
+ Scheduler.log(`Component ${shouldSuspend}`);
1803
if (shouldSuspend) {
1804
readValue(123);
1805
}
@@ -1863,7 +1857,7 @@ describe('Timeline profiler', () => {
1857
}
1858
1859
function Component({shouldSuspend}) {
1866
- Scheduler.unstable_yieldValue(`Component ${shouldSuspend}`);
1860
+ Scheduler.log(`Component ${shouldSuspend}`);
1861
if (shouldSuspend) {
1862
readValue(123);
1863
}
packages/react-devtools-shared/src/__tests__/setupTests.js
-4
@@ -177,7 +177,3 @@ afterEach(() => {
177
// so that we don't disconnect the ReactCurrentDispatcher ref.
178
jest.resetModules();
179
});
180
-
181
-expect.extend({
182
- ...require('../../../../scripts/jest/matchers/schedulerTestMatchers'),
183
-});
packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
+1
-1
@@ -600,7 +600,7 @@ describe('ReactDOMFiberAsync', () => {
600
const root = ReactDOMClient.createRoot(container);
601
602
function Text(props) {
603
- Scheduler.unstable_yieldValue(props.text);
603
+ Scheduler.log(props.text);
604
return props.text;
605
}
606
packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
+38
-60
@@ -2118,7 +2118,7 @@ describe('ReactDOMFizzServer', () => {
2118
}
2119
2120
function Child({text}) {
2121
- Scheduler.unstable_yieldValue(text);
2121
+ Scheduler.log(text);
2122
return text;
2123
}
2124
@@ -2153,9 +2153,7 @@ describe('ReactDOMFizzServer', () => {
2153
2154
ReactDOMClient.hydrateRoot(container, <App />, {
2155
onRecoverableError(error) {
2156
- Scheduler.unstable_yieldValue(
2157
- 'Log recoverable error: ' + error.message,
2158
- );
2156
+ Scheduler.log('Log recoverable error: ' + error.message);
2157
},
2158
});
2159
@@ -2203,7 +2201,7 @@ describe('ReactDOMFizzServer', () => {
2201
return () => {};
2202
}
2203
function Child({text}) {
2206
- Scheduler.unstable_yieldValue(text);
2204
+ Scheduler.log(text);
2205
return text;
2206
}
2207
function App() {
@@ -2238,9 +2236,7 @@ describe('ReactDOMFizzServer', () => {
2236
2237
ReactDOMClient.hydrateRoot(container, <App />, {
2238
onRecoverableError(error) {
2241
- Scheduler.unstable_yieldValue(
2242
- 'Log recoverable error: ' + error.message,
2243
- );
2239
+ Scheduler.log('Log recoverable error: ' + error.message);
2240
},
2241
});
2242
@@ -2296,7 +2292,7 @@ describe('ReactDOMFizzServer', () => {
2292
getClientSnapshot,
2293
getServerSnapshot,
2294
);
2299
- Scheduler.unstable_yieldValue(value);
2295
+ Scheduler.log(value);
2296
return value;
2297
}
2298
@@ -2323,7 +2319,7 @@ describe('ReactDOMFizzServer', () => {
2319
isClient = true;
2320
ReactDOMClient.hydrateRoot(container, <App />, {
2321
onRecoverableError(error) {
2326
- Scheduler.unstable_yieldValue(error.message);
2322
+ Scheduler.log(error.message);
2323
},
2324
});
2325
@@ -2378,7 +2374,7 @@ describe('ReactDOMFizzServer', () => {
2374
getClientSnapshot,
2375
getServerSnapshot,
2376
);
2381
- Scheduler.unstable_yieldValue(value);
2377
+ Scheduler.log(value);
2378
return value;
2379
}
2380
@@ -2413,7 +2409,7 @@ describe('ReactDOMFizzServer', () => {
2409
isClient = true;
2410
ReactDOMClient.hydrateRoot(container, <App />, {
2411
onRecoverableError(error) {
2416
- Scheduler.unstable_yieldValue(error.message);
2412
+ Scheduler.log(error.message);
2413
},
2414
});
2415
@@ -2468,7 +2464,7 @@ describe('ReactDOMFizzServer', () => {
2464
if (isClient) {
2465
throw new Error('Oops!');
2466
}
2471
- Scheduler.unstable_yieldValue('Yay!');
2467
+ Scheduler.log('Yay!');
2468
return 'Yay!';
2469
}
2470
@@ -2527,7 +2523,7 @@ describe('ReactDOMFizzServer', () => {
2523
} else {
2524
throw Error('Oops.');
2525
}
2530
- Scheduler.unstable_yieldValue('Yay!');
2526
+ Scheduler.log('Yay!');
2527
return 'Yay!';
2528
}
2529
@@ -2546,7 +2542,7 @@ describe('ReactDOMFizzServer', () => {
2542
await act(async () => {
2543
const {pipe} = renderToPipeableStream(<App />, {
2544
onError(error) {
2549
- Scheduler.unstable_yieldValue('[s!] ' + error.message);
2545
+ Scheduler.log('[s!] ' + error.message);
2546
},
2547
});
2548
pipe(writable);
@@ -2561,7 +2557,7 @@ describe('ReactDOMFizzServer', () => {
2557
isClient = true;
2558
ReactDOMClient.hydrateRoot(container, <App />, {
2559
onRecoverableError(error) {
2564
- Scheduler.unstable_yieldValue('[c!] ' + error.message);
2560
+ Scheduler.log('[c!] ' + error.message);
2561
},
2562
});
2563
// This should not report any errors yet.
@@ -2612,7 +2608,7 @@ describe('ReactDOMFizzServer', () => {
2608
} else {
2609
throw Error('Oops.');
2610
}
2615
- Scheduler.unstable_yieldValue('Yay! (' + color + ')');
2611
+ Scheduler.log('Yay! (' + color + ')');
2612
return 'Yay! (' + color + ')';
2613
}
2614
@@ -2631,7 +2627,7 @@ describe('ReactDOMFizzServer', () => {
2627
await act(async () => {
2628
const {pipe} = renderToPipeableStream(<App color="red" />, {
2629
onError(error) {
2634
- Scheduler.unstable_yieldValue('[s!] ' + error.message);
2630
+ Scheduler.log('[s!] ' + error.message);
2631
},
2632
});
2633
pipe(writable);
@@ -2646,7 +2642,7 @@ describe('ReactDOMFizzServer', () => {
2642
isClient = true;
2643
const root = ReactDOMClient.hydrateRoot(container, <App color="red" />, {
2644
onRecoverableError(error) {
2649
- Scheduler.unstable_yieldValue('[c!] ' + error.message);
2645
+ Scheduler.log('[c!] ' + error.message);
2646
},
2647
});
2648
// This should not report any errors yet.
@@ -2709,7 +2705,7 @@ describe('ReactDOMFizzServer', () => {
2705
} else {
2706
throw Error('Oops.');
2707
}
2712
- Scheduler.unstable_yieldValue(value);
2708
+ Scheduler.log(value);
2709
return value;
2710
}
2711
@@ -2731,7 +2727,7 @@ describe('ReactDOMFizzServer', () => {
2727
<App fallbackText="Loading..." />,
2728
{
2729
onError(error) {
2734
- Scheduler.unstable_yieldValue('[s!] ' + error.message);
2730
+ Scheduler.log('[s!] ' + error.message);
2731
},
2732
},
2733
);
@@ -2749,7 +2745,7 @@ describe('ReactDOMFizzServer', () => {
2745
<App fallbackText="Loading..." />,
2746
{
2747
onRecoverableError(error) {
2752
- Scheduler.unstable_yieldValue('[c!] ' + error.message);
2748
+ Scheduler.log('[c!] ' + error.message);
2749
},
2750
},
2751
);
@@ -2833,7 +2829,7 @@ describe('ReactDOMFizzServer', () => {
2829
if (isClient) {
2830
readText(value);
2831
}
2836
- Scheduler.unstable_yieldValue(value);
2832
+ Scheduler.log(value);
2833
return value;
2834
}
2835
@@ -2868,7 +2864,7 @@ describe('ReactDOMFizzServer', () => {
2864
isClient = true;
2865
ReactDOMClient.hydrateRoot(container, <App />, {
2866
onRecoverableError(error) {
2871
- Scheduler.unstable_yieldValue(error.message);
2867
+ Scheduler.log(error.message);
2868
},
2869
});
2870
@@ -2914,15 +2910,15 @@ describe('ReactDOMFizzServer', () => {
2910
2911
function A() {
2912
if (shouldThrow) {
2917
- Scheduler.unstable_yieldValue('Oops!');
2913
+ Scheduler.log('Oops!');
2914
throw new Error('Oops!');
2915
}
2920
- Scheduler.unstable_yieldValue('A');
2916
+ Scheduler.log('A');
2917
return 'A';
2918
}
2919
2920
function B() {
2925
- Scheduler.unstable_yieldValue('B');
2921
+ Scheduler.log('B');
2922
return 'B';
2923
}
2924
@@ -2937,9 +2933,7 @@ describe('ReactDOMFizzServer', () => {
2933
2934
const root = ReactDOMClient.createRoot(container, {
2935
onRecoverableError(error) {
2940
- Scheduler.unstable_yieldValue(
2941
- 'Logged a recoverable error: ' + error.message,
2942
- );
2936
+ Scheduler.log('Logged a recoverable error: ' + error.message);
2937
},
2938
});
2939
React.startTransition(() => {
@@ -2990,7 +2984,7 @@ describe('ReactDOMFizzServer', () => {
2984
// useSyncExternalStore in this test is because getServerSnapshot has the
2985
// ability to observe whether we're hydrating.
2986
useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);
2993
- Scheduler.unstable_yieldValue(label);
2987
+ Scheduler.log(label);
2988
return label;
2989
}
2990
@@ -3018,9 +3012,7 @@ describe('ReactDOMFizzServer', () => {
3012
isClient = true;
3013
ReactDOMClient.hydrateRoot(container, <App />, {
3014
onRecoverableError(error) {
3021
- Scheduler.unstable_yieldValue(
3022
- 'Logged recoverable error: ' + error.message,
3023
- );
3015
+ Scheduler.log('Logged recoverable error: ' + error.message);
3016
},
3017
});
3018
@@ -3722,9 +3714,7 @@ describe('ReactDOMFizzServer', () => {
3714
const [ClientApp, clientResolve] = makeApp();
3715
ReactDOMClient.hydrateRoot(container, <ClientApp />, {
3716
onRecoverableError(error) {
3725
- Scheduler.unstable_yieldValue(
3726
- 'Logged recoverable error: ' + error.message,
3727
- );
3717
+ Scheduler.log('Logged recoverable error: ' + error.message);
3718
},
3719
});
3720
Scheduler.unstable_flushAll();
@@ -3801,9 +3791,7 @@ describe('ReactDOMFizzServer', () => {
3791
const [ClientApp, clientResolve] = makeApp();
3792
ReactDOMClient.hydrateRoot(container, <ClientApp text="replaced" />, {
3793
onRecoverableError(error) {
3804
- Scheduler.unstable_yieldValue(
3805
- 'Logged recoverable error: ' + error.message,
3806
- );
3794
+ Scheduler.log('Logged recoverable error: ' + error.message);
3795
},
3796
});
3797
Scheduler.unstable_flushAll();
@@ -3872,9 +3860,7 @@ describe('ReactDOMFizzServer', () => {
3860
3861
ReactDOMClient.hydrateRoot(container, <App text="replaced" />, {
3862
onRecoverableError(error) {
3875
- Scheduler.unstable_yieldValue(
3876
- 'Logged recoverable error: ' + error.message,
3877
- );
3863
+ Scheduler.log('Logged recoverable error: ' + error.message);
3864
},
3865
});
3866
await waitForAll([
@@ -3963,9 +3949,7 @@ describe('ReactDOMFizzServer', () => {
3949
3950
ReactDOMClient.hydrateRoot(container, <App />, {
3951
onRecoverableError(error) {
3966
- Scheduler.unstable_yieldValue(
3967
- 'Logged recoverable error: ' + error.message,
3968
- );
3952
+ Scheduler.log('Logged recoverable error: ' + error.message);
3953
},
3954
});
3955
await waitForAll([
@@ -4005,7 +3989,7 @@ describe('ReactDOMFizzServer', () => {
3989
3990
function ThrowUntilOnClient({children, message}) {
3991
if (isClient && shouldThrow) {
4008
- Scheduler.unstable_yieldValue('throwing: ' + message);
3992
+ Scheduler.log('throwing: ' + message);
3993
throw new Error(message);
3994
}
3995
return children;
@@ -4055,9 +4039,7 @@ describe('ReactDOMFizzServer', () => {
4039
4040
ReactDOMClient.hydrateRoot(container, <App />, {
4041
onRecoverableError(error) {
4058
- Scheduler.unstable_yieldValue(
4059
- 'Logged recoverable error: ' + error.message,
4060
- );
4042
+ Scheduler.log('Logged recoverable error: ' + error.message);
4043
},
4044
});
4045
await waitForAll([
@@ -4127,7 +4109,7 @@ describe('ReactDOMFizzServer', () => {
4109
};
4110
});
4111
}
4130
- Scheduler.unstable_yieldValue('suspending');
4112
+ Scheduler.log('suspending');
4113
throw promise;
4114
}
4115
return null;
@@ -4135,7 +4117,7 @@ describe('ReactDOMFizzServer', () => {
4117
4118
function ThrowUntilOnClient({children, message}) {
4119
if (isClient && shouldThrow) {
4138
- Scheduler.unstable_yieldValue('throwing: ' + message);
4120
+ Scheduler.log('throwing: ' + message);
4121
throw new Error(message);
4122
}
4123
return children;
@@ -4186,9 +4168,7 @@ describe('ReactDOMFizzServer', () => {
4168
4169
ReactDOMClient.hydrateRoot(container, <App />, {
4170
onRecoverableError(error) {
4189
- Scheduler.unstable_yieldValue(
4190
- 'Logged recoverable error: ' + error.message,
4191
- );
4171
+ Scheduler.log('Logged recoverable error: ' + error.message);
4172
},
4173
});
4174
await waitForAll([
@@ -4250,7 +4230,7 @@ describe('ReactDOMFizzServer', () => {
4230
};
4231
});
4232
}
4253
- Scheduler.unstable_yieldValue('suspending');
4233
+ Scheduler.log('suspending');
4234
throw promise;
4235
}
4236
return null;
@@ -4258,7 +4238,7 @@ describe('ReactDOMFizzServer', () => {
4238
4239
function ThrowUntilOnClient({children, message}) {
4240
if (isClient && shouldThrow) {
4261
- Scheduler.unstable_yieldValue('throwing: ' + message);
4241
+ Scheduler.log('throwing: ' + message);
4242
throw new Error(message);
4243
}
4244
return children;
@@ -4309,9 +4289,7 @@ describe('ReactDOMFizzServer', () => {
4289
4290
ReactDOMClient.hydrateRoot(container, <App />, {
4291
onRecoverableError(error) {
4312
- Scheduler.unstable_yieldValue(
4313
- 'Logged recoverable error: ' + error.message,
4314
- );
4292
+ Scheduler.log('Logged recoverable error: ' + error.message);
4293
},
4294
});
4295
await waitForAll([
packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js
+4
-4
@@ -129,7 +129,7 @@ describe('ReactDOMFizzShellHydration', () => {
129
return record.value;
130
}
131
} else {
132
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
132
+ Scheduler.log(`Suspend! [${text}]`);
133
134
const thenable = {
135
pings: [],
@@ -153,13 +153,13 @@ describe('ReactDOMFizzShellHydration', () => {
153
}
154
155
function Text({text}) {
156
- Scheduler.unstable_yieldValue(text);
156
+ Scheduler.log(text);
157
return text;
158
}
159
160
function AsyncText({text}) {
161
readText(text);
162
- Scheduler.unstable_yieldValue(text);
162
+ Scheduler.log(text);
163
return text;
164
}
165
@@ -275,7 +275,7 @@ describe('ReactDOMFizzShellHydration', () => {
275
const root = await clientAct(async () => {
276
return ReactDOMClient.hydrateRoot(container, <App />, {
277
onRecoverableError(error) {
278
- Scheduler.unstable_yieldValue(error.message);
278
+ Scheduler.log(error.message);
279
},
280
});
281
});
packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js
+12
-12
@@ -156,7 +156,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
156
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
157
onRecoverableError(error) {
158
// Don't miss a hydration error. There should be none.
159
- Scheduler.unstable_yieldValue(error.message);
159
+ Scheduler.log(error.message);
160
},
161
});
162
await waitForAll([]);
@@ -196,7 +196,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
196
);
197
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
198
onRecoverableError(error) {
199
- Scheduler.unstable_yieldValue(error.message);
199
+ Scheduler.log(error.message);
200
},
201
});
202
await waitForAll([]);
@@ -237,7 +237,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
237
);
238
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
239
onRecoverableError(error) {
240
- Scheduler.unstable_yieldValue(error.message);
240
+ Scheduler.log(error.message);
241
},
242
});
243
await expect(async () => {
@@ -284,7 +284,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
284
);
285
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
286
onRecoverableError(error) {
287
- Scheduler.unstable_yieldValue(error.message);
287
+ Scheduler.log(error.message);
288
},
289
});
290
await waitForAll([]);
@@ -320,7 +320,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
320
);
321
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
322
onRecoverableError(error) {
323
- Scheduler.unstable_yieldValue(error.message);
323
+ Scheduler.log(error.message);
324
},
325
});
326
await expect(async () => {
@@ -368,7 +368,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
368
);
369
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
370
onRecoverableError(error) {
371
- Scheduler.unstable_yieldValue(error.message);
371
+ Scheduler.log(error.message);
372
},
373
});
374
await expect(async () => {
@@ -419,7 +419,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
419
);
420
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
421
onRecoverableError(error) {
422
- Scheduler.unstable_yieldValue(error.message);
422
+ Scheduler.log(error.message);
423
},
424
});
425
await expect(async () => {
@@ -468,7 +468,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
468
);
469
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
470
onRecoverableError(error) {
471
- Scheduler.unstable_yieldValue(error.message);
471
+ Scheduler.log(error.message);
472
},
473
});
474
await expect(async () => {
@@ -522,7 +522,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
522
);
523
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
524
onRecoverableError(error) {
525
- Scheduler.unstable_yieldValue(error.message);
525
+ Scheduler.log(error.message);
526
},
527
});
528
await waitForAll([]);
@@ -559,7 +559,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
559
);
560
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
561
onRecoverableError(error) {
562
- Scheduler.unstable_yieldValue(error.message);
562
+ Scheduler.log(error.message);
563
},
564
});
565
await waitForAll([]);
@@ -592,7 +592,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
592
);
593
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
594
onRecoverableError(error) {
595
- Scheduler.unstable_yieldValue(error.message);
595
+ Scheduler.log(error.message);
596
},
597
});
598
await expect(async () => {
@@ -638,7 +638,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
638
);
639
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
640
onRecoverableError(error) {
641
- Scheduler.unstable_yieldValue(error.message);
641
+ Scheduler.log(error.message);
642
},
643
});
644
await expect(async () => {
packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js
+17
-17
@@ -29,12 +29,12 @@ let waitFor;
29
let assertLog;
30
31
function PhaseMarkers({children}) {
32
- Scheduler.unstable_yieldValue('render start');
32
+ Scheduler.log('render start');
33
React.useLayoutEffect(() => {
34
- Scheduler.unstable_yieldValue('last layout');
34
+ Scheduler.log('last layout');
35
});
36
React.useEffect(() => {
37
- Scheduler.unstable_yieldValue('last passive');
37
+ Scheduler.log('last passive');
38
});
39
return children;
40
}
@@ -50,7 +50,7 @@ function last(arr) {
50
}
51
52
function Text(props) {
53
- Scheduler.unstable_yieldValue(props.text);
53
+ Scheduler.log(props.text);
54
return props.text;
55
}
56
@@ -58,13 +58,13 @@ function Text(props) {
58
// const text = props.text;
59
// try {
60
// TextResource.read([props.text, props.ms]);
61
-// Scheduler.unstable_yieldValue(text);
61
+// Scheduler.log(text);
62
// return text;
63
// } catch (promise) {
64
// if (typeof promise.then === 'function') {
65
-// Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
65
+// Scheduler.log(`Suspend! [${text}]`);
66
// } else {
67
-// Scheduler.unstable_yieldValue(`Error! [${text}]`);
67
+// Scheduler.log(`Error! [${text}]`);
68
// }
69
// throw promise;
70
// }
@@ -72,12 +72,12 @@ function Text(props) {
72
73
function Img({src: maybeSrc, onLoad, useImageLoader, ref}) {
74
const src = maybeSrc || 'default';
75
- Scheduler.unstable_yieldValue('Img ' + src);
75
+ Scheduler.log('Img ' + src);
76
return <img src={src} onLoad={onLoad} />;
77
}
78
79
function Yield() {
80
- Scheduler.unstable_yieldValue('Yield');
80
+ Scheduler.log('Yield');
81
Scheduler.unstable_requestPaint();
82
return null;
83
}
@@ -105,12 +105,12 @@ describe('ReactDOMImageLoad', () => {
105
106
onLoadSpy = jest.fn(reactEvent => {
107
const src = reactEvent.target.getAttribute('src');
108
- Scheduler.unstable_yieldValue('onLoadSpy [' + src + ']');
108
+ Scheduler.log('onLoadSpy [' + src + ']');
109
});
110
111
actualLoadSpy = jest.fn(nativeEvent => {
112
const src = nativeEvent.target.getAttribute('src');
113
- Scheduler.unstable_yieldValue('actualLoadSpy [' + src + ']');
113
+ Scheduler.log('actualLoadSpy [' + src + ']');
114
nativeEvent.__originalDispatch = false;
115
});
116
@@ -127,14 +127,14 @@ describe('ReactDOMImageLoad', () => {
127
// listeners = [{resolve, reject}];
128
// setTimeout(() => {
129
// if (textResourceShouldFail) {
130
- // Scheduler.unstable_yieldValue(
130
+ // Scheduler.log(
131
// `Promise rejected [${text}]`,
132
// );
133
// status = 'rejected';
134
// value = new Error('Failed to load: ' + text);
135
// listeners.forEach(listener => listener.reject(value));
136
// } else {
137
- // Scheduler.unstable_yieldValue(
137
+ // Scheduler.log(
138
// `Promise resolved [${text}]`,
139
// );
140
// status = 'resolved';
@@ -185,7 +185,7 @@ describe('ReactDOMImageLoad', () => {
185
return this.getAttribute('src');
186
},
187
set(value) {
188
- Scheduler.unstable_yieldValue('load triggered');
188
+ Scheduler.log('load triggered');
189
this.__needsDispatch = true;
190
this.setAttribute('src', value);
191
},
@@ -438,7 +438,7 @@ describe('ReactDOMImageLoad', () => {
438
439
// it('captures the load event if it happens in a suspended subtree and replays it between layout and passive effects on resumption', async function() {
440
// function SuspendingWithImage() {
441
- // Scheduler.unstable_yieldValue('SuspendingWithImage');
441
+ // Scheduler.log('SuspendingWithImage');
442
// return (
443
// <Suspense fallback={<Text text="Loading..." />}>
444
// <AsyncText text="A" ms={100} />
@@ -511,9 +511,9 @@ describe('ReactDOMImageLoad', () => {
511
}
512
513
function YieldingWithImage({src}) {
514
- Scheduler.unstable_yieldValue('YieldingWithImage');
514
+ Scheduler.log('YieldingWithImage');
515
React.useEffect(() => {
516
- Scheduler.unstable_yieldValue('Committed');
516
+ Scheduler.log('Committed');
517
});
518
return (
519
<>
packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js
+2
-2
@@ -287,7 +287,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
287
const target = React.createRef(null);
288
function Foo({hovered}) {
289
const hoverString = hovered ? 'hovered' : 'not hovered';
290
- Scheduler.unstable_yieldValue(hoverString);
290
+ Scheduler.log(hoverString);
291
return <div ref={target}>{hoverString}</div>;
292
}
293
@@ -367,7 +367,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
367
ReactDOM.unstable_batchedUpdates(() => {
368
setCount(count + 1);
369
});
370
- Scheduler.unstable_yieldValue(
370
+ Scheduler.log(
371
container.textContent + ' [after batchedUpdates]',
372
);
373
};
packages/react-dom/src/__tests__/ReactDOMNestedEvents-test.js
+1
-3
@@ -41,9 +41,7 @@ describe('ReactDOMNestedEvents', () => {
41
// The update triggered by the focus event should not have flushed yet.
42
// Nor the click update. They would have if we had wrapped the focus
43
// call in `flushSync`, though.
44
- Scheduler.unstable_yieldValue(
45
- 'Value right after focus call: ' + el.innerHTML,
46
- );
44
+ Scheduler.log('Value right after focus call: ' + el.innerHTML);
45
};
46
const onFocus = () => {
47
setIsFocused(true);
packages/react-dom/src/__tests__/ReactDOMRoot-test.js
+2
-2
@@ -258,7 +258,7 @@ describe('ReactDOMRoot', () => {
258
it('callback passed to legacy hydrate() API', () => {
259
container.innerHTML = '<div>Hi</div>';
260
ReactDOM.hydrate(<div>Hi</div>, container, () => {
261
- Scheduler.unstable_yieldValue('callback');
261
+ Scheduler.log('callback');
262
});
263
expect(container.textContent).toEqual('Hi');
264
assertLog(['callback']);
@@ -394,7 +394,7 @@ describe('ReactDOMRoot', () => {
394
});
395
396
function Foo({value}) {
397
- Scheduler.unstable_yieldValue(value);
397
+ Scheduler.log(value);
398
return <div>{value}</div>;
399
}
400
packages/react-dom/src/__tests__/ReactDOMServerIntegrationHooks-test.js
+21
-21
@@ -32,7 +32,7 @@ let useDebugValue;
32
let forwardRef;
33
let yieldedValues;
34
let yieldValue;
35
-let clearYields;
35
+let clearLog;
36
37
function initModules() {
38
// Reset warning cache.
@@ -59,7 +59,7 @@ function initModules() {
59
yieldValue = value => {
60
yieldedValues.push(value);
61
};
62
- clearYields = () => {
62
+ clearLog = () => {
63
const ret = yieldedValues;
64
yieldedValues = [];
65
return ret;
@@ -207,7 +207,7 @@ describe('ReactDOMServerHooks', () => {
207
208
const domNode = await render(<Counter />);
209
210
- expect(clearYields()).toEqual(['Render: 0', 0]);
210
+ expect(clearLog()).toEqual(['Render: 0', 0]);
211
expect(domNode.tagName).toEqual('SPAN');
212
expect(domNode.textContent).toEqual('0');
213
});
@@ -224,7 +224,7 @@ describe('ReactDOMServerHooks', () => {
224
225
const domNode = await render(<Counter />);
226
227
- expect(clearYields()).toEqual(['Render: 1', 1]);
227
+ expect(clearLog()).toEqual(['Render: 1', 1]);
228
expect(domNode.tagName).toEqual('SPAN');
229
expect(domNode.textContent).toEqual('1');
230
});
@@ -246,7 +246,7 @@ describe('ReactDOMServerHooks', () => {
246
247
const domNode = await render(<Counter />);
248
249
- expect(clearYields()).toEqual([
249
+ expect(clearLog()).toEqual([
250
'Render: 0',
251
'Render: 1',
252
'Render: 2',
@@ -299,7 +299,7 @@ describe('ReactDOMServerHooks', () => {
299
300
const domNode = await render(<Counter />);
301
302
- expect(clearYields()).toEqual([
302
+ expect(clearLog()).toEqual([
303
// The count should increase by alternating amounts of 10 and 1
304
// until we reach 21.
305
'Render: 0',
@@ -326,7 +326,7 @@ describe('ReactDOMServerHooks', () => {
326
}
327
328
const domNode = await render(<CapitalizedText text="hello" />);
329
- expect(clearYields()).toEqual(["Capitalize 'hello'", 'HELLO']);
329
+ expect(clearLog()).toEqual(["Capitalize 'hello'", 'HELLO']);
330
expect(domNode.tagName).toEqual('SPAN');
331
expect(domNode.textContent).toEqual('HELLO');
332
});
@@ -343,7 +343,7 @@ describe('ReactDOMServerHooks', () => {
343
}
344
345
const domNode = await render(<LazyCompute compute={computeA} />);
346
- expect(clearYields()).toEqual(['compute A', 'A']);
346
+ expect(clearLog()).toEqual(['compute A', 'A']);
347
expect(domNode.tagName).toEqual('SPAN');
348
expect(domNode.textContent).toEqual('A');
349
});
@@ -365,7 +365,7 @@ describe('ReactDOMServerHooks', () => {
365
}
366
367
const domNode = await render(<CapitalizedText text="hello" />);
368
- expect(clearYields()).toEqual([
368
+ expect(clearLog()).toEqual([
369
"Capitalize 'hello'",
370
"Capitalize 'hello, world.'",
371
'HELLO, WORLD.',
@@ -399,7 +399,7 @@ describe('ReactDOMServerHooks', () => {
399
}
400
401
const domNode = await render(<CapitalizedText text="hello" />);
402
- expect(clearYields()).toEqual([
402
+ expect(clearLog()).toEqual([
403
"Capitalize 'hello'",
404
0,
405
1,
@@ -470,7 +470,7 @@ describe('ReactDOMServerHooks', () => {
470
}
471
472
const domNode = await render(<Counter />);
473
- expect(clearYields()).toEqual([0, 1, 2, 3]);
473
+ expect(clearLog()).toEqual([0, 1, 2, 3]);
474
expect(domNode.textContent).toEqual('Count: 3');
475
},
476
);
@@ -500,7 +500,7 @@ describe('ReactDOMServerHooks', () => {
500
}
501
502
const domNode = await render(<Counter />);
503
- expect(clearYields()).toEqual([0, 1, 2, 3]);
503
+ expect(clearLog()).toEqual([0, 1, 2, 3]);
504
expect(domNode.textContent).toEqual('Count: 3');
505
},
506
);
@@ -517,7 +517,7 @@ describe('ReactDOMServerHooks', () => {
517
}
518
519
const domNode = await render(<Counter count={0} />);
520
- yields.push(clearYields());
520
+ yields.push(clearLog());
521
expect(domNode.tagName).toEqual('SPAN');
522
expect(domNode.textContent).toEqual('Count: 0');
523
});
@@ -542,7 +542,7 @@ describe('ReactDOMServerHooks', () => {
542
return <Text text={'Count: ' + props.count} />;
543
}
544
const domNode = await render(<Counter count={0} />);
545
- expect(clearYields()).toEqual(['Count: 0']);
545
+ expect(clearLog()).toEqual(['Count: 0']);
546
expect(domNode.tagName).toEqual('SPAN');
547
expect(domNode.textContent).toEqual('Count: 0');
548
});
@@ -555,7 +555,7 @@ describe('ReactDOMServerHooks', () => {
555
return <Text text={renderCount(3)} />;
556
}
557
const domNode = await render(<Counter count={2} />);
558
- expect(clearYields()).toEqual(['Count: 5']);
558
+ expect(clearLog()).toEqual(['Count: 5']);
559
expect(domNode.tagName).toEqual('SPAN');
560
expect(domNode.textContent).toEqual('Count: 5');
561
});
@@ -578,7 +578,7 @@ describe('ReactDOMServerHooks', () => {
578
}
579
580
const domNode = await render(<CapitalizedText text="hello" />);
581
- const [first, second, third, fourth, result] = clearYields();
581
+ const [first, second, third, fourth, result] = clearLog();
582
expect(first).toBe(second);
583
expect(second).toBe(third);
584
expect(third).not.toBe(fourth);
@@ -603,7 +603,7 @@ describe('ReactDOMServerHooks', () => {
603
const domNode = await serverRender(
604
<Counter label="Count" ref={counter} />,
605
);
606
- expect(clearYields()).toEqual(['Count: 0']);
606
+ expect(clearLog()).toEqual(['Count: 0']);
607
expect(domNode.tagName).toEqual('SPAN');
608
expect(domNode.textContent).toEqual('Count: 0');
609
});
@@ -618,7 +618,7 @@ describe('ReactDOMServerHooks', () => {
618
return <Text text="Count: 0" />;
619
}
620
const domNode = await serverRender(<Counter />, 1);
621
- expect(clearYields()).toEqual(['Count: 0']);
621
+ expect(clearLog()).toEqual(['Count: 0']);
622
expect(domNode.tagName).toEqual('SPAN');
623
expect(domNode.textContent).toEqual('Count: 0');
624
});
@@ -634,7 +634,7 @@ describe('ReactDOMServerHooks', () => {
634
return <Text text="Count: 0" />;
635
}
636
const domNode = await serverRender(<Counter />, 1);
637
- expect(clearYields()).toEqual(['Count: 0']);
637
+ expect(clearLog()).toEqual(['Count: 0']);
638
expect(domNode.tagName).toEqual('SPAN');
639
expect(domNode.textContent).toEqual('Count: 0');
640
});
@@ -738,7 +738,7 @@ describe('ReactDOMServerHooks', () => {
738
}
739
740
const domNode = await render(<App foo={1} bar={3} baz={5} />);
741
- expect(clearYields()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
741
+ expect(clearLog()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
742
expect(domNode.childNodes.length).toBe(2);
743
expect(domNode.firstChild.tagName).toEqual('SPAN');
744
expect(domNode.firstChild.textContent).toEqual('Foo: 1, Bar: 3');
@@ -834,7 +834,7 @@ describe('ReactDOMServerHooks', () => {
834
}
835
836
const domNode = await render(<App foo={1} bar={3} baz={5} />);
837
- expect(clearYields()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
837
+ expect(clearLog()).toEqual(['Foo: 1, Bar: 3', 'Baz: 5']);
838
expect(domNode.childNodes.length).toBe(2);
839
expect(domNode.firstChild.tagName).toEqual('SPAN');
840
expect(domNode.firstChild.textContent).toEqual('Foo: 1, Bar: 3');
packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js
+9
-11
@@ -19,8 +19,8 @@ let ReactTestUtils;
19
let forwardRef;
20
let memo;
21
let yieldedValues;
22
-let unstable_yieldValue;
23
-let clearYields;
22
+let log;
23
+let clearLog;
24
25
function initModules() {
26
// Reset warning cache.
@@ -33,10 +33,10 @@ function initModules() {
33
memo = React.memo;
34
35
yieldedValues = [];
36
- unstable_yieldValue = value => {
36
+ log = value => {
37
yieldedValues.push(value);
38
};
39
- clearYields = () => {
39
+ clearLog = () => {
40
const ret = yieldedValues;
41
yieldedValues = [];
42
return ret;
@@ -93,7 +93,7 @@ describe('ReactDOMServerIntegration', () => {
93
});
94
95
function Text({text}) {
96
- unstable_yieldValue(text);
96
+ log(text);
97
return <span>{text}</span>;
98
}
99
@@ -115,27 +115,25 @@ describe('ReactDOMServerIntegration', () => {
115
ref.current = 0;
116
await render(<MemoRefCounter ref={ref} />);
117
118
- expect(clearYields()).toEqual(['Count: 0']);
118
+ expect(clearLog()).toEqual(['Count: 0']);
119
});
120
121
itRenders('with comparator', async render => {
122
const MemoCounter = memo(Counter, (oldProps, newProps) => false);
123
await render(<MemoCounter count={0} />);
124
- expect(clearYields()).toEqual(['Count: 0']);
124
+ expect(clearLog()).toEqual(['Count: 0']);
125
});
126
127
itRenders(
128
'comparator functions are not invoked on the server',
129
async render => {
130
const MemoCounter = React.memo(Counter, (oldProps, newProps) => {
131
- unstable_yieldValue(
132
- `Old count: ${oldProps.count}, New count: ${newProps.count}`,
133
- );
131
+ log(`Old count: ${oldProps.count}, New count: ${newProps.count}`);
132
return oldProps.count === newProps.count;
133
});
134
135
await render(<MemoCounter count={0} />);
138
- expect(clearYields()).toEqual(['Count: 0']);
136
+ expect(clearLog()).toEqual(['Count: 0']);
137
},
138
);
139
});
packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+31
-35
@@ -234,7 +234,7 @@ describe('ReactDOMServerPartialHydration', () => {
234
suspend = true;
235
ReactDOMClient.hydrateRoot(container, <App />, {
236
onRecoverableError(error) {
237
- Scheduler.unstable_yieldValue(error.message);
237
+ Scheduler.log(error.message);
238
},
239
});
240
Scheduler.unstable_flushAll();
@@ -271,15 +271,15 @@ describe('ReactDOMServerPartialHydration', () => {
271
});
272
function Child() {
273
if (suspend) {
274
- Scheduler.unstable_yieldValue('Suspend');
274
+ Scheduler.log('Suspend');
275
throw promise;
276
} else {
277
- Scheduler.unstable_yieldValue('Hello');
277
+ Scheduler.log('Hello');
278
return 'Hello';
279
}
280
}
281
function Component({shouldMismatch}) {
282
- Scheduler.unstable_yieldValue('Component');
282
+ Scheduler.log('Component');
283
if (shouldMismatch && client) {
284
return <article>Mismatch</article>;
285
}
@@ -311,7 +311,7 @@ describe('ReactDOMServerPartialHydration', () => {
311
312
ReactDOMClient.hydrateRoot(container, <App />, {
313
onRecoverableError(error) {
314
- Scheduler.unstable_yieldValue(error.message);
314
+ Scheduler.log(error.message);
315
},
316
});
317
await waitForAll([
@@ -435,7 +435,7 @@ describe('ReactDOMServerPartialHydration', () => {
435
deleted.push(node);
436
},
437
onRecoverableError(error) {
438
- Scheduler.unstable_yieldValue(error.message);
438
+ Scheduler.log(error.message);
439
},
440
});
441
await waitForAll([]);
@@ -513,7 +513,7 @@ describe('ReactDOMServerPartialHydration', () => {
513
act(() => {
514
ReactDOMClient.hydrateRoot(container, <App hasB={false} />, {
515
onRecoverableError(error) {
516
- Scheduler.unstable_yieldValue(error.message);
516
+ Scheduler.log(error.message);
517
},
518
});
519
});
@@ -639,7 +639,7 @@ describe('ReactDOMServerPartialHydration', () => {
639
act(() => {
640
ReactDOMClient.hydrateRoot(container, <App hasB={false} />, {
641
onRecoverableError(error) {
642
- Scheduler.unstable_yieldValue(error.message);
642
+ Scheduler.log(error.message);
643
},
644
});
645
});
@@ -1086,7 +1086,7 @@ describe('ReactDOMServerPartialHydration', () => {
1086
<App text="Hello" className="hello" />,
1087
{
1088
onRecoverableError(error) {
1089
- Scheduler.unstable_yieldValue(error.message);
1089
+ Scheduler.log(error.message);
1090
},
1091
},
1092
);
@@ -1165,7 +1165,7 @@ describe('ReactDOMServerPartialHydration', () => {
1165
<App text="Hello" className="hello" />,
1166
{
1167
onRecoverableError(error) {
1168
- Scheduler.unstable_yieldValue(error.message);
1168
+ Scheduler.log(error.message);
1169
},
1170
},
1171
);
@@ -1242,7 +1242,7 @@ describe('ReactDOMServerPartialHydration', () => {
1242
<App text="Hello" className="hello" />,
1243
{
1244
onRecoverableError(error) {
1245
- Scheduler.unstable_yieldValue(error.message);
1245
+ Scheduler.log(error.message);
1246
},
1247
},
1248
);
@@ -1367,7 +1367,7 @@ describe('ReactDOMServerPartialHydration', () => {
1367
function Child() {
1368
const [state, setState] = React.useState('Hello');
1369
updateText = setState;
1370
- Scheduler.unstable_yieldValue('Child');
1370
+ Scheduler.log('Child');
1371
if (suspend) {
1372
throw promise;
1373
} else {
@@ -1376,7 +1376,7 @@ describe('ReactDOMServerPartialHydration', () => {
1376
}
1377
1378
function Sibling() {
1379
- Scheduler.unstable_yieldValue('Sibling');
1379
+ Scheduler.log('Sibling');
1380
return null;
1381
}
1382
@@ -1559,7 +1559,7 @@ describe('ReactDOMServerPartialHydration', () => {
1559
</Context.Provider>,
1560
{
1561
onRecoverableError(error) {
1562
- Scheduler.unstable_yieldValue(error.message);
1562
+ Scheduler.log(error.message);
1563
},
1564
},
1565
);
@@ -1635,7 +1635,7 @@ describe('ReactDOMServerPartialHydration', () => {
1635
suspend = false;
1636
ReactDOMClient.hydrateRoot(container, <App />, {
1637
onRecoverableError(error) {
1638
- Scheduler.unstable_yieldValue(error.message);
1638
+ Scheduler.log(error.message);
1639
},
1640
});
1641
if (__DEV__) {
@@ -1708,7 +1708,7 @@ describe('ReactDOMServerPartialHydration', () => {
1708
suspend = false;
1709
ReactDOMClient.hydrateRoot(container, <App />, {
1710
onRecoverableError(error) {
1711
- Scheduler.unstable_yieldValue(error.message);
1711
+ Scheduler.log(error.message);
1712
},
1713
});
1714
if (__DEV__) {
@@ -1786,7 +1786,7 @@ describe('ReactDOMServerPartialHydration', () => {
1786
suspend = false;
1787
ReactDOMClient.hydrateRoot(container, <App />, {
1788
onRecoverableError(error) {
1789
- Scheduler.unstable_yieldValue(error.message);
1789
+ Scheduler.log(error.message);
1790
},
1791
});
1792
if (__DEV__) {
@@ -1994,12 +1994,12 @@ describe('ReactDOMServerPartialHydration', () => {
1994
}
1995
1996
function Before() {
1997
- Scheduler.unstable_yieldValue('Before');
1997
+ Scheduler.log('Before');
1998
return null;
1999
}
2000
2001
function After() {
2002
- Scheduler.unstable_yieldValue('After');
2002
+ Scheduler.log('After');
2003
return null;
2004
}
2005
@@ -2106,7 +2106,7 @@ describe('ReactDOMServerPartialHydration', () => {
2106
2107
ReactDOMClient.hydrateRoot(container, <App />, {
2108
onRecoverableError(error) {
2109
- Scheduler.unstable_yieldValue(error.message);
2109
+ Scheduler.log(error.message);
2110
},
2111
});
2112
@@ -2182,7 +2182,7 @@ describe('ReactDOMServerPartialHydration', () => {
2182
suspend = false;
2183
ReactDOMClient.hydrateRoot(container, <App />, {
2184
onRecoverableError(error) {
2185
- Scheduler.unstable_yieldValue(error.message);
2185
+ Scheduler.log(error.message);
2186
},
2187
});
2188
if (__DEV__) {
@@ -2299,7 +2299,7 @@ describe('ReactDOMServerPartialHydration', () => {
2299
</ClassName.Provider>,
2300
{
2301
onRecoverableError(error) {
2302
- Scheduler.unstable_yieldValue(error.message);
2302
+ Scheduler.log(error.message);
2303
},
2304
},
2305
);
@@ -2980,15 +2980,15 @@ describe('ReactDOMServerPartialHydration', () => {
2980
if (suspend) {
2981
throw promise;
2982
} else {
2983
- Scheduler.unstable_yieldValue('Child');
2983
+ Scheduler.log('Child');
2984
return 'Hello';
2985
}
2986
}
2987
2988
function Sibling() {
2989
- Scheduler.unstable_yieldValue('Sibling');
2989
+ Scheduler.log('Sibling');
2990
React.useLayoutEffect(() => {
2991
- Scheduler.unstable_yieldValue('Commit Sibling');
2991
+ Scheduler.log('Commit Sibling');
2992
});
2993
return 'World';
2994
}
@@ -3175,9 +3175,7 @@ describe('ReactDOMServerPartialHydration', () => {
3175
3176
ReactDOMClient.hydrateRoot(container, <App />, {
3177
onRecoverableError(error) {
3178
- Scheduler.unstable_yieldValue(
3179
- 'Log recoverable error: ' + error.message,
3180
- );
3178
+ Scheduler.log('Log recoverable error: ' + error.message);
3179
},
3180
});
3181
@@ -3280,12 +3278,12 @@ describe('ReactDOMServerPartialHydration', () => {
3278
const visibleRef = React.createRef();
3279
3280
function HiddenChild() {
3283
- Scheduler.unstable_yieldValue('HiddenChild');
3281
+ Scheduler.log('HiddenChild');
3282
return <span>Hidden</span>;
3283
}
3284
3285
function App() {
3288
- Scheduler.unstable_yieldValue('App');
3286
+ Scheduler.log('App');
3287
return (
3288
<>
3289
<span ref={visibleRef}>Visible</span>
@@ -3422,9 +3420,7 @@ describe('ReactDOMServerPartialHydration', () => {
3420
act(() => {
3421
ReactDOMClient.hydrateRoot(container, <App />, {
3422
onRecoverableError(error) {
3425
- Scheduler.unstable_yieldValue(
3426
- 'Log recoverable error: ' + error.message,
3427
- );
3423
+ Scheduler.log('Log recoverable error: ' + error.message);
3424
},
3425
});
3426
});
@@ -3474,7 +3470,7 @@ describe('ReactDOMServerPartialHydration', () => {
3470
act(() => {
3471
ReactDOMClient.hydrateRoot(container, <DirectTextChild text="bad" />, {
3472
onRecoverableError(error) {
3477
- Scheduler.unstable_yieldValue(error.message);
3473
+ Scheduler.log(error.message);
3474
},
3475
});
3476
});
@@ -3518,7 +3514,7 @@ describe('ReactDOMServerPartialHydration', () => {
3514
<TextChildWithSibling text="bad" />,
3515
{
3516
onRecoverableError(error) {
3521
- Scheduler.unstable_yieldValue(error.message);
3517
+ Scheduler.log(error.message);
3518
},
3519
},
3520
);
packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
+96
-98
@@ -154,12 +154,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
154
155
it('hydrates the target boundary synchronously during a click', async () => {
156
function Child({text}) {
157
- Scheduler.unstable_yieldValue(text);
157
+ Scheduler.log(text);
158
return (
159
<span
160
onClick={e => {
161
e.preventDefault();
162
- Scheduler.unstable_yieldValue('Clicked ' + text);
162
+ Scheduler.log('Clicked ' + text);
163
}}>
164
{text}
165
</span>
@@ -167,7 +167,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
167
}
168
169
function App() {
170
- Scheduler.unstable_yieldValue('App');
170
+ Scheduler.log('App');
171
return (
172
<div>
173
<Suspense fallback="Loading...">
@@ -222,12 +222,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
222
if ((text === 'A' || text === 'D') && suspend) {
223
throw promise;
224
}
225
- Scheduler.unstable_yieldValue(text);
225
+ Scheduler.log(text);
226
return (
227
<span
228
onClick={e => {
229
e.preventDefault();
230
- Scheduler.unstable_yieldValue('Clicked ' + text);
230
+ Scheduler.log('Clicked ' + text);
231
}}>
232
{text}
233
</span>
@@ -235,7 +235,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
235
}
236
237
function App() {
238
- Scheduler.unstable_yieldValue('App');
238
+ Scheduler.log('App');
239
return (
240
<div>
241
<Suspense fallback="Loading...">
@@ -318,12 +318,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
318
if ((text === 'A' || text === 'D') && suspend) {
319
throw promise;
320
}
321
- Scheduler.unstable_yieldValue(text);
321
+ Scheduler.log(text);
322
return (
323
<span
324
onClick={e => {
325
e.preventDefault();
326
- Scheduler.unstable_yieldValue('Clicked ' + text);
326
+ Scheduler.log('Clicked ' + text);
327
}}>
328
{text}
329
</span>
@@ -331,7 +331,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
331
}
332
333
function App() {
334
- Scheduler.unstable_yieldValue('App');
334
+ Scheduler.log('App');
335
return (
336
<div>
337
<Suspense fallback="Loading...">
@@ -429,11 +429,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
429
430
function Child({text}) {
431
const ref = React.useRef(null);
432
- Scheduler.unstable_yieldValue(text);
432
+ Scheduler.log(text);
433
if (!isServerRendering) {
434
React.useLayoutEffect(() => {
435
return setClick(ref.current, () => {
436
- Scheduler.unstable_yieldValue('Clicked ' + text);
436
+ Scheduler.log('Clicked ' + text);
437
});
438
});
439
}
@@ -442,7 +442,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
442
}
443
444
function App() {
445
- Scheduler.unstable_yieldValue('App');
445
+ Scheduler.log('App');
446
return (
447
<div>
448
<Suspense fallback="Loading...">
@@ -502,12 +502,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
502
if ((text === 'A' || text === 'D') && suspend) {
503
throw promise;
504
}
505
- Scheduler.unstable_yieldValue(text);
505
+ Scheduler.log(text);
506
507
if (!isServerRendering) {
508
React.useLayoutEffect(() => {
509
return setClick(ref.current, () => {
510
- Scheduler.unstable_yieldValue('Clicked ' + text);
510
+ Scheduler.log('Clicked ' + text);
511
});
512
});
513
}
@@ -516,7 +516,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
516
}
517
518
function App() {
519
- Scheduler.unstable_yieldValue('App');
519
+ Scheduler.log('App');
520
return (
521
<div>
522
<Suspense fallback="Loading...">
@@ -599,12 +599,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
599
if ((text === 'A' || text === 'D') && suspend) {
600
throw promise;
601
}
602
- Scheduler.unstable_yieldValue(text);
602
+ Scheduler.log(text);
603
604
if (!isServerRendering) {
605
React.useLayoutEffect(() => {
606
return setClick(ref.current, () => {
607
- Scheduler.unstable_yieldValue('Clicked ' + text);
607
+ Scheduler.log('Clicked ' + text);
608
});
609
});
610
}
@@ -612,7 +612,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
612
}
613
614
function App() {
615
- Scheduler.unstable_yieldValue('App');
615
+ Scheduler.log('App');
616
return (
617
<div>
618
<Suspense fallback="Loading...">
@@ -708,16 +708,16 @@ describe('ReactDOMServerSelectiveHydration', () => {
708
if ((text === 'A' || text === 'D') && suspend) {
709
throw promise;
710
}
711
- Scheduler.unstable_yieldValue(text);
711
+ Scheduler.log(text);
712
return (
713
<span
714
onClick={e => {
715
e.preventDefault();
716
- Scheduler.unstable_yieldValue('Clicked ' + text);
716
+ Scheduler.log('Clicked ' + text);
717
}}
718
onMouseEnter={e => {
719
e.preventDefault();
720
- Scheduler.unstable_yieldValue('Hover ' + text);
720
+ Scheduler.log('Hover ' + text);
721
}}>
722
{text}
723
</span>
@@ -725,7 +725,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
725
}
726
727
function App() {
728
- Scheduler.unstable_yieldValue('App');
728
+ Scheduler.log('App');
729
return (
730
<div>
731
<Suspense fallback="Loading...">
@@ -819,44 +819,44 @@ describe('ReactDOMServerSelectiveHydration', () => {
819
if ((text === 'A' || text === 'D') && suspend) {
820
throw promise;
821
}
822
- Scheduler.unstable_yieldValue(text);
822
+ Scheduler.log(text);
823
return (
824
<span
825
id={text}
826
onClickCapture={e => {
827
e.preventDefault();
828
- Scheduler.unstable_yieldValue('Capture Clicked ' + text);
828
+ Scheduler.log('Capture Clicked ' + text);
829
}}
830
onClick={e => {
831
e.preventDefault();
832
- Scheduler.unstable_yieldValue('Clicked ' + text);
832
+ Scheduler.log('Clicked ' + text);
833
}}
834
onMouseEnter={e => {
835
e.preventDefault();
836
- Scheduler.unstable_yieldValue('Mouse Enter ' + text);
836
+ Scheduler.log('Mouse Enter ' + text);
837
}}
838
onMouseOut={e => {
839
e.preventDefault();
840
- Scheduler.unstable_yieldValue('Mouse Out ' + text);
840
+ Scheduler.log('Mouse Out ' + text);
841
}}
842
onMouseOutCapture={e => {
843
e.preventDefault();
844
e.stopPropagation();
845
- Scheduler.unstable_yieldValue('Mouse Out Capture ' + text);
845
+ Scheduler.log('Mouse Out Capture ' + text);
846
}}
847
onMouseOverCapture={e => {
848
e.preventDefault();
849
e.stopPropagation();
850
- Scheduler.unstable_yieldValue('Mouse Over Capture ' + text);
850
+ Scheduler.log('Mouse Over Capture ' + text);
851
}}
852
onMouseOver={e => {
853
e.preventDefault();
854
- Scheduler.unstable_yieldValue('Mouse Over ' + text);
854
+ Scheduler.log('Mouse Over ' + text);
855
}}>
856
<div
857
onMouseOverCapture={e => {
858
e.preventDefault();
859
- Scheduler.unstable_yieldValue('Mouse Over Capture Inner ' + text);
859
+ Scheduler.log('Mouse Over Capture Inner ' + text);
860
}}>
861
{text}
862
</div>
@@ -865,15 +865,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
865
}
866
867
function App() {
868
- Scheduler.unstable_yieldValue('App');
868
+ Scheduler.log('App');
869
return (
870
<div
871
onClickCapture={e => {
872
e.preventDefault();
873
- Scheduler.unstable_yieldValue('Capture Clicked Parent');
873
+ Scheduler.log('Capture Clicked Parent');
874
}}
875
onMouseOverCapture={e => {
876
- Scheduler.unstable_yieldValue('Mouse Over Capture Parent');
876
+ Scheduler.log('Mouse Over Capture Parent');
877
}}>
878
<Suspense fallback="Loading...">
879
<Child text="A" />
@@ -1028,16 +1028,16 @@ describe('ReactDOMServerSelectiveHydration', () => {
1028
1029
function Outer() {
1030
if (suspendOuter) {
1031
- OuterScheduler.unstable_yieldValue('Suspend Outer');
1031
+ OuterScheduler.log('Suspend Outer');
1032
throw outerPromise;
1033
}
1034
- OuterScheduler.unstable_yieldValue('Outer');
1034
+ OuterScheduler.log('Outer');
1035
const innerRoot = outerContainer.querySelector('#inner-root');
1036
return (
1037
<div
1038
id="inner-root"
1039
onMouseEnter={() => {
1040
- Scheduler.unstable_yieldValue('Outer Mouse Enter');
1040
+ Scheduler.log('Outer Mouse Enter');
1041
}}
1042
dangerouslySetInnerHTML={{
1043
__html: innerRoot ? innerRoot.innerHTML : '',
@@ -1062,15 +1062,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
1062
});
1063
function Inner() {
1064
if (suspendInner) {
1065
- InnerScheduler.unstable_yieldValue('Suspend Inner');
1065
+ InnerScheduler.log('Suspend Inner');
1066
throw innerPromise;
1067
}
1068
- InnerScheduler.unstable_yieldValue('Inner');
1068
+ InnerScheduler.log('Inner');
1069
return (
1070
<div
1071
id="inner"
1072
onMouseEnter={() => {
1073
- Scheduler.unstable_yieldValue('Inner Mouse Enter');
1073
+ Scheduler.log('Inner Mouse Enter');
1074
}}
1075
/>
1076
);
@@ -1092,8 +1092,8 @@ describe('ReactDOMServerSelectiveHydration', () => {
1092
const innerHTML = ReactDOMServer.renderToString(<InnerApp />);
1093
innerContainer.innerHTML = innerHTML;
1094
1095
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
1096
- expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
1095
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
1096
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
1097
1098
suspendOuter = true;
1099
suspendInner = true;
@@ -1103,8 +1103,8 @@ describe('ReactDOMServerSelectiveHydration', () => {
1103
1104
OuterScheduler.unstable_flushAllWithoutAsserting();
1105
InnerScheduler.unstable_flushAllWithoutAsserting();
1106
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
1107
- expect(InnerScheduler.unstable_clearYields()).toEqual(['Suspend Inner']);
1106
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
1107
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
1108
1109
innerDiv = document.querySelector('#inner');
1110
@@ -1117,7 +1117,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1117
InnerScheduler.unstable_flushAllWithoutAsserting();
1118
});
1119
1120
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
1120
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
1121
if (
1122
gate(
1123
flags =>
@@ -1126,12 +1126,10 @@ describe('ReactDOMServerSelectiveHydration', () => {
1126
) {
1127
// InnerApp doesn't see the event because OuterApp calls stopPropagation in
1128
// capture phase since the event is blocked on suspended component
1129
- expect(InnerScheduler.unstable_clearYields()).toEqual([]);
1129
+ expect(InnerScheduler.unstable_clearLog()).toEqual([]);
1130
} else {
1131
// no stopPropagation
1132
- expect(InnerScheduler.unstable_clearYields()).toEqual([
1133
- 'Suspend Inner',
1134
- ]);
1132
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
1133
}
1134
1135
assertLog([]);
@@ -1153,15 +1151,15 @@ describe('ReactDOMServerSelectiveHydration', () => {
1151
InnerScheduler.unstable_flushAllWithoutAsserting();
1152
});
1153
1156
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Suspend Outer']);
1154
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Suspend Outer']);
1155
// Inner App renders because it is unblocked
1158
- expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
1156
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
1157
// No event is replayed yet
1158
assertLog([]);
1159
1160
dispatchMouseHoverEvent(innerDiv);
1163
- expect(OuterScheduler.unstable_clearYields()).toEqual([]);
1164
- expect(InnerScheduler.unstable_clearYields()).toEqual([]);
1161
+ expect(OuterScheduler.unstable_clearLog()).toEqual([]);
1162
+ expect(InnerScheduler.unstable_clearLog()).toEqual([]);
1163
// No event is replayed yet
1164
assertLog([]);
1165
@@ -1176,9 +1174,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1174
1175
// Nothing happens to inner app yet.
1176
// Its blocked on the outer app replaying the event
1179
- expect(InnerScheduler.unstable_clearYields()).toEqual([]);
1177
+ expect(InnerScheduler.unstable_clearLog()).toEqual([]);
1178
// Outer hydrates and schedules Replay
1181
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
1179
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
1180
// No event is replayed yet
1181
assertLog([]);
1182
@@ -1207,9 +1205,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1205
});
1206
1207
// Outer resolves and scheduled replay
1210
- expect(OuterScheduler.unstable_clearYields()).toEqual(['Outer']);
1208
+ expect(OuterScheduler.unstable_clearLog()).toEqual(['Outer']);
1209
// Inner App is still blocked
1212
- expect(InnerScheduler.unstable_clearYields()).toEqual([]);
1210
+ expect(InnerScheduler.unstable_clearLog()).toEqual([]);
1211
1212
// Replay outer event
1213
await act(async () => {
@@ -1221,12 +1219,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1219
// Inner is still blocked so when Outer replays the event in capture phase
1220
// inner ends up caling stopPropagation
1221
assertLog([]);
1224
- expect(OuterScheduler.unstable_clearYields()).toEqual([]);
1225
- expect(InnerScheduler.unstable_clearYields()).toEqual(['Suspend Inner']);
1222
+ expect(OuterScheduler.unstable_clearLog()).toEqual([]);
1223
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Suspend Inner']);
1224
1225
dispatchMouseHoverEvent(innerDiv);
1228
- expect(OuterScheduler.unstable_clearYields()).toEqual([]);
1229
- expect(InnerScheduler.unstable_clearYields()).toEqual([]);
1226
+ expect(OuterScheduler.unstable_clearLog()).toEqual([]);
1227
+ expect(InnerScheduler.unstable_clearLog()).toEqual([]);
1228
assertLog([]);
1229
1230
await act(async () => {
@@ -1238,9 +1236,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1236
});
1237
1238
// Inner hydrates
1241
- expect(InnerScheduler.unstable_clearYields()).toEqual(['Inner']);
1239
+ expect(InnerScheduler.unstable_clearLog()).toEqual(['Inner']);
1240
// Outer was hydrated earlier
1243
- expect(OuterScheduler.unstable_clearYields()).toEqual([]);
1241
+ expect(OuterScheduler.unstable_clearLog()).toEqual([]);
1242
1243
await act(async () => {
1244
Scheduler.unstable_flushAllWithoutAsserting();
@@ -1268,11 +1266,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
1266
if (suspend) {
1267
throw promise;
1268
}
1271
- Scheduler.unstable_yieldValue('Child');
1269
+ Scheduler.log('Child');
1270
return (
1271
<div
1272
onMouseOver={() => {
1275
- Scheduler.unstable_yieldValue('on mouse over');
1273
+ Scheduler.log('on mouse over');
1274
}}>
1275
Child
1276
</div>
@@ -1315,7 +1313,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1313
1314
const container2 = document.createElement('div');
1315
container2.addEventListener('mouseover', () => {
1318
- Scheduler.unstable_yieldValue('container2 mouse over');
1316
+ Scheduler.log('container2 mouse over');
1317
});
1318
container2.appendChild(childDiv);
1319
},
@@ -1338,12 +1336,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1336
if ((text === 'A' || text === 'D') && suspend) {
1337
throw promise;
1338
}
1341
- Scheduler.unstable_yieldValue(text);
1339
+ Scheduler.log(text);
1340
return (
1341
<span
1342
onMouseEnter={e => {
1343
e.preventDefault();
1346
- Scheduler.unstable_yieldValue('Hover ' + text);
1344
+ Scheduler.log('Hover ' + text);
1345
}}>
1346
{text}
1347
</span>
@@ -1351,7 +1349,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1349
}
1350
1351
function App() {
1354
- Scheduler.unstable_yieldValue('App');
1352
+ Scheduler.log('App');
1353
return (
1354
<div>
1355
<Suspense fallback="Loading...">
@@ -1417,12 +1415,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1415
1416
it('hydrates the last explicitly hydrated target at higher priority', async () => {
1417
function Child({text}) {
1420
- Scheduler.unstable_yieldValue(text);
1418
+ Scheduler.log(text);
1419
return <span>{text}</span>;
1420
}
1421
1422
function App() {
1425
- Scheduler.unstable_yieldValue('App');
1423
+ Scheduler.log('App');
1424
return (
1425
<div>
1426
<Suspense fallback="Loading...">
@@ -1465,7 +1463,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1463
// @gate experimental || www
1464
it('hydrates before an update even if hydration moves away from it', async () => {
1465
function Child({text}) {
1468
- Scheduler.unstable_yieldValue(text);
1466
+ Scheduler.log(text);
1467
return <span>{text}</span>;
1468
}
1469
const ChildWithBoundary = React.memo(function ({text}) {
@@ -1478,9 +1476,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1476
});
1477
1478
function App({a}) {
1481
- Scheduler.unstable_yieldValue('App');
1479
+ Scheduler.log('App');
1480
React.useEffect(() => {
1483
- Scheduler.unstable_yieldValue('Commit');
1481
+ Scheduler.log('Commit');
1482
});
1483
return (
1484
<div>
@@ -1574,24 +1572,24 @@ describe('ReactDOMServerSelectiveHydration', () => {
1572
it('fires capture event handlers and native events if content is hydratable during discrete event', async () => {
1573
spyOnDev(console, 'error');
1574
function Child({text}) {
1577
- Scheduler.unstable_yieldValue(text);
1575
+ Scheduler.log(text);
1576
const ref = React.useRef();
1577
React.useLayoutEffect(() => {
1578
if (!ref.current) {
1579
return;
1580
}
1581
ref.current.onclick = () => {
1584
- Scheduler.unstable_yieldValue('Native Click ' + text);
1582
+ Scheduler.log('Native Click ' + text);
1583
};
1584
}, [text]);
1585
return (
1586
<span
1587
ref={ref}
1588
onClickCapture={() => {
1591
- Scheduler.unstable_yieldValue('Capture Clicked ' + text);
1589
+ Scheduler.log('Capture Clicked ' + text);
1590
}}
1591
onClick={e => {
1594
- Scheduler.unstable_yieldValue('Clicked ' + text);
1592
+ Scheduler.log('Clicked ' + text);
1593
}}>
1594
{text}
1595
</span>
@@ -1599,7 +1597,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1597
}
1598
1599
function App() {
1602
- Scheduler.unstable_yieldValue('App');
1600
+ Scheduler.log('App');
1601
return (
1602
<div>
1603
<Suspense fallback="Loading...">
@@ -1658,7 +1656,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1656
if (suspend) {
1657
throw promise;
1658
}
1661
- Scheduler.unstable_yieldValue('Child');
1659
+ Scheduler.log('Child');
1660
return (
1661
<span
1662
onClickCapture={e => {
@@ -1673,7 +1671,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1671
const onClick = () => {
1672
triggeredParent = true;
1673
};
1676
- Scheduler.unstable_yieldValue('App');
1674
+ Scheduler.log('App');
1675
return (
1676
<div
1677
ref={n => {
@@ -1719,12 +1717,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1717
if (suspend) {
1718
throw promise;
1719
}
1722
- Scheduler.unstable_yieldValue(text);
1720
+ Scheduler.log(text);
1721
return (
1722
<span
1723
onClick={e => {
1724
e.preventDefault();
1727
- Scheduler.unstable_yieldValue('Clicked ' + text);
1725
+ Scheduler.log('Clicked ' + text);
1726
}}>
1727
{text}
1728
</span>
@@ -1732,7 +1730,7 @@ describe('ReactDOMServerSelectiveHydration', () => {
1730
}
1731
1732
function App() {
1735
- Scheduler.unstable_yieldValue('App');
1733
+ Scheduler.log('App');
1734
return (
1735
<div>
1736
<Child text="A" />
@@ -1790,11 +1788,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
1788
1789
it('can force hydration in response to sync update', async () => {
1790
function Child({text}) {
1793
- Scheduler.unstable_yieldValue(`Child ${text}`);
1791
+ Scheduler.log(`Child ${text}`);
1792
return <span ref={ref => (spanRef = ref)}>{text}</span>;
1793
}
1794
function App({text}) {
1797
- Scheduler.unstable_yieldValue(`App ${text}`);
1795
+ Scheduler.log(`App ${text}`);
1796
return (
1797
<div>
1798
<Suspense fallback={null}>
@@ -1826,11 +1824,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
1824
// @gate experimental || www
1825
it('can force hydration in response to continuous update', async () => {
1826
function Child({text}) {
1829
- Scheduler.unstable_yieldValue(`Child ${text}`);
1827
+ Scheduler.log(`Child ${text}`);
1828
return <span ref={ref => (spanRef = ref)}>{text}</span>;
1829
}
1830
function App({text}) {
1833
- Scheduler.unstable_yieldValue(`App ${text}`);
1831
+ Scheduler.log(`App ${text}`);
1832
return (
1833
<div>
1834
<Suspense fallback={null}>
@@ -1862,11 +1860,11 @@ describe('ReactDOMServerSelectiveHydration', () => {
1860
1861
it('can force hydration in response to default update', async () => {
1862
function Child({text}) {
1865
- Scheduler.unstable_yieldValue(`Child ${text}`);
1863
+ Scheduler.log(`Child ${text}`);
1864
return <span ref={ref => (spanRef = ref)}>{text}</span>;
1865
}
1866
function App({text}) {
1869
- Scheduler.unstable_yieldValue(`App ${text}`);
1867
+ Scheduler.log(`App ${text}`);
1868
return (
1869
<div>
1870
<Suspense fallback={null}>
@@ -1898,12 +1896,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1896
1897
function ContextReader(props) {
1898
const value = React.useContext(Context);
1901
- Scheduler.unstable_yieldValue(value);
1899
+ Scheduler.log(value);
1900
return null;
1901
}
1902
1903
function Child({text}) {
1906
- Scheduler.unstable_yieldValue(text);
1904
+ Scheduler.log(text);
1905
return <span>{text}</span>;
1906
}
1907
const ChildWithBoundary = React.memo(function ({text}) {
@@ -1915,9 +1913,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1913
});
1914
1915
function App({a}) {
1918
- Scheduler.unstable_yieldValue('App');
1916
+ Scheduler.log('App');
1917
React.useEffect(() => {
1920
- Scheduler.unstable_yieldValue('Commit');
1918
+ Scheduler.log('Commit');
1919
});
1920
return (
1921
<>
@@ -1956,12 +1954,12 @@ describe('ReactDOMServerSelectiveHydration', () => {
1954
1955
function ContextReader(props) {
1956
const value = React.useContext(Context);
1959
- Scheduler.unstable_yieldValue(value);
1957
+ Scheduler.log(value);
1958
return null;
1959
}
1960
1961
function Child({text}) {
1964
- Scheduler.unstable_yieldValue(text);
1962
+ Scheduler.log(text);
1963
return <span>{text}</span>;
1964
}
1965
const ChildWithBoundary = React.memo(function ({text}) {
@@ -1973,9 +1971,9 @@ describe('ReactDOMServerSelectiveHydration', () => {
1971
});
1972
1973
function App({a}) {
1976
- Scheduler.unstable_yieldValue('App');
1974
+ Scheduler.log('App');
1975
React.useEffect(() => {
1978
- Scheduler.unstable_yieldValue('Commit');
1976
+ Scheduler.log('Commit');
1977
});
1978
return (
1979
<>
packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
+158
-294
@@ -55,202 +55,152 @@ describe('ReactErrorBoundaries', () => {
55
BrokenConstructor = class extends React.Component {
56
constructor(props) {
57
super(props);
58
- Scheduler.unstable_yieldValue('BrokenConstructor constructor [!]');
58
+ Scheduler.log('BrokenConstructor constructor [!]');
59
throw new Error('Hello');
60
}
61
render() {
62
- Scheduler.unstable_yieldValue('BrokenConstructor render');
62
+ Scheduler.log('BrokenConstructor render');
63
return <div>{this.props.children}</div>;
64
}
65
UNSAFE_componentWillMount() {
66
- Scheduler.unstable_yieldValue('BrokenConstructor componentWillMount');
66
+ Scheduler.log('BrokenConstructor componentWillMount');
67
}
68
componentDidMount() {
69
- Scheduler.unstable_yieldValue('BrokenConstructor componentDidMount');
69
+ Scheduler.log('BrokenConstructor componentDidMount');
70
}
71
UNSAFE_componentWillReceiveProps() {
72
- Scheduler.unstable_yieldValue(
73
- 'BrokenConstructor componentWillReceiveProps',
74
- );
72
+ Scheduler.log('BrokenConstructor componentWillReceiveProps');
73
}
74
UNSAFE_componentWillUpdate() {
77
- Scheduler.unstable_yieldValue('BrokenConstructor componentWillUpdate');
75
+ Scheduler.log('BrokenConstructor componentWillUpdate');
76
}
77
componentDidUpdate() {
80
- Scheduler.unstable_yieldValue('BrokenConstructor componentDidUpdate');
78
+ Scheduler.log('BrokenConstructor componentDidUpdate');
79
}
80
componentWillUnmount() {
83
- Scheduler.unstable_yieldValue('BrokenConstructor componentWillUnmount');
81
+ Scheduler.log('BrokenConstructor componentWillUnmount');
82
}
83
};
84
85
BrokenComponentWillMount = class extends React.Component {
86
constructor(props) {
87
super(props);
90
- Scheduler.unstable_yieldValue('BrokenComponentWillMount constructor');
88
+ Scheduler.log('BrokenComponentWillMount constructor');
89
}
90
render() {
93
- Scheduler.unstable_yieldValue('BrokenComponentWillMount render');
91
+ Scheduler.log('BrokenComponentWillMount render');
92
return <div>{this.props.children}</div>;
93
}
94
UNSAFE_componentWillMount() {
97
- Scheduler.unstable_yieldValue(
98
- 'BrokenComponentWillMount componentWillMount [!]',
99
- );
95
+ Scheduler.log('BrokenComponentWillMount componentWillMount [!]');
96
throw new Error('Hello');
97
}
98
componentDidMount() {
103
- Scheduler.unstable_yieldValue(
104
- 'BrokenComponentWillMount componentDidMount',
105
- );
99
+ Scheduler.log('BrokenComponentWillMount componentDidMount');
100
}
101
UNSAFE_componentWillReceiveProps() {
108
- Scheduler.unstable_yieldValue(
109
- 'BrokenComponentWillMount componentWillReceiveProps',
110
- );
102
+ Scheduler.log('BrokenComponentWillMount componentWillReceiveProps');
103
}
104
UNSAFE_componentWillUpdate() {
113
- Scheduler.unstable_yieldValue(
114
- 'BrokenComponentWillMount componentWillUpdate',
115
- );
105
+ Scheduler.log('BrokenComponentWillMount componentWillUpdate');
106
}
107
componentDidUpdate() {
118
- Scheduler.unstable_yieldValue(
119
- 'BrokenComponentWillMount componentDidUpdate',
120
- );
108
+ Scheduler.log('BrokenComponentWillMount componentDidUpdate');
109
}
110
componentWillUnmount() {
123
- Scheduler.unstable_yieldValue(
124
- 'BrokenComponentWillMount componentWillUnmount',
125
- );
111
+ Scheduler.log('BrokenComponentWillMount componentWillUnmount');
112
}
113
};
114
115
BrokenComponentDidMount = class extends React.Component {
116
constructor(props) {
117
super(props);
132
- Scheduler.unstable_yieldValue('BrokenComponentDidMount constructor');
118
+ Scheduler.log('BrokenComponentDidMount constructor');
119
}
120
render() {
135
- Scheduler.unstable_yieldValue('BrokenComponentDidMount render');
121
+ Scheduler.log('BrokenComponentDidMount render');
122
return <div>{this.props.children}</div>;
123
}
124
UNSAFE_componentWillMount() {
139
- Scheduler.unstable_yieldValue(
140
- 'BrokenComponentDidMount componentWillMount',
141
- );
125
+ Scheduler.log('BrokenComponentDidMount componentWillMount');
126
}
127
componentDidMount() {
144
- Scheduler.unstable_yieldValue(
145
- 'BrokenComponentDidMount componentDidMount [!]',
146
- );
128
+ Scheduler.log('BrokenComponentDidMount componentDidMount [!]');
129
throw new Error('Hello');
130
}
131
UNSAFE_componentWillReceiveProps() {
150
- Scheduler.unstable_yieldValue(
151
- 'BrokenComponentDidMount componentWillReceiveProps',
152
- );
132
+ Scheduler.log('BrokenComponentDidMount componentWillReceiveProps');
133
}
134
UNSAFE_componentWillUpdate() {
155
- Scheduler.unstable_yieldValue(
156
- 'BrokenComponentDidMount componentWillUpdate',
157
- );
135
+ Scheduler.log('BrokenComponentDidMount componentWillUpdate');
136
}
137
componentDidUpdate() {
160
- Scheduler.unstable_yieldValue(
161
- 'BrokenComponentDidMount componentDidUpdate',
162
- );
138
+ Scheduler.log('BrokenComponentDidMount componentDidUpdate');
139
}
140
componentWillUnmount() {
165
- Scheduler.unstable_yieldValue(
166
- 'BrokenComponentDidMount componentWillUnmount',
167
- );
141
+ Scheduler.log('BrokenComponentDidMount componentWillUnmount');
142
}
143
};
144
145
BrokenComponentWillReceiveProps = class extends React.Component {
146
constructor(props) {
147
super(props);
174
- Scheduler.unstable_yieldValue(
175
- 'BrokenComponentWillReceiveProps constructor',
176
- );
148
+ Scheduler.log('BrokenComponentWillReceiveProps constructor');
149
}
150
render() {
179
- Scheduler.unstable_yieldValue('BrokenComponentWillReceiveProps render');
151
+ Scheduler.log('BrokenComponentWillReceiveProps render');
152
return <div>{this.props.children}</div>;
153
}
154
UNSAFE_componentWillMount() {
183
- Scheduler.unstable_yieldValue(
184
- 'BrokenComponentWillReceiveProps componentWillMount',
185
- );
155
+ Scheduler.log('BrokenComponentWillReceiveProps componentWillMount');
156
}
157
componentDidMount() {
188
- Scheduler.unstable_yieldValue(
189
- 'BrokenComponentWillReceiveProps componentDidMount',
190
- );
158
+ Scheduler.log('BrokenComponentWillReceiveProps componentDidMount');
159
}
160
UNSAFE_componentWillReceiveProps() {
193
- Scheduler.unstable_yieldValue(
161
+ Scheduler.log(
162
'BrokenComponentWillReceiveProps componentWillReceiveProps [!]',
163
);
164
throw new Error('Hello');
165
}
166
UNSAFE_componentWillUpdate() {
199
- Scheduler.unstable_yieldValue(
200
- 'BrokenComponentWillReceiveProps componentWillUpdate',
201
- );
167
+ Scheduler.log('BrokenComponentWillReceiveProps componentWillUpdate');
168
}
169
componentDidUpdate() {
204
- Scheduler.unstable_yieldValue(
205
- 'BrokenComponentWillReceiveProps componentDidUpdate',
206
- );
170
+ Scheduler.log('BrokenComponentWillReceiveProps componentDidUpdate');
171
}
172
componentWillUnmount() {
209
- Scheduler.unstable_yieldValue(
210
- 'BrokenComponentWillReceiveProps componentWillUnmount',
211
- );
173
+ Scheduler.log('BrokenComponentWillReceiveProps componentWillUnmount');
174
}
175
};
176
177
BrokenComponentWillUpdate = class extends React.Component {
178
constructor(props) {
179
super(props);
218
- Scheduler.unstable_yieldValue('BrokenComponentWillUpdate constructor');
180
+ Scheduler.log('BrokenComponentWillUpdate constructor');
181
}
182
render() {
221
- Scheduler.unstable_yieldValue('BrokenComponentWillUpdate render');
183
+ Scheduler.log('BrokenComponentWillUpdate render');
184
return <div>{this.props.children}</div>;
185
}
186
UNSAFE_componentWillMount() {
225
- Scheduler.unstable_yieldValue(
226
- 'BrokenComponentWillUpdate componentWillMount',
227
- );
187
+ Scheduler.log('BrokenComponentWillUpdate componentWillMount');
188
}
189
componentDidMount() {
230
- Scheduler.unstable_yieldValue(
231
- 'BrokenComponentWillUpdate componentDidMount',
232
- );
190
+ Scheduler.log('BrokenComponentWillUpdate componentDidMount');
191
}
192
UNSAFE_componentWillReceiveProps() {
235
- Scheduler.unstable_yieldValue(
236
- 'BrokenComponentWillUpdate componentWillReceiveProps',
237
- );
193
+ Scheduler.log('BrokenComponentWillUpdate componentWillReceiveProps');
194
}
195
UNSAFE_componentWillUpdate() {
240
- Scheduler.unstable_yieldValue(
241
- 'BrokenComponentWillUpdate componentWillUpdate [!]',
242
- );
196
+ Scheduler.log('BrokenComponentWillUpdate componentWillUpdate [!]');
197
throw new Error('Hello');
198
}
199
componentDidUpdate() {
246
- Scheduler.unstable_yieldValue(
247
- 'BrokenComponentWillUpdate componentDidUpdate',
248
- );
200
+ Scheduler.log('BrokenComponentWillUpdate componentDidUpdate');
201
}
202
componentWillUnmount() {
251
- Scheduler.unstable_yieldValue(
252
- 'BrokenComponentWillUpdate componentWillUnmount',
253
- );
203
+ Scheduler.log('BrokenComponentWillUpdate componentWillUnmount');
204
}
205
};
206
@@ -260,42 +210,30 @@ describe('ReactErrorBoundaries', () => {
210
};
211
constructor(props) {
212
super(props);
263
- Scheduler.unstable_yieldValue('BrokenComponentDidUpdate constructor');
213
+ Scheduler.log('BrokenComponentDidUpdate constructor');
214
}
215
render() {
266
- Scheduler.unstable_yieldValue('BrokenComponentDidUpdate render');
216
+ Scheduler.log('BrokenComponentDidUpdate render');
217
return <div>{this.props.children}</div>;
218
}
219
UNSAFE_componentWillMount() {
270
- Scheduler.unstable_yieldValue(
271
- 'BrokenComponentDidUpdate componentWillMount',
272
- );
220
+ Scheduler.log('BrokenComponentDidUpdate componentWillMount');
221
}
222
componentDidMount() {
275
- Scheduler.unstable_yieldValue(
276
- 'BrokenComponentDidUpdate componentDidMount',
277
- );
223
+ Scheduler.log('BrokenComponentDidUpdate componentDidMount');
224
}
225
UNSAFE_componentWillReceiveProps() {
280
- Scheduler.unstable_yieldValue(
281
- 'BrokenComponentDidUpdate componentWillReceiveProps',
282
- );
226
+ Scheduler.log('BrokenComponentDidUpdate componentWillReceiveProps');
227
}
228
UNSAFE_componentWillUpdate() {
285
- Scheduler.unstable_yieldValue(
286
- 'BrokenComponentDidUpdate componentWillUpdate',
287
- );
229
+ Scheduler.log('BrokenComponentDidUpdate componentWillUpdate');
230
}
231
componentDidUpdate() {
290
- Scheduler.unstable_yieldValue(
291
- 'BrokenComponentDidUpdate componentDidUpdate [!]',
292
- );
232
+ Scheduler.log('BrokenComponentDidUpdate componentDidUpdate [!]');
233
throw new Error(this.props.errorText);
234
}
235
componentWillUnmount() {
296
- Scheduler.unstable_yieldValue(
297
- 'BrokenComponentDidUpdate componentWillUnmount',
298
- );
236
+ Scheduler.log('BrokenComponentDidUpdate componentWillUnmount');
237
}
238
};
239
@@ -305,41 +243,29 @@ describe('ReactErrorBoundaries', () => {
243
};
244
constructor(props) {
245
super(props);
308
- Scheduler.unstable_yieldValue('BrokenComponentWillUnmount constructor');
246
+ Scheduler.log('BrokenComponentWillUnmount constructor');
247
}
248
render() {
311
- Scheduler.unstable_yieldValue('BrokenComponentWillUnmount render');
249
+ Scheduler.log('BrokenComponentWillUnmount render');
250
return <div>{this.props.children}</div>;
251
}
252
UNSAFE_componentWillMount() {
315
- Scheduler.unstable_yieldValue(
316
- 'BrokenComponentWillUnmount componentWillMount',
317
- );
253
+ Scheduler.log('BrokenComponentWillUnmount componentWillMount');
254
}
255
componentDidMount() {
320
- Scheduler.unstable_yieldValue(
321
- 'BrokenComponentWillUnmount componentDidMount',
322
- );
256
+ Scheduler.log('BrokenComponentWillUnmount componentDidMount');
257
}
258
UNSAFE_componentWillReceiveProps() {
325
- Scheduler.unstable_yieldValue(
326
- 'BrokenComponentWillUnmount componentWillReceiveProps',
327
- );
259
+ Scheduler.log('BrokenComponentWillUnmount componentWillReceiveProps');
260
}
261
UNSAFE_componentWillUpdate() {
330
- Scheduler.unstable_yieldValue(
331
- 'BrokenComponentWillUnmount componentWillUpdate',
332
- );
262
+ Scheduler.log('BrokenComponentWillUnmount componentWillUpdate');
263
}
264
componentDidUpdate() {
335
- Scheduler.unstable_yieldValue(
336
- 'BrokenComponentWillUnmount componentDidUpdate',
337
- );
265
+ Scheduler.log('BrokenComponentWillUnmount componentDidUpdate');
266
}
267
componentWillUnmount() {
340
- Scheduler.unstable_yieldValue(
341
- 'BrokenComponentWillUnmount componentWillUnmount [!]',
342
- );
268
+ Scheduler.log('BrokenComponentWillUnmount componentWillUnmount [!]');
269
throw new Error(this.props.errorText);
270
}
271
};
@@ -348,40 +274,34 @@ describe('ReactErrorBoundaries', () => {
274
constructor(props) {
275
super(props);
276
this.state = {error: null};
351
- Scheduler.unstable_yieldValue(
352
- 'BrokenComponentWillMountErrorBoundary constructor',
353
- );
277
+ Scheduler.log('BrokenComponentWillMountErrorBoundary constructor');
278
}
279
render() {
280
if (this.state.error) {
357
- Scheduler.unstable_yieldValue(
358
- 'BrokenComponentWillMountErrorBoundary render error',
359
- );
281
+ Scheduler.log('BrokenComponentWillMountErrorBoundary render error');
282
return <div>Caught an error: {this.state.error.message}.</div>;
283
}
362
- Scheduler.unstable_yieldValue(
363
- 'BrokenComponentWillMountErrorBoundary render success',
364
- );
284
+ Scheduler.log('BrokenComponentWillMountErrorBoundary render success');
285
return <div>{this.props.children}</div>;
286
}
287
UNSAFE_componentWillMount() {
368
- Scheduler.unstable_yieldValue(
288
+ Scheduler.log(
289
'BrokenComponentWillMountErrorBoundary componentWillMount [!]',
290
);
291
throw new Error('Hello');
292
}
293
componentDidMount() {
374
- Scheduler.unstable_yieldValue(
294
+ Scheduler.log(
295
'BrokenComponentWillMountErrorBoundary componentDidMount',
296
);
297
}
298
componentWillUnmount() {
379
- Scheduler.unstable_yieldValue(
299
+ Scheduler.log(
300
'BrokenComponentWillMountErrorBoundary componentWillUnmount',
301
);
302
}
303
static getDerivedStateFromError(error) {
384
- Scheduler.unstable_yieldValue(
304
+ Scheduler.log(
305
'BrokenComponentWillMountErrorBoundary static getDerivedStateFromError',
306
);
307
return {error};
@@ -392,40 +312,34 @@ describe('ReactErrorBoundaries', () => {
312
constructor(props) {
313
super(props);
314
this.state = {error: null};
395
- Scheduler.unstable_yieldValue(
396
- 'BrokenComponentDidMountErrorBoundary constructor',
397
- );
315
+ Scheduler.log('BrokenComponentDidMountErrorBoundary constructor');
316
}
317
render() {
318
if (this.state.error) {
401
- Scheduler.unstable_yieldValue(
402
- 'BrokenComponentDidMountErrorBoundary render error',
403
- );
319
+ Scheduler.log('BrokenComponentDidMountErrorBoundary render error');
320
return <div>Caught an error: {this.state.error.message}.</div>;
321
}
406
- Scheduler.unstable_yieldValue(
407
- 'BrokenComponentDidMountErrorBoundary render success',
408
- );
322
+ Scheduler.log('BrokenComponentDidMountErrorBoundary render success');
323
return <div>{this.props.children}</div>;
324
}
325
UNSAFE_componentWillMount() {
412
- Scheduler.unstable_yieldValue(
326
+ Scheduler.log(
327
'BrokenComponentDidMountErrorBoundary componentWillMount',
328
);
329
}
330
componentDidMount() {
417
- Scheduler.unstable_yieldValue(
331
+ Scheduler.log(
332
'BrokenComponentDidMountErrorBoundary componentDidMount [!]',
333
);
334
throw new Error('Hello');
335
}
336
componentWillUnmount() {
423
- Scheduler.unstable_yieldValue(
337
+ Scheduler.log(
338
'BrokenComponentDidMountErrorBoundary componentWillUnmount',
339
);
340
}
341
static getDerivedStateFromError(error) {
428
- Scheduler.unstable_yieldValue(
342
+ Scheduler.log(
343
'BrokenComponentDidMountErrorBoundary static getDerivedStateFromError',
344
);
345
return {error};
@@ -436,37 +350,27 @@ describe('ReactErrorBoundaries', () => {
350
constructor(props) {
351
super(props);
352
this.state = {error: null};
439
- Scheduler.unstable_yieldValue('BrokenRenderErrorBoundary constructor');
353
+ Scheduler.log('BrokenRenderErrorBoundary constructor');
354
}
355
render() {
356
if (this.state.error) {
443
- Scheduler.unstable_yieldValue(
444
- 'BrokenRenderErrorBoundary render error [!]',
445
- );
357
+ Scheduler.log('BrokenRenderErrorBoundary render error [!]');
358
throw new Error('Hello');
359
}
448
- Scheduler.unstable_yieldValue(
449
- 'BrokenRenderErrorBoundary render success',
450
- );
360
+ Scheduler.log('BrokenRenderErrorBoundary render success');
361
return <div>{this.props.children}</div>;
362
}
363
UNSAFE_componentWillMount() {
454
- Scheduler.unstable_yieldValue(
455
- 'BrokenRenderErrorBoundary componentWillMount',
456
- );
364
+ Scheduler.log('BrokenRenderErrorBoundary componentWillMount');
365
}
366
componentDidMount() {
459
- Scheduler.unstable_yieldValue(
460
- 'BrokenRenderErrorBoundary componentDidMount',
461
- );
367
+ Scheduler.log('BrokenRenderErrorBoundary componentDidMount');
368
}
369
componentWillUnmount() {
464
- Scheduler.unstable_yieldValue(
465
- 'BrokenRenderErrorBoundary componentWillUnmount',
466
- );
370
+ Scheduler.log('BrokenRenderErrorBoundary componentWillUnmount');
371
}
372
static getDerivedStateFromError(error) {
469
- Scheduler.unstable_yieldValue(
373
+ Scheduler.log(
374
'BrokenRenderErrorBoundary static getDerivedStateFromError',
375
);
376
return {error};
@@ -476,37 +380,37 @@ describe('ReactErrorBoundaries', () => {
380
BrokenRender = class extends React.Component {
381
constructor(props) {
382
super(props);
479
- Scheduler.unstable_yieldValue('BrokenRender constructor');
383
+ Scheduler.log('BrokenRender constructor');
384
}
385
render() {
482
- Scheduler.unstable_yieldValue('BrokenRender render [!]');
386
+ Scheduler.log('BrokenRender render [!]');
387
throw new Error('Hello');
388
}
389
UNSAFE_componentWillMount() {
486
- Scheduler.unstable_yieldValue('BrokenRender componentWillMount');
390
+ Scheduler.log('BrokenRender componentWillMount');
391
}
392
componentDidMount() {
489
- Scheduler.unstable_yieldValue('BrokenRender componentDidMount');
393
+ Scheduler.log('BrokenRender componentDidMount');
394
}
395
UNSAFE_componentWillReceiveProps() {
492
- Scheduler.unstable_yieldValue('BrokenRender componentWillReceiveProps');
396
+ Scheduler.log('BrokenRender componentWillReceiveProps');
397
}
398
UNSAFE_componentWillUpdate() {
495
- Scheduler.unstable_yieldValue('BrokenRender componentWillUpdate');
399
+ Scheduler.log('BrokenRender componentWillUpdate');
400
}
401
componentDidUpdate() {
498
- Scheduler.unstable_yieldValue('BrokenRender componentDidUpdate');
402
+ Scheduler.log('BrokenRender componentDidUpdate');
403
}
404
componentWillUnmount() {
501
- Scheduler.unstable_yieldValue('BrokenRender componentWillUnmount');
405
+ Scheduler.log('BrokenRender componentWillUnmount');
406
}
407
};
408
409
BrokenUseEffect = ({children}) => {
506
- Scheduler.unstable_yieldValue('BrokenUseEffect render');
410
+ Scheduler.log('BrokenUseEffect render');
411
412
React.useEffect(() => {
509
- Scheduler.unstable_yieldValue('BrokenUseEffect useEffect [!]');
413
+ Scheduler.log('BrokenUseEffect useEffect [!]');
414
throw new Error('Hello');
415
});
416
@@ -514,12 +418,10 @@ describe('ReactErrorBoundaries', () => {
418
};
419
420
BrokenUseLayoutEffect = ({children}) => {
517
- Scheduler.unstable_yieldValue('BrokenUseLayoutEffect render');
421
+ Scheduler.log('BrokenUseLayoutEffect render');
422
423
React.useLayoutEffect(() => {
520
- Scheduler.unstable_yieldValue(
521
- 'BrokenUseLayoutEffect useLayoutEffect [!]',
522
- );
424
+ Scheduler.log('BrokenUseLayoutEffect useLayoutEffect [!]');
425
throw new Error('Hello');
426
});
427
@@ -529,25 +431,23 @@ describe('ReactErrorBoundaries', () => {
431
NoopErrorBoundary = class extends React.Component {
432
constructor(props) {
433
super(props);
532
- Scheduler.unstable_yieldValue('NoopErrorBoundary constructor');
434
+ Scheduler.log('NoopErrorBoundary constructor');
435
}
436
render() {
535
- Scheduler.unstable_yieldValue('NoopErrorBoundary render');
437
+ Scheduler.log('NoopErrorBoundary render');
438
return <BrokenRender />;
439
}
440
UNSAFE_componentWillMount() {
539
- Scheduler.unstable_yieldValue('NoopErrorBoundary componentWillMount');
441
+ Scheduler.log('NoopErrorBoundary componentWillMount');
442
}
443
componentDidMount() {
542
- Scheduler.unstable_yieldValue('NoopErrorBoundary componentDidMount');
444
+ Scheduler.log('NoopErrorBoundary componentDidMount');
445
}
446
componentWillUnmount() {
545
- Scheduler.unstable_yieldValue('NoopErrorBoundary componentWillUnmount');
447
+ Scheduler.log('NoopErrorBoundary componentWillUnmount');
448
}
449
static getDerivedStateFromError() {
548
- Scheduler.unstable_yieldValue(
549
- 'NoopErrorBoundary static getDerivedStateFromError',
550
- );
450
+ Scheduler.log('NoopErrorBoundary static getDerivedStateFromError');
451
}
452
};
453
@@ -557,41 +457,29 @@ describe('ReactErrorBoundaries', () => {
457
};
458
constructor(props) {
459
super(props);
560
- Scheduler.unstable_yieldValue(`${this.props.logName} constructor`);
460
+ Scheduler.log(`${this.props.logName} constructor`);
461
}
462
render() {
563
- Scheduler.unstable_yieldValue(`${this.props.logName} render`);
463
+ Scheduler.log(`${this.props.logName} render`);
464
return <div>{this.props.children}</div>;
465
}
466
UNSAFE_componentWillMount() {
567
- Scheduler.unstable_yieldValue(
568
- `${this.props.logName} componentWillMount`,
569
- );
467
+ Scheduler.log(`${this.props.logName} componentWillMount`);
468
}
469
componentDidMount() {
572
- Scheduler.unstable_yieldValue(
573
- `${this.props.logName} componentDidMount`,
574
- );
470
+ Scheduler.log(`${this.props.logName} componentDidMount`);
471
}
472
UNSAFE_componentWillReceiveProps() {
577
- Scheduler.unstable_yieldValue(
578
- `${this.props.logName} componentWillReceiveProps`,
579
- );
473
+ Scheduler.log(`${this.props.logName} componentWillReceiveProps`);
474
}
475
UNSAFE_componentWillUpdate() {
582
- Scheduler.unstable_yieldValue(
583
- `${this.props.logName} componentWillUpdate`,
584
- );
476
+ Scheduler.log(`${this.props.logName} componentWillUpdate`);
477
}
478
componentDidUpdate() {
587
- Scheduler.unstable_yieldValue(
588
- `${this.props.logName} componentDidUpdate`,
589
- );
479
+ Scheduler.log(`${this.props.logName} componentDidUpdate`);
480
}
481
componentWillUnmount() {
592
- Scheduler.unstable_yieldValue(
593
- `${this.props.logName} componentWillUnmount`,
594
- );
482
+ Scheduler.log(`${this.props.logName} componentWillUnmount`);
483
}
484
};
485
@@ -599,51 +487,37 @@ describe('ReactErrorBoundaries', () => {
487
constructor(props) {
488
super(props);
489
this.state = {error: null};
602
- Scheduler.unstable_yieldValue(`${this.props.logName} constructor`);
490
+ Scheduler.log(`${this.props.logName} constructor`);
491
}
492
render() {
493
if (this.state.error && !this.props.forceRetry) {
606
- Scheduler.unstable_yieldValue(`${this.props.logName} render error`);
494
+ Scheduler.log(`${this.props.logName} render error`);
495
return this.props.renderError(this.state.error, this.props);
496
}
609
- Scheduler.unstable_yieldValue(`${this.props.logName} render success`);
497
+ Scheduler.log(`${this.props.logName} render success`);
498
return <div>{this.props.children}</div>;
499
}
500
static getDerivedStateFromError(error) {
613
- Scheduler.unstable_yieldValue(
614
- 'ErrorBoundary static getDerivedStateFromError',
615
- );
501
+ Scheduler.log('ErrorBoundary static getDerivedStateFromError');
502
return {error};
503
}
504
UNSAFE_componentWillMount() {
619
- Scheduler.unstable_yieldValue(
620
- `${this.props.logName} componentWillMount`,
621
- );
505
+ Scheduler.log(`${this.props.logName} componentWillMount`);
506
}
507
componentDidMount() {
624
- Scheduler.unstable_yieldValue(
625
- `${this.props.logName} componentDidMount`,
626
- );
508
+ Scheduler.log(`${this.props.logName} componentDidMount`);
509
}
510
UNSAFE_componentWillReceiveProps() {
629
- Scheduler.unstable_yieldValue(
630
- `${this.props.logName} componentWillReceiveProps`,
631
- );
511
+ Scheduler.log(`${this.props.logName} componentWillReceiveProps`);
512
}
513
UNSAFE_componentWillUpdate() {
634
- Scheduler.unstable_yieldValue(
635
- `${this.props.logName} componentWillUpdate`,
636
- );
514
+ Scheduler.log(`${this.props.logName} componentWillUpdate`);
515
}
516
componentDidUpdate() {
639
- Scheduler.unstable_yieldValue(
640
- `${this.props.logName} componentDidUpdate`,
641
- );
517
+ Scheduler.log(`${this.props.logName} componentDidUpdate`);
518
}
519
componentWillUnmount() {
644
- Scheduler.unstable_yieldValue(
645
- `${this.props.logName} componentWillUnmount`,
646
- );
520
+ Scheduler.log(`${this.props.logName} componentWillUnmount`);
521
}
522
};
523
ErrorBoundary.defaultProps = {
@@ -660,27 +534,23 @@ describe('ReactErrorBoundaries', () => {
534
RetryErrorBoundary = class extends React.Component {
535
constructor(props) {
536
super(props);
663
- Scheduler.unstable_yieldValue('RetryErrorBoundary constructor');
537
+ Scheduler.log('RetryErrorBoundary constructor');
538
}
539
render() {
666
- Scheduler.unstable_yieldValue('RetryErrorBoundary render');
540
+ Scheduler.log('RetryErrorBoundary render');
541
return <BrokenRender />;
542
}
543
UNSAFE_componentWillMount() {
670
- Scheduler.unstable_yieldValue('RetryErrorBoundary componentWillMount');
544
+ Scheduler.log('RetryErrorBoundary componentWillMount');
545
}
546
componentDidMount() {
673
- Scheduler.unstable_yieldValue('RetryErrorBoundary componentDidMount');
547
+ Scheduler.log('RetryErrorBoundary componentDidMount');
548
}
549
componentWillUnmount() {
676
- Scheduler.unstable_yieldValue(
677
- 'RetryErrorBoundary componentWillUnmount',
678
- );
550
+ Scheduler.log('RetryErrorBoundary componentWillUnmount');
551
}
552
static getDerivedStateFromError(error) {
681
- Scheduler.unstable_yieldValue(
682
- 'RetryErrorBoundary static getDerivedStateFromError [!]',
683
- );
553
+ Scheduler.log('RetryErrorBoundary static getDerivedStateFromError [!]');
554
// In Fiber, calling setState() (and failing) is treated as a rethrow.
555
return {};
556
}
@@ -689,19 +559,19 @@ describe('ReactErrorBoundaries', () => {
559
ErrorMessage = class extends React.Component {
560
constructor(props) {
561
super(props);
692
- Scheduler.unstable_yieldValue('ErrorMessage constructor');
562
+ Scheduler.log('ErrorMessage constructor');
563
}
564
UNSAFE_componentWillMount() {
695
- Scheduler.unstable_yieldValue('ErrorMessage componentWillMount');
565
+ Scheduler.log('ErrorMessage componentWillMount');
566
}
567
componentDidMount() {
698
- Scheduler.unstable_yieldValue('ErrorMessage componentDidMount');
568
+ Scheduler.log('ErrorMessage componentDidMount');
569
}
570
componentWillUnmount() {
701
- Scheduler.unstable_yieldValue('ErrorMessage componentWillUnmount');
571
+ Scheduler.log('ErrorMessage componentWillUnmount');
572
}
573
render() {
704
- Scheduler.unstable_yieldValue('ErrorMessage render');
574
+ Scheduler.log('ErrorMessage render');
575
return <div>Caught an error: {this.props.message}.</div>;
576
}
577
};
@@ -1146,10 +1016,10 @@ describe('ReactErrorBoundaries', () => {
1016
1017
it('resets callback refs if mounting aborts', () => {
1018
function childRef(x) {
1149
- Scheduler.unstable_yieldValue('Child ref is set to ' + x);
1019
+ Scheduler.log('Child ref is set to ' + x);
1020
}
1021
function errorMessageRef(x) {
1152
- Scheduler.unstable_yieldValue('Error message ref is set to ' + x);
1022
+ Scheduler.log('Error message ref is set to ' + x);
1023
}
1024
1025
const container = document.createElement('div');
@@ -1246,7 +1116,7 @@ describe('ReactErrorBoundaries', () => {
1116
</ErrorBoundary>,
1117
container,
1118
);
1249
- Scheduler.unstable_clearYields();
1119
+ Scheduler.unstable_clearLog();
1120
ReactDOM.render(
1121
<ErrorBoundary>
1122
<Normal />
@@ -1291,7 +1161,7 @@ describe('ReactErrorBoundaries', () => {
1161
container,
1162
);
1163
1294
- Scheduler.unstable_clearYields();
1164
+ Scheduler.unstable_clearLog();
1165
ReactDOM.render(
1166
<ErrorBoundary>
1167
<Normal />
@@ -1338,7 +1208,7 @@ describe('ReactErrorBoundaries', () => {
1208
container,
1209
);
1210
1341
- Scheduler.unstable_clearYields();
1211
+ Scheduler.unstable_clearLog();
1212
ReactDOM.render(
1213
<ErrorBoundary>
1214
<Normal />
@@ -1380,7 +1250,7 @@ describe('ReactErrorBoundaries', () => {
1250
container,
1251
);
1252
1383
- Scheduler.unstable_clearYields();
1253
+ Scheduler.unstable_clearLog();
1254
ReactDOM.render(
1255
<ErrorBoundary>
1256
<Normal />
@@ -1421,7 +1291,7 @@ describe('ReactErrorBoundaries', () => {
1291
container,
1292
);
1293
1424
- Scheduler.unstable_clearYields();
1294
+ Scheduler.unstable_clearLog();
1295
ReactDOM.render(
1296
<ErrorBoundary>
1297
<Normal />
@@ -1460,13 +1330,13 @@ describe('ReactErrorBoundaries', () => {
1330
1331
it('keeps refs up-to-date during updates', () => {
1332
function child1Ref(x) {
1463
- Scheduler.unstable_yieldValue('Child1 ref is set to ' + x);
1333
+ Scheduler.log('Child1 ref is set to ' + x);
1334
}
1335
function child2Ref(x) {
1466
- Scheduler.unstable_yieldValue('Child2 ref is set to ' + x);
1336
+ Scheduler.log('Child2 ref is set to ' + x);
1337
}
1338
function errorMessageRef(x) {
1469
- Scheduler.unstable_yieldValue('Error message ref is set to ' + x);
1339
+ Scheduler.log('Error message ref is set to ' + x);
1340
}
1341
1342
const container = document.createElement('div');
@@ -1530,7 +1400,7 @@ describe('ReactErrorBoundaries', () => {
1400
container,
1401
);
1402
1533
- Scheduler.unstable_clearYields();
1403
+ Scheduler.unstable_clearLog();
1404
ReactDOM.render(
1405
<ErrorBoundary>
1406
<BrokenComponentWillUnmount />
@@ -1586,7 +1456,7 @@ describe('ReactErrorBoundaries', () => {
1456
container,
1457
);
1458
1589
- Scheduler.unstable_clearYields();
1459
+ Scheduler.unstable_clearLog();
1460
ReactDOM.render(
1461
<ErrorBoundary>
1462
<Normal>
@@ -1655,7 +1525,7 @@ describe('ReactErrorBoundaries', () => {
1525
container,
1526
);
1527
1658
- Scheduler.unstable_clearYields();
1528
+ Scheduler.unstable_clearLog();
1529
ReactDOM.render(
1530
<ErrorBoundary
1531
logName="OuterErrorBoundary"
@@ -1718,7 +1588,7 @@ describe('ReactErrorBoundaries', () => {
1588
expect(container.textContent).toBe('Caught an error: Hello.');
1589
1590
// Force the success path:
1721
- Scheduler.unstable_clearYields();
1591
+ Scheduler.unstable_clearLog();
1592
ReactDOM.render(
1593
<ErrorBoundary forceRetry={true}>
1594
<Normal />
@@ -1784,7 +1654,7 @@ describe('ReactErrorBoundaries', () => {
1654
ReactDOM.render(<ErrorBoundary />, container);
1655
expect(container.textContent).toBe('Caught an error: Hello.');
1656
1787
- Scheduler.unstable_clearYields();
1657
+ Scheduler.unstable_clearLog();
1658
ReactDOM.unmountComponentAtNode(container);
1659
assertLog(['ErrorBoundary componentWillUnmount']);
1660
});
@@ -1802,7 +1672,7 @@ describe('ReactErrorBoundaries', () => {
1672
);
1673
expect(container.textContent).toBe('Caught an error: Hello.');
1674
1805
- Scheduler.unstable_clearYields();
1675
+ Scheduler.unstable_clearLog();
1676
ReactDOM.unmountComponentAtNode(container);
1677
assertLog(['ErrorBoundary componentWillUnmount']);
1678
});
@@ -1850,7 +1720,7 @@ describe('ReactErrorBoundaries', () => {
1720
);
1721
expect(container.textContent).toBe('Caught an error: Hello.');
1722
1853
- Scheduler.unstable_clearYields();
1723
+ Scheduler.unstable_clearLog();
1724
ReactDOM.unmountComponentAtNode(container);
1725
assertLog(['ErrorBoundary componentWillUnmount']);
1726
});
@@ -1862,7 +1732,7 @@ describe('ReactErrorBoundaries', () => {
1732
1733
render() {
1734
if (fail) {
1865
- Scheduler.unstable_yieldValue('Stateful render [!]');
1735
+ Scheduler.log('Stateful render [!]');
1736
throw new Error('Hello');
1737
}
1738
return <div>{this.props.children}</div>;
@@ -1878,7 +1748,7 @@ describe('ReactErrorBoundaries', () => {
1748
container,
1749
);
1750
1881
- Scheduler.unstable_clearYields();
1751
+ Scheduler.unstable_clearLog();
1752
expect(() => {
1753
fail = true;
1754
statefulInst.forceUpdate();
@@ -1963,7 +1833,7 @@ describe('ReactErrorBoundaries', () => {
1833
container,
1834
);
1835
1966
- Scheduler.unstable_clearYields();
1836
+ Scheduler.unstable_clearLog();
1837
ReactDOM.render(
1838
<ErrorBoundary>
1839
<BrokenComponentDidUpdate />
@@ -2010,7 +1880,7 @@ describe('ReactErrorBoundaries', () => {
1880
]);
1881
1882
expect(container.firstChild.textContent).toBe('Initial value');
2013
- Scheduler.unstable_clearYields();
1883
+ Scheduler.unstable_clearLog();
1884
});
1885
1886
// verify flushed passive effects and handle the error
@@ -2116,7 +1986,7 @@ describe('ReactErrorBoundaries', () => {
1986
container,
1987
);
1988
2119
- Scheduler.unstable_clearYields();
1989
+ Scheduler.unstable_clearLog();
1990
ReactDOM.render(
1991
<ErrorBoundary logName="OuterErrorBoundary">
1992
<ErrorBoundary
@@ -2489,19 +2359,17 @@ describe('ReactErrorBoundaries', () => {
2359
class LocalErrorBoundary extends React.Component {
2360
state = {error: null};
2361
static getDerivedStateFromError(error) {
2492
- Scheduler.unstable_yieldValue(
2493
- `ErrorBoundary static getDerivedStateFromError`,
2494
- );
2362
+ Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
2363
return {error};
2364
}
2365
render() {
2366
const {children, id, fallbackID} = this.props;
2367
const {error} = this.state;
2368
if (error) {
2501
- Scheduler.unstable_yieldValue(`${id} render error`);
2369
+ Scheduler.log(`${id} render error`);
2370
return <Component id={fallbackID} />;
2371
}
2504
- Scheduler.unstable_yieldValue(`${id} render success`);
2372
+ Scheduler.log(`${id} render success`);
2373
return children || null;
2374
}
2375
}
@@ -2509,21 +2377,19 @@ describe('ReactErrorBoundaries', () => {
2377
class Component extends React.Component {
2378
render() {
2379
const {id} = this.props;
2512
- Scheduler.unstable_yieldValue('Component render ' + id);
2380
+ Scheduler.log('Component render ' + id);
2381
return id;
2382
}
2383
}
2384
2385
class LocalBrokenComponentWillUnmount extends React.Component {
2386
componentWillUnmount() {
2519
- Scheduler.unstable_yieldValue(
2520
- 'BrokenComponentWillUnmount componentWillUnmount',
2521
- );
2387
+ Scheduler.log('BrokenComponentWillUnmount componentWillUnmount');
2388
throw Error('Expected');
2389
}
2390
2391
render() {
2526
- Scheduler.unstable_yieldValue('BrokenComponentWillUnmount render');
2392
+ Scheduler.log('BrokenComponentWillUnmount render');
2393
return 'broken';
2394
}
2395
}
@@ -2573,19 +2439,17 @@ describe('ReactErrorBoundaries', () => {
2439
class LocalErrorBoundary extends React.Component {
2440
state = {error: null};
2441
static getDerivedStateFromError(error) {
2576
- Scheduler.unstable_yieldValue(
2577
- `ErrorBoundary static getDerivedStateFromError`,
2578
- );
2442
+ Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
2443
return {error};
2444
}
2445
render() {
2446
const {children, id, fallbackID} = this.props;
2447
const {error} = this.state;
2448
if (error) {
2585
- Scheduler.unstable_yieldValue(`${id} render error`);
2449
+ Scheduler.log(`${id} render error`);
2450
return <Component id={fallbackID} />;
2451
}
2588
- Scheduler.unstable_yieldValue(`${id} render success`);
2452
+ Scheduler.log(`${id} render success`);
2453
return children || null;
2454
}
2455
}
@@ -2593,21 +2457,21 @@ describe('ReactErrorBoundaries', () => {
2457
class Component extends React.Component {
2458
render() {
2459
const {id} = this.props;
2596
- Scheduler.unstable_yieldValue('Component render ' + id);
2460
+ Scheduler.log('Component render ' + id);
2461
return id;
2462
}
2463
}
2464
2465
class LocalBrokenCallbackRef extends React.Component {
2466
_ref = ref => {
2603
- Scheduler.unstable_yieldValue('LocalBrokenCallbackRef ref ' + !!ref);
2467
+ Scheduler.log('LocalBrokenCallbackRef ref ' + !!ref);
2468
if (ref === null) {
2469
throw Error('Expected');
2470
}
2471
};
2472
2473
render() {
2610
- Scheduler.unstable_yieldValue('LocalBrokenCallbackRef render');
2474
+ Scheduler.log('LocalBrokenCallbackRef render');
2475
return <div ref={this._ref}>ref</div>;
2476
}
2477
}
packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
+7
-7
@@ -141,7 +141,7 @@ function runActTests(label, render, unmount, rerender) {
141
it('can use act to flush effects', () => {
142
function App() {
143
React.useEffect(() => {
144
- Scheduler.unstable_yieldValue(100);
144
+ Scheduler.log(100);
145
});
146
return null;
147
}
@@ -158,7 +158,7 @@ function runActTests(label, render, unmount, rerender) {
158
function App() {
159
const [ctr, setCtr] = React.useState(0);
160
React.useEffect(() => {
161
- Scheduler.unstable_yieldValue(ctr);
161
+ Scheduler.log(ctr);
162
});
163
return (
164
<button id="button" onClick={() => setCtr(x => x + 1)}>
@@ -213,7 +213,7 @@ function runActTests(label, render, unmount, rerender) {
213
it('should flush effects only on exiting the outermost act', () => {
214
function App() {
215
React.useEffect(() => {
216
- Scheduler.unstable_yieldValue(0);
216
+ Scheduler.log(0);
217
});
218
return null;
219
}
@@ -546,7 +546,7 @@ function runActTests(label, render, unmount, rerender) {
546
something();
547
}, []);
548
React.useEffect(() => {
549
- Scheduler.unstable_yieldValue(state);
549
+ Scheduler.log(state);
550
});
551
return state;
552
}
@@ -571,7 +571,7 @@ function runActTests(label, render, unmount, rerender) {
571
setState(x => x + 1);
572
}
573
React.useEffect(() => {
574
- Scheduler.unstable_yieldValue(state);
574
+ Scheduler.log(state);
575
ticker();
576
}, [Math.min(state, 4)]);
577
return state;
@@ -644,7 +644,7 @@ function runActTests(label, render, unmount, rerender) {
644
it('should cleanup after errors - sync', () => {
645
function App() {
646
React.useEffect(() => {
647
- Scheduler.unstable_yieldValue('oh yes');
647
+ Scheduler.log('oh yes');
648
});
649
return null;
650
}
@@ -671,7 +671,7 @@ function runActTests(label, render, unmount, rerender) {
671
function App() {
672
async function somethingAsync() {
673
await null;
674
- Scheduler.unstable_yieldValue('oh yes');
674
+ Scheduler.log('oh yes');
675
}
676
React.useEffect(() => {
677
somethingAsync();
packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js
+9
-9
@@ -15,7 +15,7 @@ let act;
15
let container;
16
let yields;
17
18
-function clearYields() {
18
+function clearLog() {
19
try {
20
return yields;
21
} finally {
@@ -60,7 +60,7 @@ it('can use act to flush effects', () => {
60
render(<App />, container);
61
});
62
63
- expect(clearYields()).toEqual([100]);
63
+ expect(clearLog()).toEqual([100]);
64
});
65
66
// @gate __DEV__
@@ -81,7 +81,7 @@ it('flushes effects on every call', () => {
81
render(<App />, container);
82
});
83
84
- expect(clearYields()).toEqual([0]);
84
+ expect(clearLog()).toEqual([0]);
85
86
const button = container.querySelector('#button');
87
function click() {
@@ -94,11 +94,11 @@ it('flushes effects on every call', () => {
94
click();
95
});
96
// it consolidates the 3 updates, then fires the effect
97
- expect(clearYields()).toEqual([3]);
97
+ expect(clearLog()).toEqual([3]);
98
act(click);
99
- expect(clearYields()).toEqual([4]);
99
+ expect(clearLog()).toEqual([4]);
100
act(click);
101
- expect(clearYields()).toEqual([5]);
101
+ expect(clearLog()).toEqual([5]);
102
expect(button.innerHTML).toEqual('5');
103
});
104
@@ -136,10 +136,10 @@ it('should flush effects only on exiting the outermost act', () => {
136
});
137
// the effect wouldn't have yielded yet because
138
// we're still inside an act() scope
139
- expect(clearYields()).toEqual([]);
139
+ expect(clearLog()).toEqual([]);
140
});
141
// but after exiting the last one, effects get flushed
142
- expect(clearYields()).toEqual([0]);
142
+ expect(clearLog()).toEqual([0]);
143
});
144
145
// @gate __DEV__
@@ -163,6 +163,6 @@ it('can handle cascading promises', async () => {
163
render(<App />, container);
164
});
165
// all 5 ticks present and accounted for
166
- expect(clearYields()).toEqual([0, 1, 2, 3, 4]);
166
+ expect(clearLog()).toEqual([0, 1, 2, 3, 4]);
167
expect(container.innerHTML).toBe('5');
168
});
packages/react-dom/src/__tests__/ReactUpdates-test.js
+8
-8
@@ -1331,7 +1331,7 @@ describe('ReactUpdates', () => {
1331
const container = document.createElement('div');
1332
1333
function Baz() {
1334
- Scheduler.unstable_yieldValue('Baz');
1334
+ Scheduler.log('Baz');
1335
return <p>baz</p>;
1336
}
1337
@@ -1339,14 +1339,14 @@ describe('ReactUpdates', () => {
1339
function Bar() {
1340
const [counter, _setCounter] = React.useState(0);
1341
setCounter = _setCounter;
1342
- Scheduler.unstable_yieldValue('Bar');
1342
+ Scheduler.log('Bar');
1343
return <p>bar {counter}</p>;
1344
}
1345
1346
function Foo() {
1347
- Scheduler.unstable_yieldValue('Foo');
1347
+ Scheduler.log('Foo');
1348
React.useEffect(() => {
1349
- Scheduler.unstable_yieldValue('Foo#effect');
1349
+ Scheduler.log('Foo#effect');
1350
});
1351
return (
1352
<div>
@@ -1627,7 +1627,7 @@ describe('ReactUpdates', () => {
1627
const [step, setStep] = React.useState(0);
1628
React.useEffect(() => {
1629
setStep(x => x + 1);
1630
- Scheduler.unstable_yieldValue(step);
1630
+ Scheduler.log(step);
1631
});
1632
return step;
1633
}
@@ -1650,7 +1650,7 @@ describe('ReactUpdates', () => {
1650
ReactDOM.render(<App />, container);
1651
while (error === null) {
1652
Scheduler.unstable_flushNumberOfYields(1);
1653
- Scheduler.unstable_clearYields();
1653
+ Scheduler.unstable_clearLog();
1654
}
1655
expect(error).toContain('Warning: Maximum update depth exceeded.');
1656
expect(stack).toContain(' NonTerminating');
@@ -1675,7 +1675,7 @@ describe('ReactUpdates', () => {
1675
setStep(x => x + 1);
1676
}
1677
});
1678
- Scheduler.unstable_yieldValue(step);
1678
+ Scheduler.log(step);
1679
return step;
1680
}
1681
@@ -1697,7 +1697,7 @@ describe('ReactUpdates', () => {
1697
for (let i = 0; i < 1000; i++) {
1698
setStep(x => x + 1);
1699
}
1700
- Scheduler.unstable_yieldValue('Done');
1700
+ Scheduler.log('Done');
1701
}, []);
1702
return step;
1703
}
packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js
+5
-5
@@ -94,16 +94,16 @@ function readText(text) {
94
if (record !== undefined) {
95
switch (record.status) {
96
case 'pending':
97
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
97
+ Scheduler.log(`Suspend! [${text}]`);
98
throw record.value;
99
case 'rejected':
100
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
100
+ Scheduler.log(`Error! [${text}]`);
101
throw record.value;
102
case 'resolved':
103
return textCache.version;
104
}
105
} else {
106
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
106
+ Scheduler.log(`Suspend! [${text}]`);
107
108
const thenable = {
109
pings: [],
@@ -127,14 +127,14 @@ function readText(text) {
127
}
128
129
function Text({text}) {
130
- Scheduler.unstable_yieldValue(text);
130
+ Scheduler.log(text);
131
return <span prop={text} />;
132
}
133
134
function AsyncText({text, showVersion}) {
135
const version = readText(text);
136
const fullText = showVersion ? `${text} [v${version}]` : text;
137
- Scheduler.unstable_yieldValue(fullText);
137
+ Scheduler.log(fullText);
138
return <span prop={fullText} />;
139
}
140
packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
+1
-1
@@ -1959,7 +1959,7 @@ describe('DOMPluginEventSystem', () => {
1959
});
1960
});
1961
1962
- Scheduler.unstable_yieldValue('Test');
1962
+ Scheduler.log('Test');
1963
return <button ref={ref}>Press me</button>;
1964
}
1965
packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js
+5
-5
@@ -512,7 +512,7 @@ describe('ChangeEventPlugin', () => {
512
state = {value: 'initial'};
513
onChange = event => this.setState({value: event.target.value});
514
render() {
515
- Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
515
+ Scheduler.log(`render: ${this.state.value}`);
516
const controlledValue =
517
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
518
return (
@@ -556,7 +556,7 @@ describe('ChangeEventPlugin', () => {
556
this.setState({checked: event.target.checked});
557
};
558
render() {
559
- Scheduler.unstable_yieldValue(`render: ${this.state.checked}`);
559
+ Scheduler.log(`render: ${this.state.checked}`);
560
const controlledValue = this.props.reverse
561
? !this.state.checked
562
: this.state.checked;
@@ -609,7 +609,7 @@ describe('ChangeEventPlugin', () => {
609
state = {value: 'initial'};
610
onChange = event => this.setState({value: event.target.value});
611
render() {
612
- Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
612
+ Scheduler.log(`render: ${this.state.value}`);
613
const controlledValue =
614
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
615
return (
@@ -651,7 +651,7 @@ describe('ChangeEventPlugin', () => {
651
state = {value: 'initial'};
652
onChange = event => this.setState({value: event.target.value});
653
render() {
654
- Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
654
+ Scheduler.log(`render: ${this.state.value}`);
655
const controlledValue =
656
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
657
return (
@@ -700,7 +700,7 @@ describe('ChangeEventPlugin', () => {
700
this.setState({value: ''});
701
};
702
render() {
703
- Scheduler.unstable_yieldValue(`render: ${this.state.value}`);
703
+ Scheduler.log(`render: ${this.state.value}`);
704
const controlledValue =
705
this.state.value === 'changed' ? 'changed [!]' : this.state.value;
706
return (
packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js
+3
-3
@@ -200,7 +200,7 @@ describe('SimpleEventPlugin', function () {
200
count: state.count + 1,
201
}));
202
componentDidUpdate() {
203
- Scheduler.unstable_yieldValue(`didUpdate - Count: ${this.state.count}`);
203
+ Scheduler.log(`didUpdate - Count: ${this.state.count}`);
204
}
205
render() {
206
return (
@@ -263,12 +263,12 @@ describe('SimpleEventPlugin', function () {
263
state = {disabled: false};
264
onClick = () => {
265
// Perform some side-effect
266
- Scheduler.unstable_yieldValue('Side-effect');
266
+ Scheduler.log('Side-effect');
267
// Disable the button
268
this.setState({disabled: true});
269
};
270
render() {
271
- Scheduler.unstable_yieldValue(
271
+ Scheduler.log(
272
`render button: ${this.state.disabled ? 'disabled' : 'enabled'}`,
273
);
274
return (
packages/react-noop-renderer/src/createReactNoop.js
+1
-1
@@ -980,7 +980,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
980
981
flushNextYield(): Array<mixed> {
982
Scheduler.unstable_flushNumberOfYields(1);
983
- return Scheduler.unstable_clearYields();
983
+ return Scheduler.unstable_clearLog();
984
},
985
986
flushWithHostCounters(fn: () => void):
packages/react-reconciler/src/ReactFiberDevToolsHook.js
+3
-3
@@ -35,7 +35,7 @@ import {
35
UserBlockingPriority as UserBlockingSchedulerPriority,
36
NormalPriority as NormalSchedulerPriority,
37
IdlePriority as IdleSchedulerPriority,
38
- unstable_yieldValue,
38
+ log,
39
unstable_setDisableYieldValue,
40
} from './Scheduler';
41
import {setSuppressWarning} from 'shared/consoleWithStackDev';
@@ -201,8 +201,8 @@ export function onCommitUnmount(fiber: Fiber) {
201
202
export function setIsStrictModeForDevtools(newIsStrictMode: boolean) {
203
if (consoleManagedByDevToolsDuringStrictMode) {
204
- if (typeof unstable_yieldValue === 'function') {
205
- // We're in a test because Scheduler.unstable_yieldValue only exists
204
+ if (typeof log === 'function') {
205
+ // We're in a test because Scheduler.log only exists
206
// in SchedulerMock. To reduce the noise in strict mode tests,
207
// suppress warnings and disable scheduler yielding during the double render
208
unstable_setDisableYieldValue(newIsStrictMode);
packages/react-reconciler/src/Scheduler.js
+1
-1
@@ -29,6 +29,6 @@ export type SchedulerCallback = (isSync: boolean) => SchedulerCallback | null;
29
30
// this doesn't actually exist on the scheduler, but it *does*
31
// on scheduler/unstable_mock, which we'll need for internal testing
32
-export const unstable_yieldValue = Scheduler.unstable_yieldValue;
32
+export const log = Scheduler.log;
33
export const unstable_setDisableYieldValue =
34
Scheduler.unstable_setDisableYieldValue;
packages/react-reconciler/src/__tests__/ReactActWarnings-test.js
+5
-5
@@ -87,16 +87,16 @@ describe('act warnings', () => {
87
if (record !== undefined) {
88
switch (record.status) {
89
case 'pending':
90
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
90
+ Scheduler.log(`Suspend! [${text}]`);
91
throw record.value;
92
case 'rejected':
93
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
93
+ Scheduler.log(`Error! [${text}]`);
94
throw record.value;
95
case 'resolved':
96
return textCache.version;
97
}
98
} else {
99
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
99
+ Scheduler.log(`Suspend! [${text}]`);
100
101
const thenable = {
102
pings: [],
@@ -120,13 +120,13 @@ describe('act warnings', () => {
120
}
121
122
function Text({text}) {
123
- Scheduler.unstable_yieldValue(text);
123
+ Scheduler.log(text);
124
return text;
125
}
126
127
function AsyncText({text}) {
128
readText(text);
129
- Scheduler.unstable_yieldValue(text);
129
+ Scheduler.log(text);
130
return text;
131
}
132
packages/react-reconciler/src/__tests__/ReactBatching-test.internal.js
+6
-6
@@ -28,7 +28,7 @@ describe('ReactBlockingMode', () => {
28
([text, ms = 0]) => {
29
return new Promise((resolve, reject) =>
30
setTimeout(() => {
31
- Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
31
+ Scheduler.log(`Promise resolved [${text}]`);
32
resolve(text);
33
}, ms),
34
);
@@ -38,7 +38,7 @@ describe('ReactBlockingMode', () => {
38
});
39
40
function Text(props) {
41
- Scheduler.unstable_yieldValue(props.text);
41
+ Scheduler.log(props.text);
42
return props.text;
43
}
44
@@ -46,13 +46,13 @@ describe('ReactBlockingMode', () => {
46
const text = props.text;
47
try {
48
TextResource.read([props.text, props.ms]);
49
- Scheduler.unstable_yieldValue(text);
49
+ Scheduler.log(text);
50
return props.text;
51
} catch (promise) {
52
if (typeof promise.then === 'function') {
53
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
53
+ Scheduler.log(`Suspend! [${text}]`);
54
} else {
55
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
55
+ Scheduler.log(`Error! [${text}]`);
56
}
57
throw promise;
58
}
@@ -81,7 +81,7 @@ describe('ReactBlockingMode', () => {
81
82
function App() {
83
useLayoutEffect(() => {
84
- Scheduler.unstable_yieldValue('Layout effect');
84
+ Scheduler.log('Layout effect');
85
});
86
return <Text text="Hi" />;
87
}
packages/react-reconciler/src/__tests__/ReactCPUSuspense-test.js
+5
-5
@@ -77,7 +77,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
77
// const record = textCache.get(text);
78
// if (record !== undefined) {
79
// if (record.status === 'pending') {
80
- // Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
80
+ // Scheduler.log(`Promise rejected [${text}]`);
81
// record.ping();
82
// record.status = 'rejected';
83
// clearTimeout(record.promise._timer);
@@ -95,7 +95,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
95
});
96
97
function Text(props) {
98
- Scheduler.unstable_yieldValue(props.text);
98
+ Scheduler.log(props.text);
99
return props.text;
100
}
101
@@ -103,13 +103,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
103
const text = props.text;
104
try {
105
readText(text);
106
- Scheduler.unstable_yieldValue(text);
106
+ Scheduler.log(text);
107
return text;
108
} catch (promise) {
109
if (typeof promise.then === 'function') {
110
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
110
+ Scheduler.log(`Suspend! [${text}]`);
111
} else {
112
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
112
+ Scheduler.log(`Error! [${text}]`);
113
}
114
throw promise;
115
}
packages/react-reconciler/src/__tests__/ReactCache-test.js
+5
-9
@@ -100,9 +100,7 @@ describe('ReactCache', () => {
100
record.cleanupScheduled = true;
101
if (getCacheSignal) {
102
signal.addEventListener('abort', () => {
103
- Scheduler.unstable_yieldValue(
104
- `Cache cleanup: ${text} [v${textCache.version}]`,
105
- );
103
+ Scheduler.log(`Cache cleanup: ${text} [v${textCache.version}]`);
104
});
105
}
106
}
@@ -115,7 +113,7 @@ describe('ReactCache', () => {
113
return textCache.version;
114
}
115
} else {
118
- Scheduler.unstable_yieldValue(`Cache miss! [${text}]`);
116
+ Scheduler.log(`Cache miss! [${text}]`);
117
118
let resolve;
119
let reject;
@@ -148,9 +146,7 @@ describe('ReactCache', () => {
146
147
if (getCacheSignal) {
148
signal.addEventListener('abort', () => {
151
- Scheduler.unstable_yieldValue(
152
- `Cache cleanup: ${text} [v${textCache.version}]`,
153
- );
149
+ Scheduler.log(`Cache cleanup: ${text} [v${textCache.version}]`);
150
});
151
}
152
throw thenable;
@@ -158,14 +154,14 @@ describe('ReactCache', () => {
154
}
155
156
function Text({text}) {
161
- Scheduler.unstable_yieldValue(text);
157
+ Scheduler.log(text);
158
return text;
159
}
160
161
function AsyncText({text, showVersion}) {
162
const version = readText(text);
163
const fullText = showVersion ? `${text} [v${version}]` : text;
168
- Scheduler.unstable_yieldValue(fullText);
164
+ Scheduler.log(fullText);
165
return fullText;
166
}
167
packages/react-reconciler/src/__tests__/ReactClassSetStateCallback-test.js
+4
-10
@@ -18,7 +18,7 @@ describe('ReactClassSetStateCallback', () => {
18
});
19
20
function Text({text}) {
21
- Scheduler.unstable_yieldValue(text);
21
+ Scheduler.log(text);
22
return text;
23
}
24
@@ -41,19 +41,13 @@ describe('ReactClassSetStateCallback', () => {
41
await act(async () => {
42
if (gate(flags => flags.enableUnifiedSyncLane)) {
43
React.startTransition(() => {
44
- app.setState({step: 1}, () =>
45
- Scheduler.unstable_yieldValue('Callback 1'),
46
- );
44
+ app.setState({step: 1}, () => Scheduler.log('Callback 1'));
45
});
46
} else {
49
- app.setState({step: 1}, () =>
50
- Scheduler.unstable_yieldValue('Callback 1'),
51
- );
47
+ app.setState({step: 1}, () => Scheduler.log('Callback 1'));
48
}
49
ReactNoop.flushSync(() => {
54
- app.setState({step: 2}, () =>
55
- Scheduler.unstable_yieldValue('Callback 2'),
56
- );
50
+ app.setState({step: 2}, () => Scheduler.log('Callback 2'));
51
});
52
});
53
assertLog([2, 'Callback 2', 2, 'Callback 1']);
packages/react-reconciler/src/__tests__/ReactConcurrentErrorRecovery-test.js
+5
-5
@@ -86,16 +86,16 @@ describe('ReactConcurrentErrorRecovery', () => {
86
if (record !== undefined) {
87
switch (record.status) {
88
case 'pending':
89
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
89
+ Scheduler.log(`Suspend! [${text}]`);
90
throw record.value;
91
case 'rejected':
92
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
92
+ Scheduler.log(`Error! [${text}]`);
93
throw record.value;
94
case 'resolved':
95
return textCache.version;
96
}
97
} else {
98
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
98
+ Scheduler.log(`Suspend! [${text}]`);
99
100
const thenable = {
101
pings: [],
@@ -119,14 +119,14 @@ describe('ReactConcurrentErrorRecovery', () => {
119
}
120
121
function Text({text}) {
122
- Scheduler.unstable_yieldValue(text);
122
+ Scheduler.log(text);
123
return text;
124
}
125
126
function AsyncText({text, showVersion}) {
127
const version = readText(text);
128
const fullText = showVersion ? `${text} [v${version}]` : text;
129
- Scheduler.unstable_yieldValue(fullText);
129
+ Scheduler.log(fullText);
130
return fullText;
131
}
132
packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js
+6
-6
@@ -96,16 +96,16 @@ describe('ReactLazyContextPropagation', () => {
96
if (record !== undefined) {
97
switch (record.status) {
98
case 'pending':
99
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
99
+ Scheduler.log(`Suspend! [${text}]`);
100
throw record.value;
101
case 'rejected':
102
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
102
+ Scheduler.log(`Error! [${text}]`);
103
throw record.value;
104
case 'resolved':
105
return textCache.version;
106
}
107
} else {
108
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
108
+ Scheduler.log(`Suspend! [${text}]`);
109
110
const thenable = {
111
pings: [],
@@ -129,14 +129,14 @@ describe('ReactLazyContextPropagation', () => {
129
}
130
131
function Text({text}) {
132
- Scheduler.unstable_yieldValue(text);
132
+ Scheduler.log(text);
133
return text;
134
}
135
136
// function AsyncText({text, showVersion}) {
137
// const version = readText(text);
138
// const fullText = showVersion ? `${text} [v${version}]` : text;
139
- // Scheduler.unstable_yieldValue(fullText);
139
+ // Scheduler.log(fullText);
140
// return text;
141
// }
142
@@ -321,7 +321,7 @@ describe('ReactLazyContextPropagation', () => {
321
const [, _setOtherValue] = useState(0);
322
setOtherValue = _setOtherValue;
323
324
- Scheduler.unstable_yieldValue('Consumer');
324
+ Scheduler.log('Consumer');
325
326
return <Text text={value} />;
327
});
packages/react-reconciler/src/__tests__/ReactDeferredValue-test.js
+1
-1
@@ -37,7 +37,7 @@ describe('ReactDeferredValue', () => {
37
});
38
39
function Text({text}) {
40
- Scheduler.unstable_yieldValue(text);
40
+ Scheduler.log(text);
41
return text;
42
}
43
packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js
+4
-4
@@ -29,7 +29,7 @@ describe('ReactSuspenseList', () => {
29
});
30
31
function Text(props) {
32
- Scheduler.unstable_yieldValue(props.text);
32
+ Scheduler.log(props.text);
33
return props.text;
34
}
35
@@ -37,7 +37,7 @@ describe('ReactSuspenseList', () => {
37
let resolved = false;
38
const Component = function () {
39
if (!resolved) {
40
- Scheduler.unstable_yieldValue('Suspend! [' + text + ']');
40
+ Scheduler.log('Suspend! [' + text + ']');
41
throw promise;
42
}
43
return <Text text={text} />;
@@ -79,11 +79,11 @@ describe('ReactSuspenseList', () => {
79
expect(root).toMatchRenderedOutput(null);
80
81
scheduleCallback(NormalPriority, () => {
82
- Scheduler.unstable_yieldValue('Resolve A');
82
+ Scheduler.log('Resolve A');
83
A.resolve();
84
});
85
scheduleCallback(NormalPriority, () => {
86
- Scheduler.unstable_yieldValue('Resolve B');
86
+ Scheduler.log('Resolve B');
87
B.resolve();
88
});
89
packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js
+4
-4
@@ -41,14 +41,14 @@ describe('ReactEffectOrdering', () => {
41
42
function Parent() {
43
useLayoutEffect(() => {
44
- return () => Scheduler.unstable_yieldValue('Unmount parent');
44
+ return () => Scheduler.log('Unmount parent');
45
});
46
return <Child />;
47
}
48
49
function Child() {
50
useLayoutEffect(() => {
51
- return () => Scheduler.unstable_yieldValue('Unmount child');
51
+ return () => Scheduler.log('Unmount child');
52
});
53
return 'Child';
54
}
@@ -68,14 +68,14 @@ describe('ReactEffectOrdering', () => {
68
69
function Parent() {
70
useEffect(() => {
71
- return () => Scheduler.unstable_yieldValue('Unmount parent');
71
+ return () => Scheduler.log('Unmount parent');
72
});
73
return <Child />;
74
}
75
76
function Child() {
77
useEffect(() => {
78
- return () => Scheduler.unstable_yieldValue('Unmount child');
78
+ return () => Scheduler.log('Unmount child');
79
});
80
return 'Child';
81
}
packages/react-reconciler/src/__tests__/ReactExpiration-test.js
+15
-21
@@ -69,7 +69,7 @@ describe('ReactExpiration', () => {
69
const record = textCache.get(text);
70
if (record !== undefined) {
71
if (record.status === 'pending') {
72
- Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
72
+ Scheduler.log(`Promise resolved [${text}]`);
73
record.ping();
74
record.ping = null;
75
record.status = 'resolved';
@@ -88,7 +88,7 @@ describe('ReactExpiration', () => {
88
});
89
90
function Text(props) {
91
- Scheduler.unstable_yieldValue(props.text);
91
+ Scheduler.log(props.text);
92
return props.text;
93
}
94
@@ -96,18 +96,18 @@ describe('ReactExpiration', () => {
96
const text = props.text;
97
try {
98
readText(text);
99
- Scheduler.unstable_yieldValue(text);
99
+ Scheduler.log(text);
100
return text;
101
} catch (promise) {
102
if (typeof promise.then === 'function') {
103
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
103
+ Scheduler.log(`Suspend! [${text}]`);
104
if (typeof props.ms === 'number' && promise._timer === undefined) {
105
promise._timer = setTimeout(() => {
106
resolveText(text);
107
}, props.ms);
108
}
109
} else {
110
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
110
+ Scheduler.log(`Error! [${text}]`);
111
}
112
throw promise;
113
}
@@ -147,13 +147,13 @@ describe('ReactExpiration', () => {
147
it('two updates of like priority in the same event always flush within the same batch', async () => {
148
class TextClass extends React.Component {
149
componentDidMount() {
150
- Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
150
+ Scheduler.log(`${this.props.text} [commit]`);
151
}
152
componentDidUpdate() {
153
- Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
153
+ Scheduler.log(`${this.props.text} [commit]`);
154
}
155
render() {
156
- Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
156
+ Scheduler.log(`${this.props.text} [render]`);
157
return <span prop={this.props.text} />;
158
}
159
}
@@ -204,13 +204,13 @@ describe('ReactExpiration', () => {
204
async () => {
205
class TextClass extends React.Component {
206
componentDidMount() {
207
- Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
207
+ Scheduler.log(`${this.props.text} [commit]`);
208
}
209
componentDidUpdate() {
210
- Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
210
+ Scheduler.log(`${this.props.text} [commit]`);
211
}
212
render() {
213
- Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
213
+ Scheduler.log(`${this.props.text} [render]`);
214
return <span prop={this.props.text} />;
215
}
216
}
@@ -268,19 +268,13 @@ describe('ReactExpiration', () => {
268
state = {text: store.text};
269
componentDidMount() {
270
subscribers.push(this);
271
- Scheduler.unstable_yieldValue(
272
- `${this.state.text} [${this.props.label}] [commit]`,
273
- );
271
+ Scheduler.log(`${this.state.text} [${this.props.label}] [commit]`);
272
}
273
componentDidUpdate() {
276
- Scheduler.unstable_yieldValue(
277
- `${this.state.text} [${this.props.label}] [commit]`,
278
- );
274
+ Scheduler.log(`${this.state.text} [${this.props.label}] [commit]`);
275
}
276
render() {
281
- Scheduler.unstable_yieldValue(
282
- `${this.state.text} [${this.props.label}] [render]`,
283
- );
277
+ Scheduler.log(`${this.state.text} [${this.props.label}] [render]`);
278
return <span prop={this.state.text} />;
279
}
280
}
@@ -717,7 +711,7 @@ describe('ReactExpiration', () => {
711
it('passive effects of expired update flush after paint', async () => {
712
function App({step}) {
713
useEffect(() => {
720
- Scheduler.unstable_yieldValue('Effect: ' + step);
714
+ Scheduler.log('Effect: ' + step);
715
}, [step]);
716
return (
717
<>
packages/react-reconciler/src/__tests__/ReactFlushSync-test.js
+6
-6
@@ -28,7 +28,7 @@ describe('ReactFlushSync', () => {
28
});
29
30
function Text({text}) {
31
- Scheduler.unstable_yieldValue(text);
31
+ Scheduler.log(text);
32
return text;
33
}
34
@@ -126,7 +126,7 @@ describe('ReactFlushSync', () => {
126
test('flushes passive effects synchronously when they are the result of a sync render', async () => {
127
function App() {
128
useEffect(() => {
129
- Scheduler.unstable_yieldValue('Effect');
129
+ Scheduler.log('Effect');
130
}, []);
131
return <Text text="Child" />;
132
}
@@ -149,7 +149,7 @@ describe('ReactFlushSync', () => {
149
test('do not flush passive effects synchronously after render in legacy mode', async () => {
150
function App() {
151
useEffect(() => {
152
- Scheduler.unstable_yieldValue('Effect');
152
+ Scheduler.log('Effect');
153
}, []);
154
return <Text text="Child" />;
155
}
@@ -176,7 +176,7 @@ describe('ReactFlushSync', () => {
176
function App({step}) {
177
useEffect(() => {
178
currentStep = step;
179
- Scheduler.unstable_yieldValue('Effect: ' + step);
179
+ Scheduler.log('Effect: ' + step);
180
}, [step]);
181
return <Text text={step} />;
182
}
@@ -207,7 +207,7 @@ describe('ReactFlushSync', () => {
207
test("do not flush passive effects synchronously when they aren't the result of a sync render", async () => {
208
function App() {
209
useEffect(() => {
210
- Scheduler.unstable_yieldValue('Effect');
210
+ Scheduler.log('Effect');
211
}, []);
212
return <Text text="Child" />;
213
}
@@ -229,7 +229,7 @@ describe('ReactFlushSync', () => {
229
test('does not flush pending passive effects', async () => {
230
function App() {
231
useEffect(() => {
232
- Scheduler.unstable_yieldValue('Effect');
232
+ Scheduler.log('Effect');
233
}, []);
234
return <Text text="Child" />;
235
}
packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
+22
-28
@@ -64,7 +64,7 @@ describe('ReactHooks', () => {
64
const {useState, useLayoutEffect} = React;
65
66
function Child({text}) {
67
- Scheduler.unstable_yieldValue('Child: ' + text);
67
+ Scheduler.log('Child: ' + text);
68
return text;
69
}
70
@@ -77,9 +77,9 @@ describe('ReactHooks', () => {
77
setCounter2 = _setCounter2;
78
79
const text = `${counter1}, ${counter2}`;
80
- Scheduler.unstable_yieldValue(`Parent: ${text}`);
80
+ Scheduler.log(`Parent: ${text}`);
81
useLayoutEffect(() => {
82
- Scheduler.unstable_yieldValue(`Effect: ${text}`);
82
+ Scheduler.log(`Effect: ${text}`);
83
});
84
return <Child text={text} />;
85
}
@@ -153,7 +153,7 @@ describe('ReactHooks', () => {
153
const {useState, memo} = React;
154
155
function Child({text}) {
156
- Scheduler.unstable_yieldValue('Child: ' + text);
156
+ Scheduler.log('Child: ' + text);
157
return text;
158
}
159
@@ -166,7 +166,7 @@ describe('ReactHooks', () => {
166
setCounter2 = _setCounter2;
167
168
const text = `${counter1}, ${counter2} (${theme})`;
169
- Scheduler.unstable_yieldValue(`Parent: ${text}`);
169
+ Scheduler.log(`Parent: ${text}`);
170
return <Child text={text} />;
171
}
172
@@ -226,7 +226,7 @@ describe('ReactHooks', () => {
226
const [counter, _setCounter] = useState(0);
227
setCounter = _setCounter;
228
229
- Scheduler.unstable_yieldValue(`Count: ${counter}`);
229
+ Scheduler.log(`Count: ${counter}`);
230
return counter;
231
}
232
@@ -260,7 +260,7 @@ describe('ReactHooks', () => {
260
const [counter, _dispatch] = useReducer((s, a) => a, 0);
261
dispatch = _dispatch;
262
263
- Scheduler.unstable_yieldValue(`Count: ${counter}`);
263
+ Scheduler.log(`Count: ${counter}`);
264
return counter;
265
}
266
@@ -294,7 +294,7 @@ describe('ReactHooks', () => {
294
let setTheme;
295
function ThemeProvider({children}) {
296
const [theme, _setTheme] = useState('light');
297
- Scheduler.unstable_yieldValue('Theme: ' + theme);
297
+ Scheduler.log('Theme: ' + theme);
298
setTheme = _setTheme;
299
return (
300
<ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
@@ -302,7 +302,7 @@ describe('ReactHooks', () => {
302
}
303
304
function Child({text}) {
305
- Scheduler.unstable_yieldValue('Child: ' + text);
305
+ Scheduler.log('Child: ' + text);
306
return text;
307
}
308
@@ -314,9 +314,9 @@ describe('ReactHooks', () => {
314
const theme = useContext(ThemeContext);
315
316
const text = `${counter} (${theme})`;
317
- Scheduler.unstable_yieldValue(`Parent: ${text}`);
317
+ Scheduler.log(`Parent: ${text}`);
318
useLayoutEffect(() => {
319
- Scheduler.unstable_yieldValue(`Effect: ${text}`);
319
+ Scheduler.log(`Effect: ${text}`);
320
});
321
return <Child text={text} />;
322
}
@@ -373,7 +373,7 @@ describe('ReactHooks', () => {
373
const {useState, useLayoutEffect} = React;
374
375
function Child({text}) {
376
- Scheduler.unstable_yieldValue('Child: ' + text);
376
+ Scheduler.log('Child: ' + text);
377
return text;
378
}
379
@@ -381,9 +381,9 @@ describe('ReactHooks', () => {
381
function Parent() {
382
const [counter, _setCounter] = useState(0);
383
setCounter = _setCounter;
384
- Scheduler.unstable_yieldValue('Parent: ' + counter);
384
+ Scheduler.log('Parent: ' + counter);
385
useLayoutEffect(() => {
386
- Scheduler.unstable_yieldValue('Effect: ' + counter);
386
+ Scheduler.log('Effect: ' + counter);
387
});
388
return <Child text={counter} />;
389
}
@@ -451,7 +451,7 @@ describe('ReactHooks', () => {
451
const {useState} = React;
452
453
function Child({text}) {
454
- Scheduler.unstable_yieldValue('Child: ' + text);
454
+ Scheduler.log('Child: ' + text);
455
return text;
456
}
457
@@ -459,7 +459,7 @@ describe('ReactHooks', () => {
459
function Parent() {
460
const [counter, _setCounter] = useState(0);
461
setCounter = _setCounter;
462
- Scheduler.unstable_yieldValue('Parent: ' + counter);
462
+ Scheduler.log('Parent: ' + counter);
463
return <Child text={counter} />;
464
}
465
@@ -470,9 +470,7 @@ describe('ReactHooks', () => {
470
471
const update = value => {
472
setCounter(previous => {
473
- Scheduler.unstable_yieldValue(
474
- `Compute state (${previous} -> ${value})`,
475
- );
473
+ Scheduler.log(`Compute state (${previous} -> ${value})`);
474
return value;
475
});
476
};
@@ -511,7 +509,7 @@ describe('ReactHooks', () => {
509
const {useState} = React;
510
511
function Child({text}) {
514
- Scheduler.unstable_yieldValue('Child: ' + text);
512
+ Scheduler.log('Child: ' + text);
513
return text;
514
}
515
@@ -519,7 +517,7 @@ describe('ReactHooks', () => {
517
function Parent() {
518
const [counter, _setCounter] = useState(1);
519
setCounter = _setCounter;
522
- Scheduler.unstable_yieldValue('Parent: ' + counter);
520
+ Scheduler.log('Parent: ' + counter);
521
return <Child text={counter} />;
522
}
523
@@ -531,9 +529,7 @@ describe('ReactHooks', () => {
529
const update = compute => {
530
setCounter(previous => {
531
const value = compute(previous);
534
- Scheduler.unstable_yieldValue(
535
- `Compute state (${previous} -> ${value})`,
536
- );
532
+ Scheduler.log(`Compute state (${previous} -> ${value})`);
533
return value;
534
});
535
};
@@ -575,9 +571,7 @@ describe('ReactHooks', () => {
571
const {useLayoutEffect} = React;
572
function App(props) {
573
useLayoutEffect(() => {
578
- Scheduler.unstable_yieldValue(
579
- 'Did commit: ' + props.dependencies.join(', '),
580
- );
574
+ Scheduler.log('Did commit: ' + props.dependencies.join(', '));
575
}, props.dependencies);
576
return props.dependencies;
577
}
@@ -599,7 +593,7 @@ describe('ReactHooks', () => {
593
function App({text, hasDeps}) {
594
const resolvedText = useMemo(
595
() => {
602
- Scheduler.unstable_yieldValue('Compute');
596
+ Scheduler.log('Compute');
597
return text.toUpperCase();
598
},
599
hasDeps ? null : [text],
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+245
-289
@@ -107,7 +107,7 @@ describe('ReactHooksWithNoopRenderer', () => {
107
const record = textCache.get(text);
108
if (record !== undefined) {
109
if (record.status === 'pending') {
110
- Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
110
+ Scheduler.log(`Promise resolved [${text}]`);
111
record.ping();
112
record.ping = null;
113
record.status = 'resolved';
@@ -126,7 +126,7 @@ describe('ReactHooksWithNoopRenderer', () => {
126
});
127
128
function Text(props) {
129
- Scheduler.unstable_yieldValue(props.text);
129
+ Scheduler.log(props.text);
130
return <span prop={props.text} />;
131
}
132
@@ -134,18 +134,18 @@ describe('ReactHooksWithNoopRenderer', () => {
134
const text = props.text;
135
try {
136
readText(text);
137
- Scheduler.unstable_yieldValue(text);
137
+ Scheduler.log(text);
138
return <span prop={text} />;
139
} catch (promise) {
140
if (typeof promise.then === 'function') {
141
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
141
+ Scheduler.log(`Suspend! [${text}]`);
142
if (typeof props.ms === 'number' && promise._timer === undefined) {
143
promise._timer = setTimeout(() => {
144
resolveText(text);
145
}, props.ms);
146
}
147
} else {
148
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
148
+ Scheduler.log(`Error! [${text}]`);
149
}
150
throw promise;
151
}
@@ -306,7 +306,7 @@ describe('ReactHooksWithNoopRenderer', () => {
306
it('lazy state initializer', async () => {
307
function Counter(props, ref) {
308
const [count, updateCount] = useState(() => {
309
- Scheduler.unstable_yieldValue('getInitialState');
309
+ Scheduler.log('getInitialState');
310
return props.initialState;
311
});
312
useImperativeHandle(ref, () => ({updateCount}));
@@ -518,7 +518,7 @@ describe('ReactHooksWithNoopRenderer', () => {
518
if (count < 3) {
519
setCount(count + 1);
520
}
521
- Scheduler.unstable_yieldValue('Render: ' + count);
521
+ Scheduler.log('Render: ' + count);
522
return <Text text={count} />;
523
}
524
@@ -535,7 +535,7 @@ describe('ReactHooksWithNoopRenderer', () => {
535
setCount(c => c + 1);
536
setCount(c => c + 1);
537
}
538
- Scheduler.unstable_yieldValue('Render: ' + count);
538
+ Scheduler.log('Render: ' + count);
539
return <Text text={count} />;
540
}
541
@@ -556,7 +556,7 @@ describe('ReactHooksWithNoopRenderer', () => {
556
function Counter({row: newRow}) {
557
const [count, setCount] = useState(0);
558
setCount(count + 1);
559
- Scheduler.unstable_yieldValue('Render: ' + count);
559
+ Scheduler.log('Render: ' + count);
560
return <Text text={count} />;
561
}
562
ReactNoop.render(<Counter />);
@@ -575,7 +575,7 @@ describe('ReactHooksWithNoopRenderer', () => {
575
if (count < 3) {
576
dispatch('increment');
577
}
578
- Scheduler.unstable_yieldValue('Render: ' + count);
578
+ Scheduler.log('Render: ' + count);
579
return <Text text={count} />;
580
}
581
@@ -618,7 +618,7 @@ describe('ReactHooksWithNoopRenderer', () => {
618
setReducer(() => reducerA);
619
}
620
}
621
- Scheduler.unstable_yieldValue('Render: ' + count);
621
+ Scheduler.log('Render: ' + count);
622
return <Text text={count} />;
623
}
624
Counter = forwardRef(Counter);
@@ -673,7 +673,7 @@ describe('ReactHooksWithNoopRenderer', () => {
673
if (counter === 0) {
674
// We're suspending during a render that includes render phase
675
// updates. Those updates should not persist to the next render.
676
- Scheduler.unstable_yieldValue('Suspend!');
676
+ Scheduler.log('Suspend!');
677
throw thenable;
678
}
679
}
@@ -717,7 +717,7 @@ describe('ReactHooksWithNoopRenderer', () => {
717
if (counter === 1) {
718
// We're suspending during a render that includes render phase
719
// updates. Those updates should not persist to the next render.
720
- Scheduler.unstable_yieldValue('Suspend!');
720
+ Scheduler.log('Suspend!');
721
throw thenable;
722
}
723
@@ -881,7 +881,7 @@ describe('ReactHooksWithNoopRenderer', () => {
881
882
function Counter(props, ref) {
883
const [count, dispatch] = useReducer(reducer, props, p => {
884
- Scheduler.unstable_yieldValue('Init');
884
+ Scheduler.log('Init');
885
return p.initialCount;
886
});
887
useImperativeHandle(ref, () => ({dispatch}));
@@ -953,13 +953,13 @@ describe('ReactHooksWithNoopRenderer', () => {
953
it('simple mount and update', async () => {
954
function Counter(props) {
955
useEffect(() => {
956
- Scheduler.unstable_yieldValue(`Passive effect [${props.count}]`);
956
+ Scheduler.log(`Passive effect [${props.count}]`);
957
});
958
return <Text text={'Count: ' + props.count} />;
959
}
960
await act(async () => {
961
ReactNoop.render(<Counter count={0} />, () =>
962
- Scheduler.unstable_yieldValue('Sync effect'),
962
+ Scheduler.log('Sync effect'),
963
);
964
await waitFor(['Count: 0', 'Sync effect']);
965
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -969,7 +969,7 @@ describe('ReactHooksWithNoopRenderer', () => {
969
970
await act(async () => {
971
ReactNoop.render(<Counter count={1} />, () =>
972
- Scheduler.unstable_yieldValue('Sync effect'),
972
+ Scheduler.log('Sync effect'),
973
);
974
await waitFor(['Count: 1', 'Sync effect']);
975
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -981,13 +981,13 @@ describe('ReactHooksWithNoopRenderer', () => {
981
it('flushes passive effects even with sibling deletions', async () => {
982
function LayoutEffect(props) {
983
useLayoutEffect(() => {
984
- Scheduler.unstable_yieldValue(`Layout effect`);
984
+ Scheduler.log(`Layout effect`);
985
});
986
return <Text text="Layout" />;
987
}
988
function PassiveEffect(props) {
989
useEffect(() => {
990
- Scheduler.unstable_yieldValue(`Passive effect`);
990
+ Scheduler.log(`Passive effect`);
991
}, []);
992
return <Text text="Passive" />;
993
}
@@ -1014,7 +1014,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1014
it('flushes passive effects even if siblings schedule an update', async () => {
1015
function PassiveEffect(props) {
1016
useEffect(() => {
1017
- Scheduler.unstable_yieldValue('Passive effect');
1017
+ Scheduler.log('Passive effect');
1018
});
1019
return <Text text="Passive" />;
1020
}
@@ -1025,7 +1025,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1025
if (count === 0) {
1026
setCount(1);
1027
}
1028
- Scheduler.unstable_yieldValue('Layout effect ' + count);
1028
+ Scheduler.log('Layout effect ' + count);
1029
});
1030
return <Text text="Layout" />;
1031
}
@@ -1054,13 +1054,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1054
it('flushes passive effects even if siblings schedule a new root', async () => {
1055
function PassiveEffect(props) {
1056
useEffect(() => {
1057
- Scheduler.unstable_yieldValue('Passive effect');
1057
+ Scheduler.log('Passive effect');
1058
}, []);
1059
return <Text text="Passive" />;
1060
}
1061
function LayoutEffect(props) {
1062
useLayoutEffect(() => {
1063
- Scheduler.unstable_yieldValue('Layout effect');
1063
+ Scheduler.log('Layout effect');
1064
// Scheduling work shouldn't interfere with the queued passive effect
1065
ReactNoop.renderToRootWithID(<Text text="New Root" />, 'root2');
1066
});
@@ -1098,7 +1098,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1098
1099
function Counter(props) {
1100
useEffect(() => {
1101
- Scheduler.unstable_yieldValue(
1101
+ Scheduler.log(
1102
`Committed state when effect was fired: ${getCommittedText()}`,
1103
);
1104
});
@@ -1106,13 +1106,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1106
}
1107
await act(async () => {
1108
ReactNoop.render(<Counter count={0} />, () =>
1109
- Scheduler.unstable_yieldValue('Sync effect'),
1109
+ Scheduler.log('Sync effect'),
1110
);
1111
await waitFor([0, 'Sync effect']);
1112
expect(ReactNoop).toMatchRenderedOutput(<span prop={0} />);
1113
// Before the effects have a chance to flush, schedule another update
1114
ReactNoop.render(<Counter count={1} />, () =>
1115
- Scheduler.unstable_yieldValue('Sync effect'),
1115
+ Scheduler.log('Sync effect'),
1116
);
1117
await waitFor([
1118
// The previous effect flushes before the reconciliation
@@ -1130,36 +1130,36 @@ describe('ReactHooksWithNoopRenderer', () => {
1130
it('defers passive effect destroy functions during unmount', async () => {
1131
function Child({bar, foo}) {
1132
React.useEffect(() => {
1133
- Scheduler.unstable_yieldValue('passive bar create');
1133
+ Scheduler.log('passive bar create');
1134
return () => {
1135
- Scheduler.unstable_yieldValue('passive bar destroy');
1135
+ Scheduler.log('passive bar destroy');
1136
};
1137
}, [bar]);
1138
React.useLayoutEffect(() => {
1139
- Scheduler.unstable_yieldValue('layout bar create');
1139
+ Scheduler.log('layout bar create');
1140
return () => {
1141
- Scheduler.unstable_yieldValue('layout bar destroy');
1141
+ Scheduler.log('layout bar destroy');
1142
};
1143
}, [bar]);
1144
React.useEffect(() => {
1145
- Scheduler.unstable_yieldValue('passive foo create');
1145
+ Scheduler.log('passive foo create');
1146
return () => {
1147
- Scheduler.unstable_yieldValue('passive foo destroy');
1147
+ Scheduler.log('passive foo destroy');
1148
};
1149
}, [foo]);
1150
React.useLayoutEffect(() => {
1151
- Scheduler.unstable_yieldValue('layout foo create');
1151
+ Scheduler.log('layout foo create');
1152
return () => {
1153
- Scheduler.unstable_yieldValue('layout foo destroy');
1153
+ Scheduler.log('layout foo destroy');
1154
};
1155
}, [foo]);
1156
- Scheduler.unstable_yieldValue('render');
1156
+ Scheduler.log('render');
1157
return null;
1158
}
1159
1160
await act(async () => {
1161
ReactNoop.render(<Child bar={1} foo={1} />, () =>
1162
- Scheduler.unstable_yieldValue('Sync effect'),
1162
+ Scheduler.log('Sync effect'),
1163
);
1164
await waitFor([
1165
'render',
@@ -1175,7 +1175,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1175
// Effects without updating dependencies lose their layout/passive tag during an update.
1176
await act(async () => {
1177
ReactNoop.render(<Child bar={1} foo={2} />, () =>
1178
- Scheduler.unstable_yieldValue('Sync effect'),
1178
+ Scheduler.log('Sync effect'),
1179
);
1180
await waitFor([
1181
'render',
@@ -1189,9 +1189,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1189
1190
// Unmount the component and verify that passive destroy functions are deferred until post-commit.
1191
await act(async () => {
1192
- ReactNoop.render(null, () =>
1193
- Scheduler.unstable_yieldValue('Sync effect'),
1194
- );
1192
+ ReactNoop.render(null, () => Scheduler.log('Sync effect'));
1193
await waitFor([
1194
'layout bar destroy',
1195
'layout foo destroy',
@@ -1205,20 +1203,20 @@ describe('ReactHooksWithNoopRenderer', () => {
1203
it('does not warn about state updates for unmounted components with pending passive unmounts', async () => {
1204
let completePendingRequest = null;
1205
function Component() {
1208
- Scheduler.unstable_yieldValue('Component');
1206
+ Scheduler.log('Component');
1207
const [didLoad, setDidLoad] = React.useState(false);
1208
React.useLayoutEffect(() => {
1211
- Scheduler.unstable_yieldValue('layout create');
1209
+ Scheduler.log('layout create');
1210
return () => {
1213
- Scheduler.unstable_yieldValue('layout destroy');
1211
+ Scheduler.log('layout destroy');
1212
};
1213
}, []);
1214
React.useEffect(() => {
1217
- Scheduler.unstable_yieldValue('passive create');
1215
+ Scheduler.log('passive create');
1216
// Mimic an XHR request with a complete handler that updates state.
1217
completePendingRequest = () => setDidLoad(true);
1218
return () => {
1221
- Scheduler.unstable_yieldValue('passive destroy');
1219
+ Scheduler.log('passive destroy');
1220
};
1221
}, []);
1222
return didLoad;
@@ -1226,7 +1224,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1224
1225
await act(async () => {
1226
ReactNoop.renderToRootWithID(<Component />, 'root', () =>
1229
- Scheduler.unstable_yieldValue('Sync effect'),
1227
+ Scheduler.log('Sync effect'),
1228
);
1229
await waitFor(['Component', 'layout create', 'Sync effect']);
1230
ReactNoop.flushPassiveEffects();
@@ -1252,9 +1250,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1250
function Parent() {
1251
const [state, setState] = useState(true);
1252
setParentState = setState;
1255
- Scheduler.unstable_yieldValue(`Parent ${state} render`);
1253
+ Scheduler.log(`Parent ${state} render`);
1254
useLayoutEffect(() => {
1257
- Scheduler.unstable_yieldValue(`Parent ${state} commit`);
1255
+ Scheduler.log(`Parent ${state} commit`);
1256
});
1257
if (state) {
1258
return (
@@ -1271,16 +1269,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1269
function Child({label}) {
1270
const [state, setState] = useState(0);
1271
useLayoutEffect(() => {
1274
- Scheduler.unstable_yieldValue(`Child ${label} commit`);
1272
+ Scheduler.log(`Child ${label} commit`);
1273
});
1274
useEffect(() => {
1275
setChildStates.push(setState);
1278
- Scheduler.unstable_yieldValue(`Child ${label} passive create`);
1276
+ Scheduler.log(`Child ${label} passive create`);
1277
return () => {
1280
- Scheduler.unstable_yieldValue(`Child ${label} passive destroy`);
1278
+ Scheduler.log(`Child ${label} passive destroy`);
1279
};
1280
}, []);
1283
- Scheduler.unstable_yieldValue(`Child ${label} render`);
1281
+ Scheduler.log(`Child ${label} render`);
1282
return state;
1283
}
1284
@@ -1334,14 +1332,14 @@ describe('ReactHooksWithNoopRenderer', () => {
1332
it('does not warn about state updates for unmounted components with no pending passive unmounts', async () => {
1333
let completePendingRequest = null;
1334
function Component() {
1337
- Scheduler.unstable_yieldValue('Component');
1335
+ Scheduler.log('Component');
1336
const [didLoad, setDidLoad] = React.useState(false);
1337
React.useLayoutEffect(() => {
1340
- Scheduler.unstable_yieldValue('layout create');
1338
+ Scheduler.log('layout create');
1339
// Mimic an XHR request with a complete handler that updates state.
1340
completePendingRequest = () => setDidLoad(true);
1341
return () => {
1344
- Scheduler.unstable_yieldValue('layout destroy');
1342
+ Scheduler.log('layout destroy');
1343
};
1344
}, []);
1345
return didLoad;
@@ -1349,7 +1347,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1347
1348
await act(async () => {
1349
ReactNoop.renderToRootWithID(<Component />, 'root', () =>
1352
- Scheduler.unstable_yieldValue('Sync effect'),
1350
+ Scheduler.log('Sync effect'),
1351
);
1352
await waitFor(['Component', 'layout create', 'Sync effect']);
1353
@@ -1365,16 +1363,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1363
it('does not warn if there are pending passive unmount effects but not for the current fiber', async () => {
1364
let completePendingRequest = null;
1365
function ComponentWithXHR() {
1368
- Scheduler.unstable_yieldValue('Component');
1366
+ Scheduler.log('Component');
1367
const [didLoad, setDidLoad] = React.useState(false);
1368
React.useLayoutEffect(() => {
1371
- Scheduler.unstable_yieldValue('a:layout create');
1369
+ Scheduler.log('a:layout create');
1370
return () => {
1373
- Scheduler.unstable_yieldValue('a:layout destroy');
1371
+ Scheduler.log('a:layout destroy');
1372
};
1373
}, []);
1374
React.useEffect(() => {
1377
- Scheduler.unstable_yieldValue('a:passive create');
1375
+ Scheduler.log('a:passive create');
1376
// Mimic an XHR request with a complete handler that updates state.
1377
completePendingRequest = () => setDidLoad(true);
1378
}, []);
@@ -1383,9 +1381,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1381
1382
function ComponentWithPendingPassiveUnmount() {
1383
React.useEffect(() => {
1386
- Scheduler.unstable_yieldValue('b:passive create');
1384
+ Scheduler.log('b:passive create');
1385
return () => {
1388
- Scheduler.unstable_yieldValue('b:passive destroy');
1386
+ Scheduler.log('b:passive destroy');
1387
};
1388
}, []);
1389
return null;
@@ -1398,7 +1396,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1396
<ComponentWithPendingPassiveUnmount />
1397
</>,
1398
'root',
1401
- () => Scheduler.unstable_yieldValue('Sync effect'),
1399
+ () => Scheduler.log('Sync effect'),
1400
);
1401
await waitFor(['Component', 'a:layout create', 'Sync effect']);
1402
ReactNoop.flushPassiveEffects();
@@ -1417,13 +1415,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1415
let updaterFunction;
1416
1417
function Component() {
1420
- Scheduler.unstable_yieldValue('Component');
1418
+ Scheduler.log('Component');
1419
const [state, setState] = React.useState(false);
1420
updaterFunction = setState;
1421
React.useEffect(() => {
1424
- Scheduler.unstable_yieldValue('passive create');
1422
+ Scheduler.log('passive create');
1423
return () => {
1426
- Scheduler.unstable_yieldValue('passive destroy');
1424
+ Scheduler.log('passive destroy');
1425
};
1426
}, []);
1427
return state;
@@ -1431,7 +1429,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1429
1430
act(() => {
1431
ReactNoop.renderToRootWithID(<Component />, 'root', () =>
1434
- Scheduler.unstable_yieldValue('Sync effect'),
1432
+ Scheduler.log('Sync effect'),
1433
);
1434
});
1435
assertLog(['Component', 'Sync effect', 'passive create']);
@@ -1446,13 +1444,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1444
1445
it('does not show a warning when a component updates its own state from within passive unmount function', async () => {
1446
function Component() {
1449
- Scheduler.unstable_yieldValue('Component');
1447
+ Scheduler.log('Component');
1448
const [didLoad, setDidLoad] = React.useState(false);
1449
React.useEffect(() => {
1452
- Scheduler.unstable_yieldValue('passive create');
1450
+ Scheduler.log('passive create');
1451
return () => {
1452
setDidLoad(true);
1455
- Scheduler.unstable_yieldValue('passive destroy');
1453
+ Scheduler.log('passive destroy');
1454
};
1455
}, []);
1456
return didLoad;
@@ -1460,7 +1458,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1458
1459
await act(async () => {
1460
ReactNoop.renderToRootWithID(<Component />, 'root', () =>
1463
- Scheduler.unstable_yieldValue('Sync effect'),
1461
+ Scheduler.log('Sync effect'),
1462
);
1463
await waitFor(['Component', 'Sync effect', 'passive create']);
1464
@@ -1472,23 +1470,23 @@ describe('ReactHooksWithNoopRenderer', () => {
1470
1471
it('does not show a warning when a component updates a child state from within passive unmount function', async () => {
1472
function Parent() {
1475
- Scheduler.unstable_yieldValue('Parent');
1473
+ Scheduler.log('Parent');
1474
const updaterRef = useRef(null);
1475
React.useEffect(() => {
1478
- Scheduler.unstable_yieldValue('Parent passive create');
1476
+ Scheduler.log('Parent passive create');
1477
return () => {
1478
updaterRef.current(true);
1481
- Scheduler.unstable_yieldValue('Parent passive destroy');
1479
+ Scheduler.log('Parent passive destroy');
1480
};
1481
}, []);
1482
return <Child updaterRef={updaterRef} />;
1483
}
1484
1485
function Child({updaterRef}) {
1488
- Scheduler.unstable_yieldValue('Child');
1486
+ Scheduler.log('Child');
1487
const [state, setState] = React.useState(false);
1488
React.useEffect(() => {
1491
- Scheduler.unstable_yieldValue('Child passive create');
1489
+ Scheduler.log('Child passive create');
1490
updaterRef.current = setState;
1491
}, []);
1492
return state;
@@ -1512,16 +1510,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1510
it('does not show a warning when a component updates a parents state from within passive unmount function', async () => {
1511
function Parent() {
1512
const [state, setState] = React.useState(false);
1515
- Scheduler.unstable_yieldValue('Parent');
1513
+ Scheduler.log('Parent');
1514
return <Child setState={setState} state={state} />;
1515
}
1516
1517
function Child({setState, state}) {
1520
- Scheduler.unstable_yieldValue('Child');
1518
+ Scheduler.log('Child');
1519
React.useEffect(() => {
1522
- Scheduler.unstable_yieldValue('Child passive create');
1520
+ Scheduler.log('Child passive create');
1521
return () => {
1524
- Scheduler.unstable_yieldValue('Child passive destroy');
1522
+ Scheduler.log('Child passive destroy');
1523
setState(true);
1524
};
1525
}, []);
@@ -1542,14 +1540,14 @@ describe('ReactHooksWithNoopRenderer', () => {
1540
function Counter(props) {
1541
const [count, updateCount] = useState('(empty)');
1542
useEffect(() => {
1545
- Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
1543
+ Scheduler.log(`Schedule update [${props.count}]`);
1544
updateCount(props.count);
1545
}, [props.count]);
1546
return <Text text={'Count: ' + count} />;
1547
}
1548
await act(async () => {
1549
ReactNoop.render(<Counter count={0} />, () =>
1552
- Scheduler.unstable_yieldValue('Sync effect'),
1550
+ Scheduler.log('Sync effect'),
1551
);
1552
await waitFor(['Count: (empty)', 'Sync effect']);
1553
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: (empty)" />);
@@ -1560,7 +1558,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1558
1559
await act(async () => {
1560
ReactNoop.render(<Counter count={1} />, () =>
1563
- Scheduler.unstable_yieldValue('Sync effect'),
1561
+ Scheduler.log('Sync effect'),
1562
);
1563
await waitFor(['Count: 0', 'Sync effect']);
1564
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1574,14 +1572,14 @@ describe('ReactHooksWithNoopRenderer', () => {
1572
function Counter(props) {
1573
const [count, updateCount] = useState('(empty)');
1574
useEffect(() => {
1577
- Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
1575
+ Scheduler.log(`Schedule update [${props.count}]`);
1576
updateCount(props.count);
1577
}, [props.count]);
1578
return <Text text={'Count: ' + count} />;
1579
}
1580
await act(async () => {
1581
ReactNoop.render(<Counter count={0} />, () =>
1584
- Scheduler.unstable_yieldValue('Sync effect'),
1582
+ Scheduler.log('Sync effect'),
1583
);
1584
await waitFor(['Count: (empty)', 'Sync effect']);
1585
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: (empty)" />);
@@ -1589,7 +1587,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1587
// Rendering again should flush the previous commit's effects
1588
React.startTransition(() => {
1589
ReactNoop.render(<Counter count={1} />, () =>
1592
- Scheduler.unstable_yieldValue('Sync effect'),
1590
+ Scheduler.log('Sync effect'),
1591
);
1592
});
1593
@@ -1613,14 +1611,14 @@ describe('ReactHooksWithNoopRenderer', () => {
1611
const [count, updateCount] = useState(0);
1612
_updateCount = updateCount;
1613
useEffect(() => {
1616
- Scheduler.unstable_yieldValue(`Will set count to 1`);
1614
+ Scheduler.log(`Will set count to 1`);
1615
updateCount(1);
1616
}, []);
1617
return <Text text={'Count: ' + count} />;
1618
}
1619
1620
ReactNoop.render(<Counter count={0} />, () =>
1623
- Scheduler.unstable_yieldValue('Sync effect'),
1621
+ Scheduler.log('Sync effect'),
1622
);
1623
await waitFor(['Count: 0', 'Sync effect']);
1624
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1686,7 +1684,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1684
function Counter(props) {
1685
const [count, updateCount] = useState('(empty)');
1686
useEffect(() => {
1689
- Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
1687
+ Scheduler.log(`Schedule update [${props.count}]`);
1688
ReactNoop.flushSync(() => {
1689
updateCount(props.count);
1690
});
@@ -1701,7 +1699,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1699
await expect(async () => {
1700
await act(async () => {
1701
ReactNoop.render(<Counter count={0} />, () =>
1704
- Scheduler.unstable_yieldValue('Sync effect'),
1702
+ Scheduler.log('Sync effect'),
1703
);
1704
await waitFor(['Count: (empty)', 'Sync effect']);
1705
expect(ReactNoop).toMatchRenderedOutput(
@@ -1716,16 +1714,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1714
it('unmounts previous effect', async () => {
1715
function Counter(props) {
1716
useEffect(() => {
1719
- Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1717
+ Scheduler.log(`Did create [${props.count}]`);
1718
return () => {
1721
- Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1719
+ Scheduler.log(`Did destroy [${props.count}]`);
1720
};
1721
});
1722
return <Text text={'Count: ' + props.count} />;
1723
}
1724
await act(async () => {
1725
ReactNoop.render(<Counter count={0} />, () =>
1728
- Scheduler.unstable_yieldValue('Sync effect'),
1726
+ Scheduler.log('Sync effect'),
1727
);
1728
await waitFor(['Count: 0', 'Sync effect']);
1729
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1735,7 +1733,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1733
1734
await act(async () => {
1735
ReactNoop.render(<Counter count={1} />, () =>
1738
- Scheduler.unstable_yieldValue('Sync effect'),
1736
+ Scheduler.log('Sync effect'),
1737
);
1738
await waitFor(['Count: 1', 'Sync effect']);
1739
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -1747,16 +1745,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1745
it('unmounts on deletion', async () => {
1746
function Counter(props) {
1747
useEffect(() => {
1750
- Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1748
+ Scheduler.log(`Did create [${props.count}]`);
1749
return () => {
1752
- Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1750
+ Scheduler.log(`Did destroy [${props.count}]`);
1751
};
1752
});
1753
return <Text text={'Count: ' + props.count} />;
1754
}
1755
await act(async () => {
1756
ReactNoop.render(<Counter count={0} />, () =>
1759
- Scheduler.unstable_yieldValue('Sync effect'),
1757
+ Scheduler.log('Sync effect'),
1758
);
1759
await waitFor(['Count: 0', 'Sync effect']);
1760
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1772,16 +1770,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1770
it('unmounts on deletion after skipped effect', async () => {
1771
function Counter(props) {
1772
useEffect(() => {
1775
- Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1773
+ Scheduler.log(`Did create [${props.count}]`);
1774
return () => {
1777
- Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1775
+ Scheduler.log(`Did destroy [${props.count}]`);
1776
};
1777
}, []);
1778
return <Text text={'Count: ' + props.count} />;
1779
}
1780
await act(async () => {
1781
ReactNoop.render(<Counter count={0} />, () =>
1784
- Scheduler.unstable_yieldValue('Sync effect'),
1782
+ Scheduler.log('Sync effect'),
1783
);
1784
await waitFor(['Count: 0', 'Sync effect']);
1785
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1791,7 +1789,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1789
1790
await act(async () => {
1791
ReactNoop.render(<Counter count={1} />, () =>
1794
- Scheduler.unstable_yieldValue('Sync effect'),
1792
+ Scheduler.log('Sync effect'),
1793
);
1794
await waitFor(['Count: 1', 'Sync effect']);
1795
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -1806,9 +1804,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1804
1805
it('always fires effects if no dependencies are provided', async () => {
1806
function effect() {
1809
- Scheduler.unstable_yieldValue(`Did create`);
1807
+ Scheduler.log(`Did create`);
1808
return () => {
1811
- Scheduler.unstable_yieldValue(`Did destroy`);
1809
+ Scheduler.log(`Did destroy`);
1810
};
1811
}
1812
function Counter(props) {
@@ -1817,7 +1815,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1815
}
1816
await act(async () => {
1817
ReactNoop.render(<Counter count={0} />, () =>
1820
- Scheduler.unstable_yieldValue('Sync effect'),
1818
+ Scheduler.log('Sync effect'),
1819
);
1820
await waitFor(['Count: 0', 'Sync effect']);
1821
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1827,7 +1825,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1825
1826
await act(async () => {
1827
ReactNoop.render(<Counter count={1} />, () =>
1830
- Scheduler.unstable_yieldValue('Sync effect'),
1828
+ Scheduler.log('Sync effect'),
1829
);
1830
await waitFor(['Count: 1', 'Sync effect']);
1831
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -1844,16 +1842,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1842
function Counter(props) {
1843
const text = `${props.label}: ${props.count}`;
1844
useEffect(() => {
1847
- Scheduler.unstable_yieldValue(`Did create [${text}]`);
1845
+ Scheduler.log(`Did create [${text}]`);
1846
return () => {
1849
- Scheduler.unstable_yieldValue(`Did destroy [${text}]`);
1847
+ Scheduler.log(`Did destroy [${text}]`);
1848
};
1849
}, [props.label, props.count]);
1850
return <Text text={text} />;
1851
}
1852
await act(async () => {
1853
ReactNoop.render(<Counter label="Count" count={0} />, () =>
1856
- Scheduler.unstable_yieldValue('Sync effect'),
1854
+ Scheduler.log('Sync effect'),
1855
);
1856
await waitFor(['Count: 0', 'Sync effect']);
1857
});
@@ -1863,7 +1861,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1861
1862
await act(async () => {
1863
ReactNoop.render(<Counter label="Count" count={1} />, () =>
1866
- Scheduler.unstable_yieldValue('Sync effect'),
1864
+ Scheduler.log('Sync effect'),
1865
);
1866
// Count changed
1867
await waitFor(['Count: 1', 'Sync effect']);
@@ -1874,7 +1872,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1872
1873
await act(async () => {
1874
ReactNoop.render(<Counter label="Count" count={1} />, () =>
1877
- Scheduler.unstable_yieldValue('Sync effect'),
1875
+ Scheduler.log('Sync effect'),
1876
);
1877
// Nothing changed, so no effect should have fired
1878
await waitFor(['Count: 1', 'Sync effect']);
@@ -1885,7 +1883,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1883
1884
await act(async () => {
1885
ReactNoop.render(<Counter label="Total" count={1} />, () =>
1888
- Scheduler.unstable_yieldValue('Sync effect'),
1886
+ Scheduler.log('Sync effect'),
1887
);
1888
// Label changed
1889
await waitFor(['Total: 1', 'Sync effect']);
@@ -1898,16 +1896,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1896
it('multiple effects', async () => {
1897
function Counter(props) {
1898
useEffect(() => {
1901
- Scheduler.unstable_yieldValue(`Did commit 1 [${props.count}]`);
1899
+ Scheduler.log(`Did commit 1 [${props.count}]`);
1900
});
1901
useEffect(() => {
1904
- Scheduler.unstable_yieldValue(`Did commit 2 [${props.count}]`);
1902
+ Scheduler.log(`Did commit 2 [${props.count}]`);
1903
});
1904
return <Text text={'Count: ' + props.count} />;
1905
}
1906
await act(async () => {
1907
ReactNoop.render(<Counter count={0} />, () =>
1910
- Scheduler.unstable_yieldValue('Sync effect'),
1908
+ Scheduler.log('Sync effect'),
1909
);
1910
await waitFor(['Count: 0', 'Sync effect']);
1911
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1917,7 +1915,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1915
1916
await act(async () => {
1917
ReactNoop.render(<Counter count={1} />, () =>
1920
- Scheduler.unstable_yieldValue('Sync effect'),
1918
+ Scheduler.log('Sync effect'),
1919
);
1920
await waitFor(['Count: 1', 'Sync effect']);
1921
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -1928,22 +1926,22 @@ describe('ReactHooksWithNoopRenderer', () => {
1926
it('unmounts all previous effects before creating any new ones', async () => {
1927
function Counter(props) {
1928
useEffect(() => {
1931
- Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
1929
+ Scheduler.log(`Mount A [${props.count}]`);
1930
return () => {
1933
- Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
1931
+ Scheduler.log(`Unmount A [${props.count}]`);
1932
};
1933
});
1934
useEffect(() => {
1937
- Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
1935
+ Scheduler.log(`Mount B [${props.count}]`);
1936
return () => {
1939
- Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
1937
+ Scheduler.log(`Unmount B [${props.count}]`);
1938
};
1939
});
1940
return <Text text={'Count: ' + props.count} />;
1941
}
1942
await act(async () => {
1943
ReactNoop.render(<Counter count={0} />, () =>
1946
- Scheduler.unstable_yieldValue('Sync effect'),
1944
+ Scheduler.log('Sync effect'),
1945
);
1946
await waitFor(['Count: 0', 'Sync effect']);
1947
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -1953,7 +1951,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1951
1952
await act(async () => {
1953
ReactNoop.render(<Counter count={1} />, () =>
1956
- Scheduler.unstable_yieldValue('Sync effect'),
1954
+ Scheduler.log('Sync effect'),
1955
);
1956
await waitFor(['Count: 1', 'Sync effect']);
1957
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -1969,9 +1967,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1967
it('unmounts all previous effects between siblings before creating any new ones', async () => {
1968
function Counter({count, label}) {
1969
useEffect(() => {
1972
- Scheduler.unstable_yieldValue(`Mount ${label} [${count}]`);
1970
+ Scheduler.log(`Mount ${label} [${count}]`);
1971
return () => {
1974
- Scheduler.unstable_yieldValue(`Unmount ${label} [${count}]`);
1972
+ Scheduler.log(`Unmount ${label} [${count}]`);
1973
};
1974
});
1975
return <Text text={`${label} ${count}`} />;
@@ -1982,7 +1980,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1980
<Counter label="A" count={0} />
1981
<Counter label="B" count={0} />
1982
</>,
1985
- () => Scheduler.unstable_yieldValue('Sync effect'),
1983
+ () => Scheduler.log('Sync effect'),
1984
);
1985
await waitFor(['A 0', 'B 0', 'Sync effect']);
1986
expect(ReactNoop).toMatchRenderedOutput(
@@ -2001,7 +1999,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1999
<Counter label="A" count={1} />
2000
<Counter label="B" count={1} />
2001
</>,
2004
- () => Scheduler.unstable_yieldValue('Sync effect'),
2002
+ () => Scheduler.log('Sync effect'),
2003
);
2004
await waitFor(['A 1', 'B 1', 'Sync effect']);
2005
expect(ReactNoop).toMatchRenderedOutput(
@@ -2024,7 +2022,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2022
<Counter label="B" count={2} />
2023
<Counter label="C" count={0} />
2024
</>,
2027
- () => Scheduler.unstable_yieldValue('Sync effect'),
2025
+ () => Scheduler.log('Sync effect'),
2026
);
2027
await waitFor(['B 2', 'C 0', 'Sync effect']);
2028
expect(ReactNoop).toMatchRenderedOutput(
@@ -2045,25 +2043,25 @@ describe('ReactHooksWithNoopRenderer', () => {
2043
it('handles errors in create on mount', async () => {
2044
function Counter(props) {
2045
useEffect(() => {
2048
- Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
2046
+ Scheduler.log(`Mount A [${props.count}]`);
2047
return () => {
2050
- Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
2048
+ Scheduler.log(`Unmount A [${props.count}]`);
2049
};
2050
});
2051
useEffect(() => {
2054
- Scheduler.unstable_yieldValue('Oops!');
2052
+ Scheduler.log('Oops!');
2053
throw new Error('Oops!');
2054
// eslint-disable-next-line no-unreachable
2057
- Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
2055
+ Scheduler.log(`Mount B [${props.count}]`);
2056
return () => {
2059
- Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
2057
+ Scheduler.log(`Unmount B [${props.count}]`);
2058
};
2059
});
2060
return <Text text={'Count: ' + props.count} />;
2061
}
2062
await act(async () => {
2063
ReactNoop.render(<Counter count={0} />, () =>
2066
- Scheduler.unstable_yieldValue('Sync effect'),
2064
+ Scheduler.log('Sync effect'),
2065
);
2066
await waitFor(['Count: 0', 'Sync effect']);
2067
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -2083,26 +2081,26 @@ describe('ReactHooksWithNoopRenderer', () => {
2081
it('handles errors in create on update', async () => {
2082
function Counter(props) {
2083
useEffect(() => {
2086
- Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
2084
+ Scheduler.log(`Mount A [${props.count}]`);
2085
return () => {
2088
- Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
2086
+ Scheduler.log(`Unmount A [${props.count}]`);
2087
};
2088
});
2089
useEffect(() => {
2090
if (props.count === 1) {
2093
- Scheduler.unstable_yieldValue('Oops!');
2091
+ Scheduler.log('Oops!');
2092
throw new Error('Oops!');
2093
}
2096
- Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
2094
+ Scheduler.log(`Mount B [${props.count}]`);
2095
return () => {
2098
- Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
2096
+ Scheduler.log(`Unmount B [${props.count}]`);
2097
};
2098
});
2099
return <Text text={'Count: ' + props.count} />;
2100
}
2101
await act(async () => {
2102
ReactNoop.render(<Counter count={0} />, () =>
2105
- Scheduler.unstable_yieldValue('Sync effect'),
2103
+ Scheduler.log('Sync effect'),
2104
);
2105
await waitFor(['Count: 0', 'Sync effect']);
2106
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -2113,7 +2111,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2111
await act(async () => {
2112
// This update will trigger an error
2113
ReactNoop.render(<Counter count={1} />, () =>
2116
- Scheduler.unstable_yieldValue('Sync effect'),
2114
+ Scheduler.log('Sync effect'),
2115
);
2116
await waitFor(['Count: 1', 'Sync effect']);
2117
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -2131,18 +2129,18 @@ describe('ReactHooksWithNoopRenderer', () => {
2129
it('handles errors in destroy on update', async () => {
2130
function Counter(props) {
2131
useEffect(() => {
2134
- Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
2132
+ Scheduler.log(`Mount A [${props.count}]`);
2133
return () => {
2136
- Scheduler.unstable_yieldValue('Oops!');
2134
+ Scheduler.log('Oops!');
2135
if (props.count === 0) {
2136
throw new Error('Oops!');
2137
}
2138
};
2139
});
2140
useEffect(() => {
2143
- Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
2141
+ Scheduler.log(`Mount B [${props.count}]`);
2142
return () => {
2145
- Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
2143
+ Scheduler.log(`Unmount B [${props.count}]`);
2144
};
2145
});
2146
return <Text text={'Count: ' + props.count} />;
@@ -2150,7 +2148,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2148
2149
await act(async () => {
2150
ReactNoop.render(<Counter count={0} />, () =>
2153
- Scheduler.unstable_yieldValue('Sync effect'),
2151
+ Scheduler.log('Sync effect'),
2152
);
2153
await waitFor(['Count: 0', 'Sync effect']);
2154
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
@@ -2161,7 +2159,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2159
await act(async () => {
2160
// This update will trigger an error during passive effect unmount
2161
ReactNoop.render(<Counter count={1} />, () =>
2164
- Scheduler.unstable_yieldValue('Sync effect'),
2162
+ Scheduler.log('Sync effect'),
2163
);
2164
await waitFor(['Count: 1', 'Sync effect']);
2165
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -2184,21 +2182,21 @@ describe('ReactHooksWithNoopRenderer', () => {
2182
it('works with memo', async () => {
2183
function Counter({count}) {
2184
useLayoutEffect(() => {
2187
- Scheduler.unstable_yieldValue('Mount: ' + count);
2188
- return () => Scheduler.unstable_yieldValue('Unmount: ' + count);
2185
+ Scheduler.log('Mount: ' + count);
2186
+ return () => Scheduler.log('Unmount: ' + count);
2187
});
2188
return <Text text={'Count: ' + count} />;
2189
}
2190
Counter = memo(Counter);
2191
2192
ReactNoop.render(<Counter count={0} />, () =>
2195
- Scheduler.unstable_yieldValue('Sync effect'),
2193
+ Scheduler.log('Sync effect'),
2194
);
2195
await waitFor(['Count: 0', 'Mount: 0', 'Sync effect']);
2196
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
2197
2198
ReactNoop.render(<Counter count={1} />, () =>
2201
- Scheduler.unstable_yieldValue('Sync effect'),
2199
+ Scheduler.log('Sync effect'),
2200
);
2201
await waitFor(['Count: 1', 'Unmount: 0', 'Mount: 1', 'Sync effect']);
2202
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
@@ -2216,11 +2214,9 @@ describe('ReactHooksWithNoopRenderer', () => {
2214
beforeEach(() => {
2215
BrokenUseEffectCleanup = function () {
2216
useEffect(() => {
2219
- Scheduler.unstable_yieldValue('BrokenUseEffectCleanup useEffect');
2217
+ Scheduler.log('BrokenUseEffectCleanup useEffect');
2218
return () => {
2221
- Scheduler.unstable_yieldValue(
2222
- 'BrokenUseEffectCleanup useEffect destroy',
2223
- );
2219
+ Scheduler.log('BrokenUseEffectCleanup useEffect destroy');
2220
throw new Error('Expected error');
2221
};
2222
}, []);
@@ -2231,32 +2227,28 @@ describe('ReactHooksWithNoopRenderer', () => {
2227
ErrorBoundary = class extends React.Component {
2228
state = {error: null};
2229
static getDerivedStateFromError(error) {
2234
- Scheduler.unstable_yieldValue(
2235
- `ErrorBoundary static getDerivedStateFromError`,
2236
- );
2230
+ Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
2231
return {error};
2232
}
2233
componentDidCatch(error, info) {
2240
- Scheduler.unstable_yieldValue(`ErrorBoundary componentDidCatch`);
2234
+ Scheduler.log(`ErrorBoundary componentDidCatch`);
2235
}
2236
render() {
2237
if (this.state.error) {
2244
- Scheduler.unstable_yieldValue('ErrorBoundary render error');
2238
+ Scheduler.log('ErrorBoundary render error');
2239
return <span prop="ErrorBoundary fallback" />;
2240
}
2247
- Scheduler.unstable_yieldValue('ErrorBoundary render success');
2241
+ Scheduler.log('ErrorBoundary render success');
2242
return this.props.children || null;
2243
}
2244
};
2245
2246
LogOnlyErrorBoundary = class extends React.Component {
2247
componentDidCatch(error, info) {
2254
- Scheduler.unstable_yieldValue(
2255
- `LogOnlyErrorBoundary componentDidCatch`,
2256
- );
2248
+ Scheduler.log(`LogOnlyErrorBoundary componentDidCatch`);
2249
}
2250
render() {
2259
- Scheduler.unstable_yieldValue(`LogOnlyErrorBoundary render`);
2251
+ Scheduler.log(`LogOnlyErrorBoundary render`);
2252
return this.props.children || null;
2253
}
2254
};
@@ -2414,18 +2406,18 @@ describe('ReactHooksWithNoopRenderer', () => {
2406
const Wrapper = ({children}) => children;
2407
function Child() {
2408
React.useEffect(() => {
2417
- Scheduler.unstable_yieldValue('passive create');
2409
+ Scheduler.log('passive create');
2410
return () => {
2419
- Scheduler.unstable_yieldValue('passive destroy');
2411
+ Scheduler.log('passive destroy');
2412
};
2413
}, []);
2414
React.useLayoutEffect(() => {
2423
- Scheduler.unstable_yieldValue('layout create');
2415
+ Scheduler.log('layout create');
2416
return () => {
2425
- Scheduler.unstable_yieldValue('layout destroy');
2417
+ Scheduler.log('layout destroy');
2418
};
2419
}, []);
2428
- Scheduler.unstable_yieldValue('render');
2420
+ Scheduler.log('render');
2421
return null;
2422
}
2423
@@ -2481,18 +2473,18 @@ describe('ReactHooksWithNoopRenderer', () => {
2473
2474
function Grandchild() {
2475
React.useEffect(() => {
2484
- Scheduler.unstable_yieldValue('passive create');
2476
+ Scheduler.log('passive create');
2477
return () => {
2486
- Scheduler.unstable_yieldValue('passive destroy');
2478
+ Scheduler.log('passive destroy');
2479
};
2480
}, []);
2481
React.useLayoutEffect(() => {
2490
- Scheduler.unstable_yieldValue('layout create');
2482
+ Scheduler.log('layout create');
2483
return () => {
2492
- Scheduler.unstable_yieldValue('layout destroy');
2484
+ Scheduler.log('layout destroy');
2485
};
2486
}, []);
2495
- Scheduler.unstable_yieldValue('render');
2487
+ Scheduler.log('render');
2488
return null;
2489
}
2490
@@ -2593,9 +2585,9 @@ describe('ReactHooksWithNoopRenderer', () => {
2585
it('fires insertion effects after snapshots on update', async () => {
2586
function CounterA(props) {
2587
useInsertionEffect(() => {
2596
- Scheduler.unstable_yieldValue(`Create insertion`);
2588
+ Scheduler.log(`Create insertion`);
2589
return () => {
2598
- Scheduler.unstable_yieldValue(`Destroy insertion`);
2590
+ Scheduler.log(`Destroy insertion`);
2591
};
2592
});
2593
return null;
@@ -2603,7 +2595,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2595
2596
class CounterB extends React.Component {
2597
getSnapshotBeforeUpdate(prevProps, prevState) {
2606
- Scheduler.unstable_yieldValue(`Get Snapshot`);
2598
+ Scheduler.log(`Get Snapshot`);
2599
return null;
2600
}
2601
@@ -2654,34 +2646,22 @@ describe('ReactHooksWithNoopRenderer', () => {
2646
2647
function Counter(props) {
2648
useInsertionEffect(() => {
2657
- Scheduler.unstable_yieldValue(
2658
- `Create insertion [current: ${committedText}]`,
2659
- );
2649
+ Scheduler.log(`Create insertion [current: ${committedText}]`);
2650
committedText = String(props.count);
2651
return () => {
2662
- Scheduler.unstable_yieldValue(
2663
- `Destroy insertion [current: ${committedText}]`,
2664
- );
2652
+ Scheduler.log(`Destroy insertion [current: ${committedText}]`);
2653
};
2654
});
2655
useLayoutEffect(() => {
2668
- Scheduler.unstable_yieldValue(
2669
- `Create layout [current: ${committedText}]`,
2670
- );
2656
+ Scheduler.log(`Create layout [current: ${committedText}]`);
2657
return () => {
2672
- Scheduler.unstable_yieldValue(
2673
- `Destroy layout [current: ${committedText}]`,
2674
- );
2658
+ Scheduler.log(`Destroy layout [current: ${committedText}]`);
2659
};
2660
});
2661
useEffect(() => {
2678
- Scheduler.unstable_yieldValue(
2679
- `Create passive [current: ${committedText}]`,
2680
- );
2662
+ Scheduler.log(`Create passive [current: ${committedText}]`);
2663
return () => {
2682
- Scheduler.unstable_yieldValue(
2683
- `Destroy passive [current: ${committedText}]`,
2684
- );
2664
+ Scheduler.log(`Destroy passive [current: ${committedText}]`);
2665
};
2666
});
2667
return null;
@@ -2716,35 +2696,23 @@ describe('ReactHooksWithNoopRenderer', () => {
2696
2697
function Counter(props) {
2698
useInsertionEffect(() => {
2719
- Scheduler.unstable_yieldValue(
2720
- `Create insertion [current: ${committedText}]`,
2721
- );
2699
+ Scheduler.log(`Create insertion [current: ${committedText}]`);
2700
committedText = String(props.count);
2701
return () => {
2724
- Scheduler.unstable_yieldValue(
2725
- `Destroy insertion [current: ${committedText}]`,
2726
- );
2702
+ Scheduler.log(`Destroy insertion [current: ${committedText}]`);
2703
};
2704
});
2705
useLayoutEffect(() => {
2730
- Scheduler.unstable_yieldValue(
2731
- `Create layout [current: ${committedText}]`,
2732
- );
2706
+ Scheduler.log(`Create layout [current: ${committedText}]`);
2707
committedText = String(props.count);
2708
return () => {
2735
- Scheduler.unstable_yieldValue(
2736
- `Destroy layout [current: ${committedText}]`,
2737
- );
2709
+ Scheduler.log(`Destroy layout [current: ${committedText}]`);
2710
};
2711
});
2712
useEffect(() => {
2741
- Scheduler.unstable_yieldValue(
2742
- `Create passive [current: ${committedText}]`,
2743
- );
2713
+ Scheduler.log(`Create passive [current: ${committedText}]`);
2714
return () => {
2745
- Scheduler.unstable_yieldValue(
2746
- `Destroy passive [current: ${committedText}]`,
2747
- );
2715
+ Scheduler.log(`Destroy passive [current: ${committedText}]`);
2716
};
2717
});
2718
return null;
@@ -2784,45 +2752,45 @@ describe('ReactHooksWithNoopRenderer', () => {
2752
2753
function CounterA(props) {
2754
useInsertionEffect(() => {
2787
- Scheduler.unstable_yieldValue(
2755
+ Scheduler.log(
2756
`Create Insertion 1 for Component A [A: ${committedA}, B: ${committedB}]`,
2757
);
2758
committedA = String(props.count);
2759
return () => {
2792
- Scheduler.unstable_yieldValue(
2760
+ Scheduler.log(
2761
`Destroy Insertion 1 for Component A [A: ${committedA}, B: ${committedB}]`,
2762
);
2763
};
2764
});
2765
useInsertionEffect(() => {
2798
- Scheduler.unstable_yieldValue(
2766
+ Scheduler.log(
2767
`Create Insertion 2 for Component A [A: ${committedA}, B: ${committedB}]`,
2768
);
2769
committedA = String(props.count);
2770
return () => {
2803
- Scheduler.unstable_yieldValue(
2771
+ Scheduler.log(
2772
`Destroy Insertion 2 for Component A [A: ${committedA}, B: ${committedB}]`,
2773
);
2774
};
2775
});
2776
2777
useLayoutEffect(() => {
2810
- Scheduler.unstable_yieldValue(
2778
+ Scheduler.log(
2779
`Create Layout 1 for Component A [A: ${committedA}, B: ${committedB}]`,
2780
);
2781
return () => {
2814
- Scheduler.unstable_yieldValue(
2782
+ Scheduler.log(
2783
`Destroy Layout 1 for Component A [A: ${committedA}, B: ${committedB}]`,
2784
);
2785
};
2786
});
2787
2788
useLayoutEffect(() => {
2821
- Scheduler.unstable_yieldValue(
2789
+ Scheduler.log(
2790
`Create Layout 2 for Component A [A: ${committedA}, B: ${committedB}]`,
2791
);
2792
return () => {
2825
- Scheduler.unstable_yieldValue(
2793
+ Scheduler.log(
2794
`Destroy Layout 2 for Component A [A: ${committedA}, B: ${committedB}]`,
2795
);
2796
};
@@ -2832,45 +2800,45 @@ describe('ReactHooksWithNoopRenderer', () => {
2800
2801
function CounterB(props) {
2802
useInsertionEffect(() => {
2835
- Scheduler.unstable_yieldValue(
2803
+ Scheduler.log(
2804
`Create Insertion 1 for Component B [A: ${committedA}, B: ${committedB}]`,
2805
);
2806
committedB = String(props.count);
2807
return () => {
2840
- Scheduler.unstable_yieldValue(
2808
+ Scheduler.log(
2809
`Destroy Insertion 1 for Component B [A: ${committedA}, B: ${committedB}]`,
2810
);
2811
};
2812
});
2813
useInsertionEffect(() => {
2846
- Scheduler.unstable_yieldValue(
2814
+ Scheduler.log(
2815
`Create Insertion 2 for Component B [A: ${committedA}, B: ${committedB}]`,
2816
);
2817
committedB = String(props.count);
2818
return () => {
2851
- Scheduler.unstable_yieldValue(
2819
+ Scheduler.log(
2820
`Destroy Insertion 2 for Component B [A: ${committedA}, B: ${committedB}]`,
2821
);
2822
};
2823
});
2824
2825
useLayoutEffect(() => {
2858
- Scheduler.unstable_yieldValue(
2826
+ Scheduler.log(
2827
`Create Layout 1 for Component B [A: ${committedA}, B: ${committedB}]`,
2828
);
2829
return () => {
2862
- Scheduler.unstable_yieldValue(
2830
+ Scheduler.log(
2831
`Destroy Layout 1 for Component B [A: ${committedA}, B: ${committedB}]`,
2832
);
2833
};
2834
});
2835
2836
useLayoutEffect(() => {
2869
- Scheduler.unstable_yieldValue(
2837
+ Scheduler.log(
2838
`Create Layout 2 for Component B [A: ${committedA}, B: ${committedB}]`,
2839
);
2840
return () => {
2873
- Scheduler.unstable_yieldValue(
2841
+ Scheduler.log(
2842
`Destroy Layout 2 for Component B [A: ${committedA}, B: ${committedB}]`,
2843
);
2844
};
@@ -3077,9 +3045,9 @@ describe('ReactHooksWithNoopRenderer', () => {
3045
describe('useLayoutEffect', () => {
3046
it('fires layout effects after the host has been mutated', async () => {
3047
function getCommittedText() {
3080
- const yields = Scheduler.unstable_clearYields();
3048
+ const yields = Scheduler.unstable_clearLog();
3049
const children = ReactNoop.getChildrenAsJSX();
3082
- Scheduler.unstable_yieldValue(yields);
3050
+ Scheduler.log(yields);
3051
if (children === null) {
3052
return null;
3053
}
@@ -3088,19 +3056,19 @@ describe('ReactHooksWithNoopRenderer', () => {
3056
3057
function Counter(props) {
3058
useLayoutEffect(() => {
3091
- Scheduler.unstable_yieldValue(`Current: ${getCommittedText()}`);
3059
+ Scheduler.log(`Current: ${getCommittedText()}`);
3060
});
3061
return <Text text={props.count} />;
3062
}
3063
3064
ReactNoop.render(<Counter count={0} />, () =>
3097
- Scheduler.unstable_yieldValue('Sync effect'),
3065
+ Scheduler.log('Sync effect'),
3066
);
3067
await waitFor([[0], 'Current: 0', 'Sync effect']);
3068
expect(ReactNoop).toMatchRenderedOutput(<span prop={0} />);
3069
3070
ReactNoop.render(<Counter count={1} />, () =>
3103
- Scheduler.unstable_yieldValue('Sync effect'),
3071
+ Scheduler.log('Sync effect'),
3072
);
3073
await waitFor([[1], 'Current: 1', 'Sync effect']);
3074
expect(ReactNoop).toMatchRenderedOutput(<span prop={1} />);
@@ -3115,23 +3083,15 @@ describe('ReactHooksWithNoopRenderer', () => {
3083
// intentionally omits a mutation effect.
3084
committedText = String(props.count);
3085
3118
- Scheduler.unstable_yieldValue(
3119
- `Mount layout [current: ${committedText}]`,
3120
- );
3086
+ Scheduler.log(`Mount layout [current: ${committedText}]`);
3087
return () => {
3122
- Scheduler.unstable_yieldValue(
3123
- `Unmount layout [current: ${committedText}]`,
3124
- );
3088
+ Scheduler.log(`Unmount layout [current: ${committedText}]`);
3089
};
3090
});
3091
useEffect(() => {
3128
- Scheduler.unstable_yieldValue(
3129
- `Mount normal [current: ${committedText}]`,
3130
- );
3092
+ Scheduler.log(`Mount normal [current: ${committedText}]`);
3093
return () => {
3132
- Scheduler.unstable_yieldValue(
3133
- `Unmount normal [current: ${committedText}]`,
3134
- );
3094
+ Scheduler.log(`Unmount normal [current: ${committedText}]`);
3095
};
3096
});
3097
return null;
@@ -3139,12 +3099,12 @@ describe('ReactHooksWithNoopRenderer', () => {
3099
3100
await act(async () => {
3101
ReactNoop.render(<Counter count={0} />, () =>
3142
- Scheduler.unstable_yieldValue('Sync effect'),
3102
+ Scheduler.log('Sync effect'),
3103
);
3104
await waitFor(['Mount layout [current: 0]', 'Sync effect']);
3105
expect(committedText).toEqual('0');
3106
ReactNoop.render(<Counter count={1} />, () =>
3147
- Scheduler.unstable_yieldValue('Sync effect'),
3107
+ Scheduler.log('Sync effect'),
3108
);
3109
await waitFor([
3110
'Mount normal [current: 0]',
@@ -3163,39 +3123,35 @@ describe('ReactHooksWithNoopRenderer', () => {
3123
class ErrorBoundary extends React.Component {
3124
state = {error: null};
3125
static getDerivedStateFromError(error) {
3166
- Scheduler.unstable_yieldValue(
3167
- `ErrorBoundary static getDerivedStateFromError`,
3168
- );
3126
+ Scheduler.log(`ErrorBoundary static getDerivedStateFromError`);
3127
return {error};
3128
}
3129
render() {
3130
const {children, id, fallbackID} = this.props;
3131
const {error} = this.state;
3132
if (error) {
3175
- Scheduler.unstable_yieldValue(`${id} render error`);
3133
+ Scheduler.log(`${id} render error`);
3134
return <Component id={fallbackID} />;
3135
}
3178
- Scheduler.unstable_yieldValue(`${id} render success`);
3136
+ Scheduler.log(`${id} render success`);
3137
return children || null;
3138
}
3139
}
3140
3141
function Component({id}) {
3184
- Scheduler.unstable_yieldValue('Component render ' + id);
3142
+ Scheduler.log('Component render ' + id);
3143
return <span prop={id} />;
3144
}
3145
3146
function BrokenLayoutEffectDestroy() {
3147
useLayoutEffect(() => {
3148
return () => {
3191
- Scheduler.unstable_yieldValue(
3192
- 'BrokenLayoutEffectDestroy useLayoutEffect destroy',
3193
- );
3149
+ Scheduler.log('BrokenLayoutEffectDestroy useLayoutEffect destroy');
3150
throw Error('Expected');
3151
};
3152
}, []);
3153
3198
- Scheduler.unstable_yieldValue('BrokenLayoutEffectDestroy render');
3154
+ Scheduler.log('BrokenLayoutEffectDestroy render');
3155
return <span prop="broken" />;
3156
}
3157
@@ -3367,7 +3323,7 @@ describe('ReactHooksWithNoopRenderer', () => {
3323
function CapitalizedText(props) {
3324
const text = props.text;
3325
const capitalizedText = useMemo(() => {
3370
- Scheduler.unstable_yieldValue(`Capitalize '${text}'`);
3326
+ Scheduler.log(`Capitalize '${text}'`);
3327
return text.toUpperCase();
3328
}, [text]);
3329
return <Text text={capitalizedText} />;
@@ -3397,12 +3353,12 @@ describe('ReactHooksWithNoopRenderer', () => {
3353
}
3354
3355
function computeA() {
3400
- Scheduler.unstable_yieldValue('compute A');
3356
+ Scheduler.log('compute A');
3357
return 'A';
3358
}
3359
3360
function computeB() {
3405
- Scheduler.unstable_yieldValue('compute B');
3361
+ Scheduler.log('compute B');
3362
return 'B';
3363
}
3364
@@ -3433,7 +3389,7 @@ describe('ReactHooksWithNoopRenderer', () => {
3389
}
3390
3391
function compute(val) {
3436
- Scheduler.unstable_yieldValue('compute ' + val);
3392
+ Scheduler.log('compute ' + val);
3393
return val;
3394
}
3395
@@ -3812,17 +3768,17 @@ describe('ReactHooksWithNoopRenderer', () => {
3768
it('unmount effects', async () => {
3769
function App(props) {
3770
useEffect(() => {
3815
- Scheduler.unstable_yieldValue('Mount A');
3771
+ Scheduler.log('Mount A');
3772
return () => {
3817
- Scheduler.unstable_yieldValue('Unmount A');
3773
+ Scheduler.log('Unmount A');
3774
};
3775
}, []);
3776
3777
if (props.showMore) {
3778
useEffect(() => {
3823
- Scheduler.unstable_yieldValue('Mount B');
3779
+ Scheduler.log('Mount B');
3780
return () => {
3825
- Scheduler.unstable_yieldValue('Unmount B');
3781
+ Scheduler.log('Unmount B');
3782
};
3783
}, []);
3784
}
@@ -3832,7 +3788,7 @@ describe('ReactHooksWithNoopRenderer', () => {
3788
3789
await act(async () => {
3790
ReactNoop.render(<App showMore={false} />, () =>
3835
- Scheduler.unstable_yieldValue('Sync effect'),
3791
+ Scheduler.log('Sync effect'),
3792
);
3793
await waitFor(['Sync effect']);
3794
});
@@ -3884,14 +3840,14 @@ describe('ReactHooksWithNoopRenderer', () => {
3840
// This reducer closes over a value from props. If the reducer is not
3841
// properly updated, the eager reducer will compare to an old value
3842
// and bail out incorrectly.
3887
- Scheduler.unstable_yieldValue('Reducer: ' + count);
3843
+ Scheduler.log('Reducer: ' + count);
3844
return count;
3845
}, -1);
3846
useEffect(() => {
3891
- Scheduler.unstable_yieldValue('Effect: ' + count);
3847
+ Scheduler.log('Effect: ' + count);
3848
dispatch();
3849
}, [count]);
3894
- Scheduler.unstable_yieldValue('Render: ' + state);
3850
+ Scheduler.log('Render: ' + state);
3851
return count;
3852
}
3853
@@ -3927,8 +3883,8 @@ describe('ReactHooksWithNoopRenderer', () => {
3883
increment = () => dispatch({type: 'increment'});
3884
setDisabled = _setDisabled;
3885
3930
- Scheduler.unstable_yieldValue('Render disabled: ' + disabled);
3931
- Scheduler.unstable_yieldValue('Render count: ' + count);
3886
+ Scheduler.log('Render disabled: ' + disabled);
3887
+ Scheduler.log('Render count: ' + count);
3888
return count;
3889
}
3890
@@ -3970,14 +3926,14 @@ describe('ReactHooksWithNoopRenderer', () => {
3926
3927
increment = () => dispatch({type: 'increment'});
3928
3973
- Scheduler.unstable_yieldValue('Render count: ' + count);
3929
+ Scheduler.log('Render count: ' + count);
3930
return count;
3931
}
3932
3933
function App() {
3934
const [disabled, _setDisabled] = useState(true);
3935
setDisabled = _setDisabled;
3980
- Scheduler.unstable_yieldValue('Render disabled: ' + disabled);
3936
+ Scheduler.log('Render disabled: ' + disabled);
3937
return <Counter disabled={disabled} />;
3938
}
3939
@@ -4019,14 +3975,14 @@ describe('ReactHooksWithNoopRenderer', () => {
3975
3976
increment = () => dispatch({type: 'increment'});
3977
4022
- Scheduler.unstable_yieldValue('Render count: ' + count);
3978
+ Scheduler.log('Render count: ' + count);
3979
return count;
3980
}
3981
3982
function App() {
3983
const [disabled, _setDisabled] = useState(true);
3984
setDisabled = _setDisabled;
4029
- Scheduler.unstable_yieldValue('Render disabled: ' + disabled);
3985
+ Scheduler.log('Render disabled: ' + disabled);
3986
return <Counter disabled={disabled} />;
3987
}
3988
@@ -4055,9 +4011,9 @@ describe('ReactHooksWithNoopRenderer', () => {
4011
function CounterA() {
4012
const [counter, setCounter] = useState(0);
4013
setCounterA = setCounter;
4058
- Scheduler.unstable_yieldValue('Render A: ' + counter);
4014
+ Scheduler.log('Render A: ' + counter);
4015
useEffect(() => {
4060
- Scheduler.unstable_yieldValue('Commit A: ' + counter);
4016
+ Scheduler.log('Commit A: ' + counter);
4017
});
4018
return counter;
4019
}
@@ -4065,9 +4021,9 @@ describe('ReactHooksWithNoopRenderer', () => {
4021
function CounterB() {
4022
const [counter, setCounter] = useState(0);
4023
setCounterB = setCounter;
4068
- Scheduler.unstable_yieldValue('Render B: ' + counter);
4024
+ Scheduler.log('Render B: ' + counter);
4025
useEffect(() => {
4070
- Scheduler.unstable_yieldValue('Commit B: ' + counter);
4026
+ Scheduler.log('Commit B: ' + counter);
4027
});
4028
return counter;
4029
}
@@ -4114,7 +4070,7 @@ describe('ReactHooksWithNoopRenderer', () => {
4070
setStep(step + 1);
4071
}
4072
4117
- Scheduler.unstable_yieldValue(`Step: ${step}, Shadow: ${shadow}`);
4073
+ Scheduler.log(`Step: ${step}, Shadow: ${shadow}`);
4074
return shadow;
4075
}
4076
@@ -4170,15 +4126,15 @@ describe('ReactHooksWithNoopRenderer', () => {
4126
4127
function Child({label}) {
4128
useLayoutEffect(() => {
4173
- Scheduler.unstable_yieldValue('Mount layout ' + label);
4129
+ Scheduler.log('Mount layout ' + label);
4130
return () => {
4175
- Scheduler.unstable_yieldValue('Unmount layout ' + label);
4131
+ Scheduler.log('Unmount layout ' + label);
4132
};
4133
}, [label]);
4134
useEffect(() => {
4179
- Scheduler.unstable_yieldValue('Mount passive ' + label);
4135
+ Scheduler.log('Mount passive ' + label);
4136
return () => {
4181
- Scheduler.unstable_yieldValue('Unmount passive ' + label);
4137
+ Scheduler.log('Unmount passive ' + label);
4138
};
4139
}, [label]);
4140
return label;
@@ -4222,9 +4178,9 @@ describe('ReactHooksWithNoopRenderer', () => {
4178
4179
function Child({label}) {
4180
useEffect(() => {
4225
- Scheduler.unstable_yieldValue('Mount ' + label);
4181
+ Scheduler.log('Mount ' + label);
4182
return () => {
4227
- Scheduler.unstable_yieldValue('Unmount ' + label);
4183
+ Scheduler.log('Unmount ' + label);
4184
};
4185
}, [label]);
4186
return label;
@@ -4267,9 +4223,9 @@ describe('ReactHooksWithNoopRenderer', () => {
4223
it('regression: SuspenseList causes unmounts to be dropped on deletion', async () => {
4224
function Row({label}) {
4225
useEffect(() => {
4270
- Scheduler.unstable_yieldValue('Mount ' + label);
4226
+ Scheduler.log('Mount ' + label);
4227
return () => {
4272
- Scheduler.unstable_yieldValue('Unmount ' + label);
4228
+ Scheduler.log('Unmount ' + label);
4229
};
4230
}, [label]);
4231
return (
@@ -4314,7 +4270,7 @@ describe('ReactHooksWithNoopRenderer', () => {
4270
const [count, setCount] = useState(0);
4271
4272
useEffect(() => {
4317
- Scheduler.unstable_yieldValue(`Effect: ${count}`);
4273
+ Scheduler.log(`Effect: ${count}`);
4274
}, [count]);
4275
4276
if (count > 0) {
packages/react-reconciler/src/__tests__/ReactIncremental-test.js
+153
-213
@@ -62,7 +62,7 @@ describe('ReactIncremental', () => {
62
63
it('should render a simple component, in steps if needed', async () => {
64
function Bar() {
65
- Scheduler.unstable_yieldValue('Bar');
65
+ Scheduler.log('Bar');
66
return (
67
<span>
68
<div>Hello World</div>
@@ -71,14 +71,12 @@ describe('ReactIncremental', () => {
71
}
72
73
function Foo() {
74
- Scheduler.unstable_yieldValue('Foo');
74
+ Scheduler.log('Foo');
75
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
76
}
77
78
React.startTransition(() => {
79
- ReactNoop.render(<Foo />, () =>
80
- Scheduler.unstable_yieldValue('callback'),
81
- );
79
+ ReactNoop.render(<Foo />, () => Scheduler.log('callback'));
80
});
81
// Do one step of work.
82
expect(ReactNoop.flushNextYield()).toEqual(['Foo']);
@@ -89,17 +87,17 @@ describe('ReactIncremental', () => {
87
88
it('updates a previous render', async () => {
89
function Header() {
92
- Scheduler.unstable_yieldValue('Header');
90
+ Scheduler.log('Header');
91
return <h1>Hi</h1>;
92
}
93
94
function Content(props) {
97
- Scheduler.unstable_yieldValue('Content');
95
+ Scheduler.log('Content');
96
return <div>{props.children}</div>;
97
}
98
99
function Footer() {
102
- Scheduler.unstable_yieldValue('Footer');
100
+ Scheduler.log('Footer');
101
return <footer>Bye</footer>;
102
}
103
@@ -107,7 +105,7 @@ describe('ReactIncremental', () => {
105
const footer = <Footer />;
106
107
function Foo(props) {
110
- Scheduler.unstable_yieldValue('Foo');
108
+ Scheduler.log('Foo');
109
return (
110
<div>
111
{header}
@@ -118,7 +116,7 @@ describe('ReactIncremental', () => {
116
}
117
118
ReactNoop.render(<Foo text="foo" />, () =>
121
- Scheduler.unstable_yieldValue('renderCallbackCalled'),
119
+ Scheduler.log('renderCallbackCalled'),
120
);
121
await waitForAll([
122
'Foo',
@@ -129,10 +127,10 @@ describe('ReactIncremental', () => {
127
]);
128
129
ReactNoop.render(<Foo text="bar" />, () =>
132
- Scheduler.unstable_yieldValue('firstRenderCallbackCalled'),
130
+ Scheduler.log('firstRenderCallbackCalled'),
131
);
132
ReactNoop.render(<Foo text="bar" />, () =>
135
- Scheduler.unstable_yieldValue('secondRenderCallbackCalled'),
133
+ Scheduler.log('secondRenderCallbackCalled'),
134
);
135
// TODO: Test bail out of host components. This is currently unobservable.
136
@@ -148,12 +146,12 @@ describe('ReactIncremental', () => {
146
147
it('can cancel partially rendered work and restart', async () => {
148
function Bar(props) {
151
- Scheduler.unstable_yieldValue('Bar');
149
+ Scheduler.log('Bar');
150
return <div>{props.children}</div>;
151
}
152
153
function Foo(props) {
156
- Scheduler.unstable_yieldValue('Foo');
154
+ Scheduler.log('Foo');
155
return (
156
<div>
157
<Bar>{props.text}</Bar>
@@ -214,10 +212,10 @@ describe('ReactIncremental', () => {
212
React.startTransition(() => {
213
inst.setState(
214
() => {
217
- Scheduler.unstable_yieldValue('setState1');
215
+ Scheduler.log('setState1');
216
return {text: 'bar'};
217
},
220
- () => Scheduler.unstable_yieldValue('callback1'),
218
+ () => Scheduler.log('callback1'),
219
);
220
});
221
@@ -229,10 +227,10 @@ describe('ReactIncremental', () => {
227
React.startTransition(() => {
228
inst.setState(
229
() => {
232
- Scheduler.unstable_yieldValue('setState2');
230
+ Scheduler.log('setState2');
231
return {text2: 'baz'};
232
},
235
- () => Scheduler.unstable_yieldValue('callback2'),
233
+ () => Scheduler.log('callback2'),
234
);
235
});
236
@@ -244,17 +242,17 @@ describe('ReactIncremental', () => {
242
// @gate www
243
it('can deprioritize unfinished work and resume it later', async () => {
244
function Bar(props) {
247
- Scheduler.unstable_yieldValue('Bar');
245
+ Scheduler.log('Bar');
246
return <div>{props.children}</div>;
247
}
248
249
function Middle(props) {
252
- Scheduler.unstable_yieldValue('Middle');
250
+ Scheduler.log('Middle');
251
return <span>{props.children}</span>;
252
}
253
254
function Foo(props) {
257
- Scheduler.unstable_yieldValue('Foo');
255
+ Scheduler.log('Foo');
256
return (
257
<div>
258
<Bar>{props.text}</Bar>
@@ -284,17 +282,17 @@ describe('ReactIncremental', () => {
282
// @gate www
283
it('can deprioritize a tree from without dropping work', async () => {
284
function Bar(props) {
287
- Scheduler.unstable_yieldValue('Bar');
285
+ Scheduler.log('Bar');
286
return <div>{props.children}</div>;
287
}
288
289
function Middle(props) {
292
- Scheduler.unstable_yieldValue('Middle');
290
+ Scheduler.log('Middle');
291
return <span>{props.children}</span>;
292
}
293
294
function Foo(props) {
297
- Scheduler.unstable_yieldValue('Foo');
295
+ Scheduler.log('Foo');
296
return (
297
<div>
298
<Bar>{props.text}</Bar>
@@ -329,19 +327,19 @@ describe('ReactIncremental', () => {
327
328
xit('can resume work in a subtree even when a parent bails out', async () => {
329
function Bar(props) {
332
- Scheduler.unstable_yieldValue('Bar');
330
+ Scheduler.log('Bar');
331
return <div>{props.children}</div>;
332
}
333
334
function Tester() {
335
// This component is just here to ensure that the bail out is
336
// in fact in effect in the expected place for this test.
339
- Scheduler.unstable_yieldValue('Tester');
337
+ Scheduler.log('Tester');
338
return <div />;
339
}
340
341
function Middle(props) {
344
- Scheduler.unstable_yieldValue('Middle');
342
+ Scheduler.log('Middle');
343
return <span>{props.children}</span>;
344
}
345
@@ -357,7 +355,7 @@ describe('ReactIncremental', () => {
355
);
356
357
function Foo(props) {
360
- Scheduler.unstable_yieldValue('Foo');
358
+ Scheduler.log('Foo');
359
return (
360
<div>
361
<Bar>{props.text}</Bar>
@@ -385,7 +383,7 @@ describe('ReactIncremental', () => {
383
384
xit('can resume work in a bailed subtree within one pass', async () => {
385
function Bar(props) {
388
- Scheduler.unstable_yieldValue('Bar');
386
+ Scheduler.log('Bar');
387
return <div>{props.children}</div>;
388
}
389
@@ -396,13 +394,13 @@ describe('ReactIncremental', () => {
394
render() {
395
// This component is just here to ensure that the bail out is
396
// in fact in effect in the expected place for this test.
399
- Scheduler.unstable_yieldValue('Tester');
397
+ Scheduler.log('Tester');
398
return <div />;
399
}
400
}
401
402
function Middle(props) {
405
- Scheduler.unstable_yieldValue('Middle');
403
+ Scheduler.log('Middle');
404
return <span>{props.children}</span>;
405
}
406
@@ -425,7 +423,7 @@ describe('ReactIncremental', () => {
423
}
424
425
function Foo(props) {
428
- Scheduler.unstable_yieldValue('Foo');
426
+ Scheduler.log('Foo');
427
return (
428
<div hidden={props.text === 'bar'}>
429
<Bar>{props.text}</Bar>
@@ -484,17 +482,17 @@ describe('ReactIncremental', () => {
482
constructor(props) {
483
super(props);
484
// Test based on a www bug where props was null on resume
487
- Scheduler.unstable_yieldValue('Foo constructor: ' + props.prop);
485
+ Scheduler.log('Foo constructor: ' + props.prop);
486
}
487
render() {
488
foo = this;
491
- Scheduler.unstable_yieldValue('Foo');
489
+ Scheduler.log('Foo');
490
return <Bar />;
491
}
492
}
493
494
function Bar() {
497
- Scheduler.unstable_yieldValue('Bar');
495
+ Scheduler.log('Bar');
496
return <div />;
497
}
498
@@ -523,37 +521,33 @@ describe('ReactIncremental', () => {
521
constructor(props) {
522
super(props);
523
// Test based on a www bug where props was null on resume
526
- Scheduler.unstable_yieldValue('constructor: ' + props.prop);
524
+ Scheduler.log('constructor: ' + props.prop);
525
constructorCount++;
526
}
527
UNSAFE_componentWillMount() {
530
- Scheduler.unstable_yieldValue('componentWillMount: ' + this.props.prop);
528
+ Scheduler.log('componentWillMount: ' + this.props.prop);
529
}
530
UNSAFE_componentWillReceiveProps() {
533
- Scheduler.unstable_yieldValue(
534
- 'componentWillReceiveProps: ' + this.props.prop,
535
- );
531
+ Scheduler.log('componentWillReceiveProps: ' + this.props.prop);
532
}
533
componentDidMount() {
538
- Scheduler.unstable_yieldValue('componentDidMount: ' + this.props.prop);
534
+ Scheduler.log('componentDidMount: ' + this.props.prop);
535
}
536
UNSAFE_componentWillUpdate() {
541
- Scheduler.unstable_yieldValue(
542
- 'componentWillUpdate: ' + this.props.prop,
543
- );
537
+ Scheduler.log('componentWillUpdate: ' + this.props.prop);
538
}
539
componentDidUpdate() {
546
- Scheduler.unstable_yieldValue('componentDidUpdate: ' + this.props.prop);
540
+ Scheduler.log('componentDidUpdate: ' + this.props.prop);
541
}
542
render() {
543
foo = this;
550
- Scheduler.unstable_yieldValue('render: ' + this.props.prop);
544
+ Scheduler.log('render: ' + this.props.prop);
545
return <Bar />;
546
}
547
}
548
549
function Bar() {
556
- Scheduler.unstable_yieldValue('Foo did complete');
550
+ Scheduler.log('Foo did complete');
551
return <div />;
552
}
553
@@ -580,12 +574,12 @@ describe('ReactIncremental', () => {
574
575
xit('can reuse work done after being preempted', async () => {
576
function Bar(props) {
583
- Scheduler.unstable_yieldValue('Bar');
577
+ Scheduler.log('Bar');
578
return <div>{props.children}</div>;
579
}
580
581
function Middle(props) {
588
- Scheduler.unstable_yieldValue('Middle');
582
+ Scheduler.log('Middle');
583
return <span>{props.children}</span>;
584
}
585
@@ -606,7 +600,7 @@ describe('ReactIncremental', () => {
600
);
601
602
function Foo(props) {
609
- Scheduler.unstable_yieldValue('Foo');
603
+ Scheduler.log('Foo');
604
return (
605
<div>
606
<Bar>{props.text2}</Bar>
@@ -661,12 +655,12 @@ describe('ReactIncremental', () => {
655
let sibling;
656
657
function GreatGrandchild() {
664
- Scheduler.unstable_yieldValue('GreatGrandchild');
658
+ Scheduler.log('GreatGrandchild');
659
return <div />;
660
}
661
662
function Grandchild() {
669
- Scheduler.unstable_yieldValue('Grandchild');
663
+ Scheduler.log('Grandchild');
664
return <GreatGrandchild />;
665
}
666
@@ -674,21 +668,21 @@ describe('ReactIncremental', () => {
668
state = {step: 0};
669
render() {
670
child = this;
677
- Scheduler.unstable_yieldValue('Child');
671
+ Scheduler.log('Child');
672
return <Grandchild />;
673
}
674
}
675
676
class Sibling extends React.Component {
677
render() {
684
- Scheduler.unstable_yieldValue('Sibling');
678
+ Scheduler.log('Sibling');
679
sibling = this;
680
return <div />;
681
}
682
}
683
684
function Parent() {
691
- Scheduler.unstable_yieldValue('Parent');
685
+ Scheduler.log('Parent');
686
return [
687
// The extra div is necessary because when Parent bails out during the
688
// high priority update, its progressedPriority is set to high.
@@ -732,7 +726,7 @@ describe('ReactIncremental', () => {
726
727
xit('can reuse work if shouldComponentUpdate is false, after being preempted', async () => {
728
function Bar(props) {
735
- Scheduler.unstable_yieldValue('Bar');
729
+ Scheduler.log('Bar');
730
return <div>{props.children}</div>;
731
}
732
@@ -741,7 +735,7 @@ describe('ReactIncremental', () => {
735
return this.props.children !== nextProps.children;
736
}
737
render() {
744
- Scheduler.unstable_yieldValue('Middle');
738
+ Scheduler.log('Middle');
739
return <span>{this.props.children}</span>;
740
}
741
}
@@ -751,7 +745,7 @@ describe('ReactIncremental', () => {
745
return this.props.step !== nextProps.step;
746
}
747
render() {
754
- Scheduler.unstable_yieldValue('Content');
748
+ Scheduler.log('Content');
749
return (
750
<div>
751
<Middle>{this.props.step === 0 ? 'Hi' : 'Hello'}</Middle>
@@ -763,7 +757,7 @@ describe('ReactIncremental', () => {
757
}
758
759
function Foo(props) {
766
- Scheduler.unstable_yieldValue('Foo');
760
+ Scheduler.log('Foo');
761
return (
762
<div>
763
<Bar>{props.text}</Bar>
@@ -808,11 +802,11 @@ describe('ReactIncremental', () => {
802
// this.props is the memoized props. So this should return true for
803
// every update except the first one.
804
const shouldUpdate = this.props.step !== 1;
811
- Scheduler.unstable_yieldValue('shouldComponentUpdate: ' + shouldUpdate);
805
+ Scheduler.log('shouldComponentUpdate: ' + shouldUpdate);
806
return shouldUpdate;
807
}
808
render() {
815
- Scheduler.unstable_yieldValue('render');
809
+ Scheduler.log('render');
810
return <div />;
811
}
812
}
@@ -997,7 +991,7 @@ describe('ReactIncremental', () => {
991
992
it('can forceUpdate', async () => {
993
function Baz() {
1000
- Scheduler.unstable_yieldValue('Baz');
994
+ Scheduler.log('Baz');
995
return <div />;
996
}
997
@@ -1011,13 +1005,13 @@ describe('ReactIncremental', () => {
1005
return false;
1006
}
1007
render() {
1014
- Scheduler.unstable_yieldValue('Bar');
1008
+ Scheduler.log('Bar');
1009
return <Baz />;
1010
}
1011
}
1012
1013
function Foo() {
1020
- Scheduler.unstable_yieldValue('Foo');
1014
+ Scheduler.log('Foo');
1015
return (
1016
<div>
1017
<Bar />
@@ -1037,7 +1031,7 @@ describe('ReactIncremental', () => {
1031
class Foo extends React.PureComponent {
1032
render() {
1033
const msg = `A: ${a}, B: ${this.props.b}`;
1040
- Scheduler.unstable_yieldValue(msg);
1034
+ Scheduler.log(msg);
1035
return msg;
1036
}
1037
}
@@ -1067,13 +1061,13 @@ describe('ReactIncremental', () => {
1061
return this.props.x !== newProps.x || this.state.y !== newState.y;
1062
}
1063
render() {
1070
- Scheduler.unstable_yieldValue('Bar:' + this.props.x);
1064
+ Scheduler.log('Bar:' + this.props.x);
1065
return <span prop={String(this.props.x === this.state.y)} />;
1066
}
1067
}
1068
1069
function Foo(props) {
1076
- Scheduler.unstable_yieldValue('Foo');
1070
+ Scheduler.log('Foo');
1071
return [
1072
<Bar key="a" x="A" />,
1073
<Bar key="b" x={props.step === 0 ? 'B' : 'B2'} />,
@@ -1114,9 +1108,7 @@ describe('ReactIncremental', () => {
1108
});
1109
}
1110
render() {
1117
- Scheduler.unstable_yieldValue(
1118
- 'Bar:' + this.props.x + '-' + this.props.step,
1119
- );
1111
+ Scheduler.log('Bar:' + this.props.x + '-' + this.props.step);
1112
return <span prop={String(this.props.x === this.state.y)} />;
1113
}
1114
}
@@ -1124,12 +1116,12 @@ describe('ReactIncremental', () => {
1116
function Baz() {
1117
// This component is used as a sibling to Foo so that we can fully
1118
// complete Foo, without committing.
1127
- Scheduler.unstable_yieldValue('Baz');
1119
+ Scheduler.log('Baz');
1120
return <div />;
1121
}
1122
1123
function Foo(props) {
1132
- Scheduler.unstable_yieldValue('Foo');
1124
+ Scheduler.log('Foo');
1125
return [
1126
<Bar key="a" x="A" step={props.step} />,
1127
<Bar key="b" x="B" step={props.step} />,
@@ -1167,20 +1159,18 @@ describe('ReactIncremental', () => {
1159
class LifeCycle extends React.Component {
1160
state = {x: this.props.x};
1161
UNSAFE_componentWillReceiveProps(nextProps) {
1170
- Scheduler.unstable_yieldValue(
1162
+ Scheduler.log(
1163
'componentWillReceiveProps:' + this.state.x + '-' + nextProps.x,
1164
);
1165
this.setState({x: nextProps.x});
1166
}
1167
UNSAFE_componentWillMount() {
1176
- Scheduler.unstable_yieldValue(
1168
+ Scheduler.log(
1169
'componentWillMount:' + this.state.x + '-' + this.props.x,
1170
);
1171
}
1172
componentDidMount() {
1181
- Scheduler.unstable_yieldValue(
1182
- 'componentDidMount:' + this.state.x + '-' + this.props.x,
1183
- );
1173
+ Scheduler.log('componentDidMount:' + this.state.x + '-' + this.props.x);
1174
}
1175
render() {
1176
return <span />;
@@ -1188,12 +1178,12 @@ describe('ReactIncremental', () => {
1178
}
1179
1180
function Trail() {
1191
- Scheduler.unstable_yieldValue('Trail');
1181
+ Scheduler.log('Trail');
1182
return null;
1183
}
1184
1185
function App(props) {
1196
- Scheduler.unstable_yieldValue('App');
1186
+ Scheduler.log('App');
1187
return (
1188
<div>
1189
<LifeCycle x={props.x} />
@@ -1224,20 +1214,20 @@ describe('ReactIncremental', () => {
1214
this.state = {x: this.props.x + '(ctor)'};
1215
}
1216
UNSAFE_componentWillMount() {
1227
- Scheduler.unstable_yieldValue('componentWillMount:' + this.state.x);
1217
+ Scheduler.log('componentWillMount:' + this.state.x);
1218
this.setState({x: this.props.x + '(willMount)'});
1219
}
1220
componentDidMount() {
1231
- Scheduler.unstable_yieldValue('componentDidMount:' + this.state.x);
1221
+ Scheduler.log('componentDidMount:' + this.state.x);
1222
}
1223
render() {
1234
- Scheduler.unstable_yieldValue('render:' + this.state.x);
1224
+ Scheduler.log('render:' + this.state.x);
1225
return <span />;
1226
}
1227
}
1228
1229
function App(props) {
1240
- Scheduler.unstable_yieldValue('App');
1230
+ Scheduler.log('App');
1231
return <LifeCycle x={props.x} />;
1232
}
1233
@@ -1258,34 +1248,32 @@ describe('ReactIncremental', () => {
1248
xit('calls componentWill* twice if an update render is aborted', async () => {
1249
class LifeCycle extends React.Component {
1250
UNSAFE_componentWillMount() {
1261
- Scheduler.unstable_yieldValue('componentWillMount:' + this.props.x);
1251
+ Scheduler.log('componentWillMount:' + this.props.x);
1252
}
1253
componentDidMount() {
1264
- Scheduler.unstable_yieldValue('componentDidMount:' + this.props.x);
1254
+ Scheduler.log('componentDidMount:' + this.props.x);
1255
}
1256
UNSAFE_componentWillReceiveProps(nextProps) {
1267
- Scheduler.unstable_yieldValue(
1257
+ Scheduler.log(
1258
'componentWillReceiveProps:' + this.props.x + '-' + nextProps.x,
1259
);
1260
}
1261
shouldComponentUpdate(nextProps) {
1272
- Scheduler.unstable_yieldValue(
1262
+ Scheduler.log(
1263
'shouldComponentUpdate:' + this.props.x + '-' + nextProps.x,
1264
);
1265
return true;
1266
}
1267
UNSAFE_componentWillUpdate(nextProps) {
1278
- Scheduler.unstable_yieldValue(
1268
+ Scheduler.log(
1269
'componentWillUpdate:' + this.props.x + '-' + nextProps.x,
1270
);
1271
}
1272
componentDidUpdate(prevProps) {
1283
- Scheduler.unstable_yieldValue(
1284
- 'componentDidUpdate:' + this.props.x + '-' + prevProps.x,
1285
- );
1273
+ Scheduler.log('componentDidUpdate:' + this.props.x + '-' + prevProps.x);
1274
}
1275
render() {
1288
- Scheduler.unstable_yieldValue('render:' + this.props.x);
1276
+ Scheduler.log('render:' + this.props.x);
1277
return <span />;
1278
}
1279
}
@@ -1293,12 +1281,12 @@ describe('ReactIncremental', () => {
1281
function Sibling() {
1282
// The sibling is used to confirm that we've completed the first child,
1283
// but not yet flushed.
1296
- Scheduler.unstable_yieldValue('Sibling');
1284
+ Scheduler.log('Sibling');
1285
return <span />;
1286
}
1287
1288
function App(props) {
1301
- Scheduler.unstable_yieldValue('App');
1289
+ Scheduler.log('App');
1290
1291
return [<LifeCycle key="a" x={props.x} />, <Sibling key="b" />];
1292
}
@@ -1344,17 +1332,17 @@ describe('ReactIncremental', () => {
1332
class LifeCycle extends React.Component {
1333
state = {};
1334
static getDerivedStateFromProps(props, prevState) {
1347
- Scheduler.unstable_yieldValue('getDerivedStateFromProps');
1335
+ Scheduler.log('getDerivedStateFromProps');
1336
return {foo: 'foo'};
1337
}
1338
changeState() {
1339
this.setState({foo: 'bar'});
1340
}
1341
componentDidUpdate() {
1354
- Scheduler.unstable_yieldValue('componentDidUpdate');
1342
+ Scheduler.log('componentDidUpdate');
1343
}
1344
render() {
1357
- Scheduler.unstable_yieldValue('render');
1345
+ Scheduler.log('render');
1346
instance = this;
1347
return null;
1348
}
@@ -1377,18 +1365,18 @@ describe('ReactIncremental', () => {
1365
class Parent extends React.Component {
1366
state = {parentRenders: 0};
1367
static getDerivedStateFromProps(props, prevState) {
1380
- Scheduler.unstable_yieldValue('getDerivedStateFromProps');
1368
+ Scheduler.log('getDerivedStateFromProps');
1369
return prevState.parentRenders + 1;
1370
}
1371
render() {
1384
- Scheduler.unstable_yieldValue('Parent');
1372
+ Scheduler.log('Parent');
1373
return <Child parentRenders={this.state.parentRenders} ref={child} />;
1374
}
1375
}
1376
1377
class Child extends React.Component {
1378
render() {
1391
- Scheduler.unstable_yieldValue('Child');
1379
+ Scheduler.log('Child');
1380
return this.props.parentRenders;
1381
}
1382
}
@@ -1414,32 +1402,30 @@ describe('ReactIncremental', () => {
1402
}
1403
UNSAFE_componentWillMount() {
1404
instances.push(this);
1417
- Scheduler.unstable_yieldValue('componentWillMount:' + this.state.x);
1405
+ Scheduler.log('componentWillMount:' + this.state.x);
1406
}
1407
componentDidMount() {
1420
- Scheduler.unstable_yieldValue('componentDidMount:' + this.state.x);
1408
+ Scheduler.log('componentDidMount:' + this.state.x);
1409
}
1410
UNSAFE_componentWillReceiveProps(nextProps) {
1423
- Scheduler.unstable_yieldValue('componentWillReceiveProps');
1411
+ Scheduler.log('componentWillReceiveProps');
1412
}
1413
shouldComponentUpdate(nextProps, nextState) {
1426
- Scheduler.unstable_yieldValue(
1414
+ Scheduler.log(
1415
'shouldComponentUpdate:' + this.state.x + '-' + nextState.x,
1416
);
1417
return true;
1418
}
1419
UNSAFE_componentWillUpdate(nextProps, nextState) {
1432
- Scheduler.unstable_yieldValue(
1420
+ Scheduler.log(
1421
'componentWillUpdate:' + this.state.x + '-' + nextState.x,
1422
);
1423
}
1424
componentDidUpdate(prevProps, prevState) {
1437
- Scheduler.unstable_yieldValue(
1438
- 'componentDidUpdate:' + this.state.x + '-' + prevState.x,
1439
- );
1425
+ Scheduler.log('componentDidUpdate:' + this.state.x + '-' + prevState.x);
1426
}
1427
render() {
1442
- Scheduler.unstable_yieldValue('render:' + this.state.x);
1428
+ Scheduler.log('render:' + this.state.x);
1429
return <span />;
1430
}
1431
}
@@ -1458,7 +1444,7 @@ describe('ReactIncremental', () => {
1444
});
1445
}
1446
render() {
1461
- Scheduler.unstable_yieldValue('Wrap');
1447
+ Scheduler.log('Wrap');
1448
return <LifeCycle y={this.state.y} />;
1449
}
1450
}
@@ -1466,12 +1452,12 @@ describe('ReactIncremental', () => {
1452
function Sibling() {
1453
// The sibling is used to confirm that we've completed the first child,
1454
// but not yet flushed.
1469
- Scheduler.unstable_yieldValue('Sibling');
1455
+ Scheduler.log('Sibling');
1456
return <span />;
1457
}
1458
1459
function App(props) {
1474
- Scheduler.unstable_yieldValue('App');
1460
+ Scheduler.log('App');
1461
return [<Wrap key="a" />, <Sibling key="b" />];
1462
}
1463
@@ -1544,33 +1530,33 @@ describe('ReactIncremental', () => {
1530
xit('skips will/DidUpdate when bailing unless an update was already in progress', async () => {
1531
class LifeCycle extends React.Component {
1532
UNSAFE_componentWillMount() {
1547
- Scheduler.unstable_yieldValue('componentWillMount');
1533
+ Scheduler.log('componentWillMount');
1534
}
1535
componentDidMount() {
1550
- Scheduler.unstable_yieldValue('componentDidMount');
1536
+ Scheduler.log('componentDidMount');
1537
}
1538
UNSAFE_componentWillReceiveProps(nextProps) {
1553
- Scheduler.unstable_yieldValue('componentWillReceiveProps');
1539
+ Scheduler.log('componentWillReceiveProps');
1540
}
1541
shouldComponentUpdate(nextProps) {
1556
- Scheduler.unstable_yieldValue('shouldComponentUpdate');
1542
+ Scheduler.log('shouldComponentUpdate');
1543
// Bail
1544
return this.props.x !== nextProps.x;
1545
}
1546
UNSAFE_componentWillUpdate(nextProps) {
1561
- Scheduler.unstable_yieldValue('componentWillUpdate');
1547
+ Scheduler.log('componentWillUpdate');
1548
}
1549
componentDidUpdate(prevProps) {
1564
- Scheduler.unstable_yieldValue('componentDidUpdate');
1550
+ Scheduler.log('componentDidUpdate');
1551
}
1552
render() {
1567
- Scheduler.unstable_yieldValue('render');
1553
+ Scheduler.log('render');
1554
return <span />;
1555
}
1556
}
1557
1558
function Sibling() {
1573
- Scheduler.unstable_yieldValue('render sibling');
1559
+ Scheduler.log('render sibling');
1560
return <span />;
1561
}
1562
@@ -1641,22 +1627,14 @@ describe('ReactIncremental', () => {
1627
1628
ReactNoop.flushSync(() => {
1629
ReactNoop.batchedUpdates(() => {
1644
- instance.setState({n: 1}, () =>
1645
- Scheduler.unstable_yieldValue('setState 1'),
1646
- );
1647
- instance.setState({n: 2}, () =>
1648
- Scheduler.unstable_yieldValue('setState 2'),
1649
- );
1630
+ instance.setState({n: 1}, () => Scheduler.log('setState 1'));
1631
+ instance.setState({n: 2}, () => Scheduler.log('setState 2'));
1632
ReactNoop.batchedUpdates(() => {
1651
- instance.setState({n: 3}, () =>
1652
- Scheduler.unstable_yieldValue('setState 3'),
1653
- );
1654
- instance.setState({n: 4}, () =>
1655
- Scheduler.unstable_yieldValue('setState 4'),
1656
- );
1657
- Scheduler.unstable_yieldValue('end inner batchedUpdates');
1633
+ instance.setState({n: 3}, () => Scheduler.log('setState 3'));
1634
+ instance.setState({n: 4}, () => Scheduler.log('setState 4'));
1635
+ Scheduler.log('end inner batchedUpdates');
1636
});
1659
- Scheduler.unstable_yieldValue('end outer batchedUpdates');
1637
+ Scheduler.log('end outer batchedUpdates');
1638
});
1639
});
1640
@@ -1691,16 +1669,12 @@ describe('ReactIncremental', () => {
1669
return {n: n + 1};
1670
}
1671
1694
- instance.setState(updater, () =>
1695
- Scheduler.unstable_yieldValue('first callback'),
1696
- );
1672
+ instance.setState(updater, () => Scheduler.log('first callback'));
1673
instance.setState(updater, () => {
1698
- Scheduler.unstable_yieldValue('second callback');
1674
+ Scheduler.log('second callback');
1675
throw new Error('callback error');
1676
});
1701
- instance.setState(updater, () =>
1702
- Scheduler.unstable_yieldValue('third callback'),
1703
- );
1677
+ instance.setState(updater, () => Scheduler.log('third callback'));
1678
1679
await waitForThrow('callback error');
1680
@@ -1720,7 +1694,7 @@ describe('ReactIncremental', () => {
1694
};
1695
}
1696
render() {
1723
- Scheduler.unstable_yieldValue('Intl ' + JSON.stringify(this.context));
1697
+ Scheduler.log('Intl ' + JSON.stringify(this.context));
1698
return this.props.children;
1699
}
1700
}
@@ -1735,7 +1709,7 @@ describe('ReactIncremental', () => {
1709
};
1710
}
1711
render() {
1738
- Scheduler.unstable_yieldValue('Router ' + JSON.stringify(this.context));
1712
+ Scheduler.log('Router ' + JSON.stringify(this.context));
1713
return this.props.children;
1714
}
1715
}
@@ -1745,9 +1719,7 @@ describe('ReactIncremental', () => {
1719
locale: PropTypes.string,
1720
};
1721
render() {
1748
- Scheduler.unstable_yieldValue(
1749
- 'ShowLocale ' + JSON.stringify(this.context),
1750
- );
1722
+ Scheduler.log('ShowLocale ' + JSON.stringify(this.context));
1723
return this.context.locale;
1724
}
1725
}
@@ -1757,15 +1729,13 @@ describe('ReactIncremental', () => {
1729
route: PropTypes.string,
1730
};
1731
render() {
1760
- Scheduler.unstable_yieldValue(
1761
- 'ShowRoute ' + JSON.stringify(this.context),
1762
- );
1732
+ Scheduler.log('ShowRoute ' + JSON.stringify(this.context));
1733
return this.context.route;
1734
}
1735
}
1736
1737
function ShowBoth(props, context) {
1768
- Scheduler.unstable_yieldValue('ShowBoth ' + JSON.stringify(context));
1738
+ Scheduler.log('ShowBoth ' + JSON.stringify(context));
1739
return `${context.route} in ${context.locale}`;
1740
}
1741
ShowBoth.contextTypes = {
@@ -1775,18 +1745,14 @@ describe('ReactIncremental', () => {
1745
1746
class ShowNeither extends React.Component {
1747
render() {
1778
- Scheduler.unstable_yieldValue(
1779
- 'ShowNeither ' + JSON.stringify(this.context),
1780
- );
1748
+ Scheduler.log('ShowNeither ' + JSON.stringify(this.context));
1749
return null;
1750
}
1751
}
1752
1753
class Indirection extends React.Component {
1754
render() {
1787
- Scheduler.unstable_yieldValue(
1788
- 'Indirection ' + JSON.stringify(this.context),
1789
- );
1755
+ Scheduler.log('Indirection ' + JSON.stringify(this.context));
1756
return [
1757
<ShowLocale key="a" />,
1758
<ShowRoute key="b" />,
@@ -1876,9 +1842,7 @@ describe('ReactIncremental', () => {
1842
return {n: (this.context.n || 3) - 1};
1843
}
1844
render() {
1879
- Scheduler.unstable_yieldValue(
1880
- 'Recurse ' + JSON.stringify(this.context),
1881
- );
1845
+ Scheduler.log('Recurse ' + JSON.stringify(this.context));
1846
if (this.context.n === 0) {
1847
return null;
1848
}
@@ -1903,7 +1867,7 @@ describe('ReactIncremental', () => {
1867
return {n: (context.n || 3) - 1};
1868
},
1869
render() {
1906
- Scheduler.unstable_yieldValue('Recurse ' + JSON.stringify(context));
1870
+ Scheduler.log('Recurse ' + JSON.stringify(context));
1871
if (context.n === 0) {
1872
return null;
1873
}
@@ -1949,7 +1913,7 @@ describe('ReactIncremental', () => {
1913
};
1914
}
1915
render() {
1952
- Scheduler.unstable_yieldValue('Intl ' + JSON.stringify(this.context));
1916
+ Scheduler.log('Intl ' + JSON.stringify(this.context));
1917
return this.props.children;
1918
}
1919
}
@@ -1959,9 +1923,7 @@ describe('ReactIncremental', () => {
1923
locale: PropTypes.string,
1924
};
1925
render() {
1962
- Scheduler.unstable_yieldValue(
1963
- 'ShowLocale ' + JSON.stringify(this.context),
1964
- );
1926
+ Scheduler.log('ShowLocale ' + JSON.stringify(this.context));
1927
return this.context.locale;
1928
}
1929
}
@@ -2004,15 +1966,11 @@ describe('ReactIncremental', () => {
1966
const childContext = {
1967
locale: this.props.locale,
1968
};
2007
- Scheduler.unstable_yieldValue(
2008
- 'Intl:provide ' + JSON.stringify(childContext),
2009
- );
1969
+ Scheduler.log('Intl:provide ' + JSON.stringify(childContext));
1970
return childContext;
1971
}
1972
render() {
2013
- Scheduler.unstable_yieldValue(
2014
- 'Intl:read ' + JSON.stringify(this.context),
2015
- );
1973
+ Scheduler.log('Intl:read ' + JSON.stringify(this.context));
1974
return this.props.children;
1975
}
1976
}
@@ -2022,17 +1980,13 @@ describe('ReactIncremental', () => {
1980
locale: PropTypes.string,
1981
};
1982
render() {
2025
- Scheduler.unstable_yieldValue(
2026
- 'ShowLocaleClass:read ' + JSON.stringify(this.context),
2027
- );
1983
+ Scheduler.log('ShowLocaleClass:read ' + JSON.stringify(this.context));
1984
return this.context.locale;
1985
}
1986
}
1987
1988
function ShowLocaleFn(props, context) {
2033
- Scheduler.unstable_yieldValue(
2034
- 'ShowLocaleFn:read ' + JSON.stringify(context),
2035
- );
1989
+ Scheduler.log('ShowLocaleFn:read ' + JSON.stringify(context));
1990
return context.locale;
1991
}
1992
ShowLocaleFn.contextTypes = {
@@ -2048,15 +2002,13 @@ describe('ReactIncremental', () => {
2002
}
2003
2004
function IndirectionFn(props, context) {
2051
- Scheduler.unstable_yieldValue('IndirectionFn ' + JSON.stringify(context));
2005
+ Scheduler.log('IndirectionFn ' + JSON.stringify(context));
2006
return props.children;
2007
}
2008
2009
class IndirectionClass extends React.Component {
2010
render() {
2057
- Scheduler.unstable_yieldValue(
2058
- 'IndirectionClass ' + JSON.stringify(this.context),
2059
- );
2011
+ Scheduler.log('IndirectionClass ' + JSON.stringify(this.context));
2012
return this.props.children;
2013
}
2014
}
@@ -2100,15 +2052,11 @@ describe('ReactIncremental', () => {
2052
const childContext = {
2053
locale: this.props.locale,
2054
};
2103
- Scheduler.unstable_yieldValue(
2104
- 'Intl:provide ' + JSON.stringify(childContext),
2105
- );
2055
+ Scheduler.log('Intl:provide ' + JSON.stringify(childContext));
2056
return childContext;
2057
}
2058
render() {
2109
- Scheduler.unstable_yieldValue(
2110
- 'Intl:read ' + JSON.stringify(this.context),
2111
- );
2059
+ Scheduler.log('Intl:read ' + JSON.stringify(this.context));
2060
return this.props.children;
2061
}
2062
}
@@ -2118,17 +2066,13 @@ describe('ReactIncremental', () => {
2066
locale: PropTypes.string,
2067
};
2068
render() {
2121
- Scheduler.unstable_yieldValue(
2122
- 'ShowLocaleClass:read ' + JSON.stringify(this.context),
2123
- );
2069
+ Scheduler.log('ShowLocaleClass:read ' + JSON.stringify(this.context));
2070
return this.context.locale;
2071
}
2072
}
2073
2074
function ShowLocaleFn(props, context) {
2129
- Scheduler.unstable_yieldValue(
2130
- 'ShowLocaleFn:read ' + JSON.stringify(context),
2131
- );
2075
+ Scheduler.log('ShowLocaleFn:read ' + JSON.stringify(context));
2076
return context.locale;
2077
}
2078
ShowLocaleFn.contextTypes = {
@@ -2136,15 +2080,13 @@ describe('ReactIncremental', () => {
2080
};
2081
2082
function IndirectionFn(props, context) {
2139
- Scheduler.unstable_yieldValue('IndirectionFn ' + JSON.stringify(context));
2083
+ Scheduler.log('IndirectionFn ' + JSON.stringify(context));
2084
return props.children;
2085
}
2086
2087
class IndirectionClass extends React.Component {
2088
render() {
2145
- Scheduler.unstable_yieldValue(
2146
- 'IndirectionClass ' + JSON.stringify(this.context),
2147
- );
2089
+ Scheduler.log('IndirectionClass ' + JSON.stringify(this.context));
2090
return this.props.children;
2091
}
2092
}
@@ -2293,25 +2235,25 @@ describe('ReactIncremental', () => {
2235
class MyComponent extends React.Component {
2236
static contextTypes = {};
2237
componentDidMount(prevProps, prevState) {
2296
- Scheduler.unstable_yieldValue('componentDidMount');
2238
+ Scheduler.log('componentDidMount');
2239
this.setState({setStateInCDU: true});
2240
}
2241
componentDidUpdate(prevProps, prevState) {
2300
- Scheduler.unstable_yieldValue('componentDidUpdate');
2242
+ Scheduler.log('componentDidUpdate');
2243
if (this.state.setStateInCDU) {
2244
this.setState({setStateInCDU: false});
2245
}
2246
}
2247
UNSAFE_componentWillReceiveProps(nextProps) {
2306
- Scheduler.unstable_yieldValue('componentWillReceiveProps');
2248
+ Scheduler.log('componentWillReceiveProps');
2249
this.setState({setStateInCDU: true});
2250
}
2251
render() {
2310
- Scheduler.unstable_yieldValue('render');
2252
+ Scheduler.log('render');
2253
return null;
2254
}
2255
shouldComponentUpdate(nextProps, nextState) {
2314
- Scheduler.unstable_yieldValue('shouldComponentUpdate');
2256
+ Scheduler.log('shouldComponentUpdate');
2257
return scuCounter++ < 5; // Don't let test hang
2258
}
2259
}
@@ -2443,7 +2385,7 @@ describe('ReactIncremental', () => {
2385
count: PropTypes.number,
2386
};
2387
render = () => {
2446
- Scheduler.unstable_yieldValue(`count:${this.context.count}`);
2388
+ Scheduler.log(`count:${this.context.count}`);
2389
return null;
2390
};
2391
}
@@ -2498,7 +2440,7 @@ describe('ReactIncremental', () => {
2440
count: PropTypes.number,
2441
};
2442
render = () => {
2501
- Scheduler.unstable_yieldValue(`count:${this.context.count}`);
2443
+ Scheduler.log(`count:${this.context.count}`);
2444
return null;
2445
};
2446
}
@@ -2560,7 +2502,7 @@ describe('ReactIncremental', () => {
2502
count: PropTypes.number,
2503
};
2504
render = () => {
2563
- Scheduler.unstable_yieldValue(`count:${this.context.count}`);
2505
+ Scheduler.log(`count:${this.context.count}`);
2506
return null;
2507
};
2508
}
@@ -2634,9 +2576,7 @@ describe('ReactIncremental', () => {
2576
name: PropTypes.string,
2577
};
2578
render = () => {
2637
- Scheduler.unstable_yieldValue(
2638
- `count:${this.context.count}, name:${this.context.name}`,
2639
- );
2579
+ Scheduler.log(`count:${this.context.count}, name:${this.context.name}`);
2580
return null;
2581
};
2582
}
@@ -2660,12 +2600,12 @@ describe('ReactIncremental', () => {
2600
2601
it('does not interrupt for update at same priority', async () => {
2602
function Parent(props) {
2663
- Scheduler.unstable_yieldValue('Parent: ' + props.step);
2603
+ Scheduler.log('Parent: ' + props.step);
2604
return <Child step={props.step} />;
2605
}
2606
2607
function Child(props) {
2668
- Scheduler.unstable_yieldValue('Child: ' + props.step);
2608
+ Scheduler.log('Child: ' + props.step);
2609
return null;
2610
}
2611
@@ -2682,12 +2622,12 @@ describe('ReactIncremental', () => {
2622
2623
it('does not interrupt for update at lower priority', async () => {
2624
function Parent(props) {
2685
- Scheduler.unstable_yieldValue('Parent: ' + props.step);
2625
+ Scheduler.log('Parent: ' + props.step);
2626
return <Child step={props.step} />;
2627
}
2628
2629
function Child(props) {
2690
- Scheduler.unstable_yieldValue('Child: ' + props.step);
2630
+ Scheduler.log('Child: ' + props.step);
2631
return null;
2632
}
2633
@@ -2705,12 +2645,12 @@ describe('ReactIncremental', () => {
2645
2646
it('does interrupt for update at higher priority', async () => {
2647
function Parent(props) {
2708
- Scheduler.unstable_yieldValue('Parent: ' + props.step);
2648
+ Scheduler.log('Parent: ' + props.step);
2649
return <Child step={props.step} />;
2650
}
2651
2652
function Child(props) {
2713
- Scheduler.unstable_yieldValue('Child: ' + props.step);
2653
+ Scheduler.log('Child: ' + props.step);
2654
return null;
2655
}
2656
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+84
-88
@@ -69,31 +69,31 @@ describe('ReactIncrementalErrorHandling', () => {
69
class ErrorBoundary extends React.Component {
70
state = {error: null};
71
static getDerivedStateFromError(error) {
72
- Scheduler.unstable_yieldValue('getDerivedStateFromError');
72
+ Scheduler.log('getDerivedStateFromError');
73
return {error};
74
}
75
render() {
76
if (this.state.error) {
77
- Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
77
+ Scheduler.log('ErrorBoundary (catch)');
78
return <ErrorMessage error={this.state.error} />;
79
}
80
- Scheduler.unstable_yieldValue('ErrorBoundary (try)');
80
+ Scheduler.log('ErrorBoundary (try)');
81
return this.props.children;
82
}
83
}
84
85
function ErrorMessage({error}) {
86
- Scheduler.unstable_yieldValue('ErrorMessage');
86
+ Scheduler.log('ErrorMessage');
87
return <span prop={`Caught an error: ${error.message}`} />;
88
}
89
90
function Indirection({children}) {
91
- Scheduler.unstable_yieldValue('Indirection');
91
+ Scheduler.log('Indirection');
92
return children || null;
93
}
94
95
function BadRender({unused}) {
96
- Scheduler.unstable_yieldValue('throw');
96
+ Scheduler.log('throw');
97
throw new Error('oops!');
98
}
99
@@ -167,31 +167,31 @@ describe('ReactIncrementalErrorHandling', () => {
167
class ErrorBoundary extends React.Component {
168
state = {error: null};
169
componentDidCatch(error) {
170
- Scheduler.unstable_yieldValue('componentDidCatch');
170
+ Scheduler.log('componentDidCatch');
171
this.setState({error});
172
}
173
render() {
174
if (this.state.error) {
175
- Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
175
+ Scheduler.log('ErrorBoundary (catch)');
176
return <ErrorMessage error={this.state.error} />;
177
}
178
- Scheduler.unstable_yieldValue('ErrorBoundary (try)');
178
+ Scheduler.log('ErrorBoundary (try)');
179
return this.props.children;
180
}
181
}
182
183
function ErrorMessage({error}) {
184
- Scheduler.unstable_yieldValue('ErrorMessage');
184
+ Scheduler.log('ErrorMessage');
185
return <span prop={`Caught an error: ${error.message}`} />;
186
}
187
188
function Indirection({children}) {
189
- Scheduler.unstable_yieldValue('Indirection');
189
+ Scheduler.log('Indirection');
190
return children || null;
191
}
192
193
function BadRender({unused}) {
194
- Scheduler.unstable_yieldValue('throw');
194
+ Scheduler.log('throw');
195
throw new Error('oops!');
196
}
197
@@ -250,15 +250,15 @@ describe('ReactIncrementalErrorHandling', () => {
250
it("retries at a lower priority if there's additional pending work", async () => {
251
function App(props) {
252
if (props.isBroken) {
253
- Scheduler.unstable_yieldValue('error');
253
+ Scheduler.log('error');
254
throw new Error('Oops!');
255
}
256
- Scheduler.unstable_yieldValue('success');
256
+ Scheduler.log('success');
257
return <span prop="Everything is fine." />;
258
}
259
260
function onCommit() {
261
- Scheduler.unstable_yieldValue('commit');
261
+ Scheduler.log('commit');
262
}
263
264
React.startTransition(() => {
@@ -293,10 +293,10 @@ describe('ReactIncrementalErrorHandling', () => {
293
it('does not include offscreen work when retrying after an error', async () => {
294
function App(props) {
295
if (props.isBroken) {
296
- Scheduler.unstable_yieldValue('error');
296
+ Scheduler.log('error');
297
throw new Error('Oops!');
298
}
299
- Scheduler.unstable_yieldValue('success');
299
+ Scheduler.log('success');
300
return (
301
<>
302
Everything is fine
@@ -308,7 +308,7 @@ describe('ReactIncrementalErrorHandling', () => {
308
}
309
310
function onCommit() {
311
- Scheduler.unstable_yieldValue('commit');
311
+ Scheduler.log('commit');
312
}
313
314
React.startTransition(() => {
@@ -358,17 +358,17 @@ describe('ReactIncrementalErrorHandling', () => {
358
359
it('retries one more time before handling error', async () => {
360
function BadRender({unused}) {
361
- Scheduler.unstable_yieldValue('BadRender');
361
+ Scheduler.log('BadRender');
362
throw new Error('oops');
363
}
364
365
function Sibling({unused}) {
366
- Scheduler.unstable_yieldValue('Sibling');
366
+ Scheduler.log('Sibling');
367
return <span prop="Sibling" />;
368
}
369
370
function Parent({unused}) {
371
- Scheduler.unstable_yieldValue('Parent');
371
+ Scheduler.log('Parent');
372
return (
373
<>
374
<BadRender />
@@ -378,9 +378,7 @@ describe('ReactIncrementalErrorHandling', () => {
378
}
379
380
React.startTransition(() => {
381
- ReactNoop.render(<Parent />, () =>
382
- Scheduler.unstable_yieldValue('commit'),
383
- );
381
+ ReactNoop.render(<Parent />, () => Scheduler.log('commit'));
382
});
383
384
// Render the bad component asynchronously
@@ -397,12 +395,12 @@ describe('ReactIncrementalErrorHandling', () => {
395
396
it('retries one more time if an error occurs during a render that expires midway through the tree', async () => {
397
function Oops({unused}) {
400
- Scheduler.unstable_yieldValue('Oops');
398
+ Scheduler.log('Oops');
399
throw new Error('Oops');
400
}
401
402
function Text({text}) {
405
- Scheduler.unstable_yieldValue(text);
403
+ Scheduler.log(text);
404
return text;
405
}
406
@@ -458,7 +456,7 @@ describe('ReactIncrementalErrorHandling', () => {
456
throw new Error(`Error ${++id}`);
457
}
458
render() {
461
- Scheduler.unstable_yieldValue('BadMount');
459
+ Scheduler.log('BadMount');
460
return null;
461
}
462
}
@@ -466,14 +464,14 @@ describe('ReactIncrementalErrorHandling', () => {
464
class ErrorBoundary extends React.Component {
465
state = {errorCount: 0};
466
componentDidCatch(error) {
469
- Scheduler.unstable_yieldValue(`componentDidCatch: ${error.message}`);
467
+ Scheduler.log(`componentDidCatch: ${error.message}`);
468
this.setState(state => ({errorCount: state.errorCount + 1}));
469
}
470
render() {
471
if (this.state.errorCount > 0) {
472
return <span prop={`Number of errors: ${this.state.errorCount}`} />;
473
}
476
- Scheduler.unstable_yieldValue('ErrorBoundary');
474
+ Scheduler.log('ErrorBoundary');
475
return this.props.children;
476
}
477
}
@@ -535,23 +533,23 @@ describe('ReactIncrementalErrorHandling', () => {
533
class ErrorBoundary extends React.Component {
534
state = {error: null};
535
componentDidCatch(error) {
538
- Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
536
+ Scheduler.log('ErrorBoundary componentDidCatch');
537
this.setState({error});
538
}
539
render() {
540
if (this.state.error) {
543
- Scheduler.unstable_yieldValue('ErrorBoundary render error');
541
+ Scheduler.log('ErrorBoundary render error');
542
return (
543
<span prop={`Caught an error: ${this.state.error.message}.`} />
544
);
545
}
548
- Scheduler.unstable_yieldValue('ErrorBoundary render success');
546
+ Scheduler.log('ErrorBoundary render success');
547
return this.props.children;
548
}
549
}
550
551
function BrokenRender({unused}) {
554
- Scheduler.unstable_yieldValue('BrokenRender');
552
+ Scheduler.log('BrokenRender');
553
throw new Error('Hello');
554
}
555
@@ -585,23 +583,23 @@ describe('ReactIncrementalErrorHandling', () => {
583
class ErrorBoundary extends React.Component {
584
state = {error: null};
585
componentDidCatch(error) {
588
- Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
586
+ Scheduler.log('ErrorBoundary componentDidCatch');
587
this.setState({error});
588
}
589
render() {
590
if (this.state.error) {
593
- Scheduler.unstable_yieldValue('ErrorBoundary render error');
591
+ Scheduler.log('ErrorBoundary render error');
592
return (
593
<span prop={`Caught an error: ${this.state.error.message}.`} />
594
);
595
}
598
- Scheduler.unstable_yieldValue('ErrorBoundary render success');
596
+ Scheduler.log('ErrorBoundary render success');
597
return this.props.children;
598
}
599
}
600
601
function BrokenRender({unused}) {
604
- Scheduler.unstable_yieldValue('BrokenRender');
602
+ Scheduler.log('BrokenRender');
603
throw new Error('Hello');
604
}
605
@@ -634,23 +632,23 @@ describe('ReactIncrementalErrorHandling', () => {
632
class ErrorBoundary extends React.Component {
633
state = {error: null};
634
componentDidCatch(error) {
637
- Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
635
+ Scheduler.log('ErrorBoundary componentDidCatch');
636
this.setState({error});
637
}
638
render() {
639
if (this.state.error) {
642
- Scheduler.unstable_yieldValue('ErrorBoundary render error');
640
+ Scheduler.log('ErrorBoundary render error');
641
return (
642
<span prop={`Caught an error: ${this.state.error.message}.`} />
643
);
644
}
647
- Scheduler.unstable_yieldValue('ErrorBoundary render success');
645
+ Scheduler.log('ErrorBoundary render success');
646
return this.props.children;
647
}
648
}
649
650
function BrokenRender({unused}) {
653
- Scheduler.unstable_yieldValue('BrokenRender');
651
+ Scheduler.log('BrokenRender');
652
throw new Error('Hello');
653
}
654
@@ -683,17 +681,17 @@ describe('ReactIncrementalErrorHandling', () => {
681
it('propagates an error from a noop error boundary during full deferred mounting', async () => {
682
class RethrowErrorBoundary extends React.Component {
683
componentDidCatch(error) {
686
- Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
684
+ Scheduler.log('RethrowErrorBoundary componentDidCatch');
685
throw error;
686
}
687
render() {
690
- Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
688
+ Scheduler.log('RethrowErrorBoundary render');
689
return this.props.children;
690
}
691
}
692
693
function BrokenRender({unused}) {
696
- Scheduler.unstable_yieldValue('BrokenRender');
694
+ Scheduler.log('BrokenRender');
695
throw new Error('Hello');
696
}
697
@@ -721,17 +719,17 @@ describe('ReactIncrementalErrorHandling', () => {
719
it('propagates an error from a noop error boundary during partial deferred mounting', async () => {
720
class RethrowErrorBoundary extends React.Component {
721
componentDidCatch(error) {
724
- Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
722
+ Scheduler.log('RethrowErrorBoundary componentDidCatch');
723
throw error;
724
}
725
render() {
728
- Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
726
+ Scheduler.log('RethrowErrorBoundary render');
727
return this.props.children;
728
}
729
}
730
731
function BrokenRender({unused}) {
734
- Scheduler.unstable_yieldValue('BrokenRender');
732
+ Scheduler.log('BrokenRender');
733
throw new Error('Hello');
734
}
735
@@ -762,17 +760,17 @@ describe('ReactIncrementalErrorHandling', () => {
760
it('propagates an error from a noop error boundary during synchronous mounting', () => {
761
class RethrowErrorBoundary extends React.Component {
762
componentDidCatch(error) {
765
- Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
763
+ Scheduler.log('RethrowErrorBoundary componentDidCatch');
764
throw error;
765
}
766
render() {
769
- Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
767
+ Scheduler.log('RethrowErrorBoundary render');
768
return this.props.children;
769
}
770
}
771
772
function BrokenRender({unused}) {
775
- Scheduler.unstable_yieldValue('BrokenRender');
773
+ Scheduler.log('BrokenRender');
774
throw new Error('Hello');
775
}
776
@@ -802,17 +800,17 @@ describe('ReactIncrementalErrorHandling', () => {
800
it('propagates an error from a noop error boundary during batched mounting', () => {
801
class RethrowErrorBoundary extends React.Component {
802
componentDidCatch(error) {
805
- Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
803
+ Scheduler.log('RethrowErrorBoundary componentDidCatch');
804
throw error;
805
}
806
render() {
809
- Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
807
+ Scheduler.log('RethrowErrorBoundary render');
808
return this.props.children;
809
}
810
}
811
812
function BrokenRender({unused}) {
815
- Scheduler.unstable_yieldValue('BrokenRender');
813
+ Scheduler.log('BrokenRender');
814
throw new Error('Hello');
815
}
816
@@ -890,12 +888,12 @@ describe('ReactIncrementalErrorHandling', () => {
888
889
it('can schedule updates after uncaught error in render on mount', async () => {
890
function BrokenRender({unused}) {
893
- Scheduler.unstable_yieldValue('BrokenRender');
891
+ Scheduler.log('BrokenRender');
892
throw new Error('Hello');
893
}
894
895
function Foo({unused}) {
898
- Scheduler.unstable_yieldValue('Foo');
896
+ Scheduler.log('Foo');
897
return null;
898
}
899
@@ -913,7 +911,7 @@ describe('ReactIncrementalErrorHandling', () => {
911
912
it('can schedule updates after uncaught error in render on update', async () => {
913
function BrokenRender({shouldThrow}) {
916
- Scheduler.unstable_yieldValue('BrokenRender');
914
+ Scheduler.log('BrokenRender');
915
if (shouldThrow) {
916
throw new Error('Hello');
917
}
@@ -921,7 +919,7 @@ describe('ReactIncrementalErrorHandling', () => {
919
}
920
921
function Foo({unused}) {
924
- Scheduler.unstable_yieldValue('Foo');
922
+ Scheduler.log('Foo');
923
return null;
924
}
925
@@ -952,7 +950,7 @@ describe('ReactIncrementalErrorHandling', () => {
950
}
951
952
function Foo() {
955
- Scheduler.unstable_yieldValue('Foo');
953
+ Scheduler.log('Foo');
954
return null;
955
}
956
@@ -970,7 +968,7 @@ describe('ReactIncrementalErrorHandling', () => {
968
it('should not attempt to recover an unmounting error boundary', async () => {
969
class Parent extends React.Component {
970
componentWillUnmount() {
973
- Scheduler.unstable_yieldValue('Parent componentWillUnmount');
971
+ Scheduler.log('Parent componentWillUnmount');
972
}
973
render() {
974
return <Boundary />;
@@ -979,7 +977,7 @@ describe('ReactIncrementalErrorHandling', () => {
977
978
class Boundary extends React.Component {
979
componentDidCatch(e) {
982
- Scheduler.unstable_yieldValue(`Caught error: ${e.message}`);
980
+ Scheduler.log(`Caught error: ${e.message}`);
981
}
982
render() {
983
return <ThrowsOnUnmount />;
@@ -988,7 +986,7 @@ describe('ReactIncrementalErrorHandling', () => {
986
987
class ThrowsOnUnmount extends React.Component {
988
componentWillUnmount() {
991
- Scheduler.unstable_yieldValue('ThrowsOnUnmount componentWillUnmount');
989
+ Scheduler.log('ThrowsOnUnmount componentWillUnmount');
990
throw new Error('unmount error');
991
}
992
render() {
@@ -1339,9 +1337,7 @@ describe('ReactIncrementalErrorHandling', () => {
1337
class BrokenRenderAndUnmount extends React.Component {
1338
state = {fail: false};
1339
componentWillUnmount() {
1342
- Scheduler.unstable_yieldValue(
1343
- 'BrokenRenderAndUnmount componentWillUnmount',
1344
- );
1340
+ Scheduler.log('BrokenRenderAndUnmount componentWillUnmount');
1341
}
1342
render() {
1343
inst = this;
@@ -1354,7 +1350,7 @@ describe('ReactIncrementalErrorHandling', () => {
1350
1351
class Parent extends React.Component {
1352
componentWillUnmount() {
1357
- Scheduler.unstable_yieldValue('Parent componentWillUnmount [!]');
1353
+ Scheduler.log('Parent componentWillUnmount [!]');
1354
throw new Error('One does not simply unmount me.');
1355
}
1356
render() {
@@ -1396,7 +1392,7 @@ describe('ReactIncrementalErrorHandling', () => {
1392
it('does not interrupt unmounting if detaching a ref throws', async () => {
1393
class Bar extends React.Component {
1394
componentWillUnmount() {
1399
- Scheduler.unstable_yieldValue('Bar unmount');
1395
+ Scheduler.log('Bar unmount');
1396
}
1397
render() {
1398
return <span prop="Bar" />;
@@ -1405,10 +1401,10 @@ describe('ReactIncrementalErrorHandling', () => {
1401
1402
function barRef(inst) {
1403
if (inst === null) {
1408
- Scheduler.unstable_yieldValue('barRef detach');
1404
+ Scheduler.log('barRef detach');
1405
throw new Error('Detach error');
1406
}
1411
- Scheduler.unstable_yieldValue('barRef attach');
1407
+ Scheduler.log('barRef attach');
1408
}
1409
1410
function Foo(props) {
@@ -1455,31 +1451,31 @@ describe('ReactIncrementalErrorHandling', () => {
1451
state = {error: null};
1452
componentDidCatch(error) {
1453
// Should not be called
1458
- Scheduler.unstable_yieldValue('componentDidCatch');
1454
+ Scheduler.log('componentDidCatch');
1455
this.setState({error});
1456
}
1457
render() {
1458
if (this.state.error) {
1463
- Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
1459
+ Scheduler.log('ErrorBoundary (catch)');
1460
return (
1461
<span
1462
prop={`Caught an error: ${this.state.error.nonStandardMessage}`}
1463
/>
1464
);
1465
}
1470
- Scheduler.unstable_yieldValue('ErrorBoundary (try)');
1466
+ Scheduler.log('ErrorBoundary (try)');
1467
return this.props.children;
1468
}
1469
}
1470
1471
function Indirection({children}) {
1476
- Scheduler.unstable_yieldValue('Indirection');
1472
+ Scheduler.log('Indirection');
1473
return children;
1474
}
1475
1476
const notAnError = {nonStandardMessage: 'oops'};
1477
function BadRender({unused}) {
1482
- Scheduler.unstable_yieldValue('BadRender');
1478
+ Scheduler.log('BadRender');
1479
throw notAnError;
1480
}
1481
@@ -1526,31 +1522,31 @@ describe('ReactIncrementalErrorHandling', () => {
1522
class ErrorBoundary extends React.Component {
1523
state = {error: null};
1524
componentDidCatch(error) {
1529
- Scheduler.unstable_yieldValue('componentDidCatch');
1525
+ Scheduler.log('componentDidCatch');
1526
this.setState({error});
1527
}
1528
render() {
1529
if (this.state.error) {
1534
- Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
1530
+ Scheduler.log('ErrorBoundary (catch)');
1531
return <ErrorMessage error={this.state.error} />;
1532
}
1537
- Scheduler.unstable_yieldValue('ErrorBoundary (try)');
1533
+ Scheduler.log('ErrorBoundary (try)');
1534
return this.props.children;
1535
}
1536
}
1537
1538
function ErrorMessage({error}) {
1543
- Scheduler.unstable_yieldValue('ErrorMessage');
1539
+ Scheduler.log('ErrorMessage');
1540
return <span prop={`Caught an error: ${error.message}`} />;
1541
}
1542
1543
function BadRenderSibling({unused}) {
1548
- Scheduler.unstable_yieldValue('BadRenderSibling');
1544
+ Scheduler.log('BadRenderSibling');
1545
return null;
1546
}
1547
1548
function BadRender({unused}) {
1553
- Scheduler.unstable_yieldValue('throw');
1549
+ Scheduler.log('throw');
1550
throw new Error('oops!');
1551
}
1552
@@ -1590,25 +1586,25 @@ describe('ReactIncrementalErrorHandling', () => {
1586
// where we checked for the existence of didUpdate instead of didMount, and
1587
// didMount was not defined.
1588
function BadRender({unused}) {
1593
- Scheduler.unstable_yieldValue('throw');
1589
+ Scheduler.log('throw');
1590
throw new Error('oops!');
1591
}
1592
1593
class Parent extends React.Component {
1594
state = {error: null, other: false};
1595
componentDidCatch(error) {
1600
- Scheduler.unstable_yieldValue('did catch');
1596
+ Scheduler.log('did catch');
1597
this.setState({error});
1598
}
1599
componentDidUpdate() {
1604
- Scheduler.unstable_yieldValue('did update');
1600
+ Scheduler.log('did update');
1601
}
1602
render() {
1603
if (this.state.error) {
1608
- Scheduler.unstable_yieldValue('render error message');
1604
+ Scheduler.log('render error message');
1605
return <span prop={`Caught an error: ${this.state.error.message}`} />;
1606
}
1611
- Scheduler.unstable_yieldValue('render');
1607
+ Scheduler.log('render');
1608
return <BadRender />;
1609
}
1610
}
@@ -1636,7 +1632,7 @@ describe('ReactIncrementalErrorHandling', () => {
1632
}
1633
render() {
1634
if (this.state.errorInfo) {
1639
- Scheduler.unstable_yieldValue('render error message');
1635
+ Scheduler.log('render error message');
1636
return (
1637
<span
1638
prop={`Caught an error:${normalizeCodeLocInfo(
@@ -1722,7 +1718,7 @@ describe('ReactIncrementalErrorHandling', () => {
1718
}
1719
render() {
1720
if (this.state.errorInfo) {
1725
- Scheduler.unstable_yieldValue('render error message');
1721
+ Scheduler.log('render error message');
1722
return (
1723
<span
1724
prop={`Caught an error:${normalizeCodeLocInfo(
@@ -1793,7 +1789,7 @@ describe('ReactIncrementalErrorHandling', () => {
1789
const root = ReactNoop.createRoot();
1790
1791
function Oops({unused}) {
1796
- Scheduler.unstable_yieldValue('Oops');
1792
+ Scheduler.log('Oops');
1793
throw Error('Oops');
1794
}
1795
@@ -1832,7 +1828,7 @@ describe('ReactIncrementalErrorHandling', () => {
1828
}
1829
1830
function AllGood() {
1835
- Scheduler.unstable_yieldValue('Everything is fine.');
1831
+ Scheduler.log('Everything is fine.');
1832
return 'Everything is fine.';
1833
}
1834
packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js
+2
-4
@@ -173,12 +173,10 @@ describe('ReactIncrementalErrorLogging', () => {
173
this.setState({step: 1});
174
}
175
componentWillUnmount() {
176
- Scheduler.unstable_yieldValue(
177
- 'componentWillUnmount: ' + this.state.step,
178
- );
176
+ Scheduler.log('componentWillUnmount: ' + this.state.step);
177
}
178
render() {
181
- Scheduler.unstable_yieldValue('render: ' + this.state.step);
179
+ Scheduler.log('render: ' + this.state.step);
180
if (this.state.step > 0) {
181
throw new Error('oops');
182
}
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js
+12
-33
@@ -51,14 +51,10 @@ describe('ReactIncrementalReflection', () => {
51
}
52
UNSAFE_componentWillMount() {
53
instances.push(this);
54
- Scheduler.unstable_yieldValue(
55
- 'componentWillMount: ' + this._isMounted(),
56
- );
54
+ Scheduler.log('componentWillMount: ' + this._isMounted());
55
}
56
componentDidMount() {
59
- Scheduler.unstable_yieldValue(
60
- 'componentDidMount: ' + this._isMounted(),
61
- );
57
+ Scheduler.log('componentDidMount: ' + this._isMounted());
58
}
59
render() {
60
return <span />;
@@ -95,18 +91,16 @@ describe('ReactIncrementalReflection', () => {
91
instances.push(this);
92
}
93
componentWillUnmount() {
98
- Scheduler.unstable_yieldValue(
99
- 'componentWillUnmount: ' + this._isMounted(),
100
- );
94
+ Scheduler.log('componentWillUnmount: ' + this._isMounted());
95
}
96
render() {
103
- Scheduler.unstable_yieldValue('Component');
97
+ Scheduler.log('Component');
98
return <span />;
99
}
100
}
101
102
function Other() {
109
- Scheduler.unstable_yieldValue('Other');
103
+ Scheduler.log('Other');
104
return <span />;
105
}
106
@@ -153,37 +147,22 @@ describe('ReactIncrementalReflection', () => {
147
class Component extends React.Component {
148
UNSAFE_componentWillMount() {
149
classInstance = this;
156
- Scheduler.unstable_yieldValue([
157
- 'componentWillMount',
158
- findInstance(this),
159
- ]);
150
+ Scheduler.log(['componentWillMount', findInstance(this)]);
151
}
152
componentDidMount() {
162
- Scheduler.unstable_yieldValue([
163
- 'componentDidMount',
164
- findInstance(this),
165
- ]);
153
+ Scheduler.log(['componentDidMount', findInstance(this)]);
154
}
155
UNSAFE_componentWillUpdate() {
168
- Scheduler.unstable_yieldValue([
169
- 'componentWillUpdate',
170
- findInstance(this),
171
- ]);
156
+ Scheduler.log(['componentWillUpdate', findInstance(this)]);
157
}
158
componentDidUpdate() {
174
- Scheduler.unstable_yieldValue([
175
- 'componentDidUpdate',
176
- findInstance(this),
177
- ]);
159
+ Scheduler.log(['componentDidUpdate', findInstance(this)]);
160
}
161
componentWillUnmount() {
180
- Scheduler.unstable_yieldValue([
181
- 'componentWillUnmount',
182
- findInstance(this),
183
- ]);
162
+ Scheduler.log(['componentWillUnmount', findInstance(this)]);
163
}
164
render() {
186
- Scheduler.unstable_yieldValue('render');
165
+ Scheduler.log('render');
166
return this.props.step < 2 ? (
167
<span ref={ref => (this.span = ref)} />
168
) : this.props.step === 2 ? (
@@ -196,7 +175,7 @@ describe('ReactIncrementalReflection', () => {
175
176
function Sibling() {
177
// Sibling is used to assert that we've rendered past the first component.
199
- Scheduler.unstable_yieldValue('render sibling');
178
+ Scheduler.log('render sibling');
179
return <span />;
180
}
181
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js
+14
-18
@@ -97,7 +97,7 @@ describe('ReactIncrementalScheduling', () => {
97
const {useEffect} = React;
98
function Text({text}) {
99
useEffect(() => {
100
- Scheduler.unstable_yieldValue(text);
100
+ Scheduler.log(text);
101
}, [text]);
102
return text;
103
}
@@ -151,24 +151,22 @@ describe('ReactIncrementalScheduling', () => {
151
state = {tick: 0};
152
153
componentDidMount() {
154
- Scheduler.unstable_yieldValue(
154
+ Scheduler.log(
155
'componentDidMount (before setState): ' + this.state.tick,
156
);
157
this.setState({tick: 1});
158
// We're in a batch. Update hasn't flushed yet.
159
- Scheduler.unstable_yieldValue(
160
- 'componentDidMount (after setState): ' + this.state.tick,
161
- );
159
+ Scheduler.log('componentDidMount (after setState): ' + this.state.tick);
160
}
161
162
componentDidUpdate() {
165
- Scheduler.unstable_yieldValue('componentDidUpdate: ' + this.state.tick);
163
+ Scheduler.log('componentDidUpdate: ' + this.state.tick);
164
if (this.state.tick === 2) {
167
- Scheduler.unstable_yieldValue(
165
+ Scheduler.log(
166
'componentDidUpdate (before setState): ' + this.state.tick,
167
);
168
this.setState({tick: 3});
171
- Scheduler.unstable_yieldValue(
169
+ Scheduler.log(
170
'componentDidUpdate (after setState): ' + this.state.tick,
171
);
172
// We're in a batch. Update hasn't flushed yet.
@@ -176,7 +174,7 @@ describe('ReactIncrementalScheduling', () => {
174
}
175
176
render() {
179
- Scheduler.unstable_yieldValue('render: ' + this.state.tick);
177
+ Scheduler.log('render: ' + this.state.tick);
178
instance = this;
179
return <span prop={this.state.tick} />;
180
}
@@ -220,11 +218,11 @@ describe('ReactIncrementalScheduling', () => {
218
219
componentDidMount() {
220
React.startTransition(() => {
223
- Scheduler.unstable_yieldValue(
221
+ Scheduler.log(
222
'componentDidMount (before setState): ' + this.state.tick,
223
);
224
this.setState({tick: 1});
227
- Scheduler.unstable_yieldValue(
225
+ Scheduler.log(
226
'componentDidMount (after setState): ' + this.state.tick,
227
);
228
});
@@ -232,15 +230,13 @@ describe('ReactIncrementalScheduling', () => {
230
231
componentDidUpdate() {
232
React.startTransition(() => {
235
- Scheduler.unstable_yieldValue(
236
- 'componentDidUpdate: ' + this.state.tick,
237
- );
233
+ Scheduler.log('componentDidUpdate: ' + this.state.tick);
234
if (this.state.tick === 2) {
239
- Scheduler.unstable_yieldValue(
235
+ Scheduler.log(
236
'componentDidUpdate (before setState): ' + this.state.tick,
237
);
238
this.setState({tick: 3});
243
- Scheduler.unstable_yieldValue(
239
+ Scheduler.log(
240
'componentDidUpdate (after setState): ' + this.state.tick,
241
);
242
}
@@ -248,7 +244,7 @@ describe('ReactIncrementalScheduling', () => {
244
}
245
246
render() {
251
- Scheduler.unstable_yieldValue('render: ' + this.state.tick);
247
+ Scheduler.log('render: ' + this.state.tick);
248
instance = this;
249
return <span prop={this.state.tick} />;
250
}
@@ -299,7 +295,7 @@ describe('ReactIncrementalScheduling', () => {
295
});
296
}
297
render() {
302
- Scheduler.unstable_yieldValue('Foo');
298
+ Scheduler.log('Foo');
299
return <span prop={this.state.step} />;
300
}
301
}
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+14
-16
@@ -433,12 +433,12 @@ describe('ReactIncrementalSideEffects', () => {
433
434
it('does not update child nodes if a flush is aborted', async () => {
435
function Bar(props) {
436
- Scheduler.unstable_yieldValue('Bar');
436
+ Scheduler.log('Bar');
437
return <span prop={props.text} />;
438
}
439
440
function Foo(props) {
441
- Scheduler.unstable_yieldValue('Foo');
441
+ Scheduler.log('Foo');
442
return (
443
<div>
444
<div>
@@ -482,12 +482,12 @@ describe('ReactIncrementalSideEffects', () => {
482
// @gate www
483
it('preserves a previously rendered node when deprioritized', async () => {
484
function Middle(props) {
485
- Scheduler.unstable_yieldValue('Middle');
485
+ Scheduler.log('Middle');
486
return <span prop={props.children} />;
487
}
488
489
function Foo(props) {
490
- Scheduler.unstable_yieldValue('Foo');
490
+ Scheduler.log('Foo');
491
return (
492
<div>
493
<LegacyHiddenDiv mode="hidden">
@@ -508,9 +508,7 @@ describe('ReactIncrementalSideEffects', () => {
508
</div>,
509
);
510
511
- ReactNoop.render(<Foo text="bar" />, () =>
512
- Scheduler.unstable_yieldValue('commit'),
513
- );
511
+ ReactNoop.render(<Foo text="bar" />, () => Scheduler.log('commit'));
512
await waitFor(['Foo', 'commit']);
513
expect(ReactNoop.getChildrenAsJSX()).toEqual(
514
<div>
@@ -533,7 +531,7 @@ describe('ReactIncrementalSideEffects', () => {
531
// @gate www
532
it('can reuse side-effects after being preempted', async () => {
533
function Bar(props) {
536
- Scheduler.unstable_yieldValue('Bar');
534
+ Scheduler.log('Bar');
535
return <span prop={props.children} />;
536
}
537
@@ -545,7 +543,7 @@ describe('ReactIncrementalSideEffects', () => {
543
);
544
545
function Foo(props) {
548
- Scheduler.unstable_yieldValue('Foo');
546
+ Scheduler.log('Foo');
547
return (
548
<LegacyHiddenDiv mode="hidden">
549
{props.step === 0 ? (
@@ -576,7 +574,7 @@ describe('ReactIncrementalSideEffects', () => {
574
// Make a quick update which will schedule low priority work to
575
// update the middle content.
576
ReactNoop.render(<Foo text="bar" step={1} />, () =>
579
- Scheduler.unstable_yieldValue('commit'),
577
+ Scheduler.log('commit'),
578
);
579
await waitFor(['Foo', 'commit', 'Bar']);
580
@@ -617,7 +615,7 @@ describe('ReactIncrementalSideEffects', () => {
615
return this.props.children !== nextProps.children;
616
}
617
render() {
620
- Scheduler.unstable_yieldValue('Bar');
618
+ Scheduler.log('Bar');
619
return <span prop={this.props.children} />;
620
}
621
}
@@ -627,7 +625,7 @@ describe('ReactIncrementalSideEffects', () => {
625
return this.props.step !== nextProps.step;
626
}
627
render() {
630
- Scheduler.unstable_yieldValue('Content');
628
+ Scheduler.log('Content');
629
return (
630
<div>
631
<Bar>{this.props.step === 0 ? 'Hi' : 'Hello'}</Bar>
@@ -638,7 +636,7 @@ describe('ReactIncrementalSideEffects', () => {
636
}
637
638
function Foo(props) {
641
- Scheduler.unstable_yieldValue('Foo');
639
+ Scheduler.log('Foo');
640
return (
641
<LegacyHiddenDiv mode="hidden">
642
<Content step={props.step} text={props.text} />
@@ -696,7 +694,7 @@ describe('ReactIncrementalSideEffects', () => {
694
695
it('can update a completed tree before it has a chance to commit', async () => {
696
function Foo(props) {
699
- Scheduler.unstable_yieldValue('Foo');
697
+ Scheduler.log('Foo');
698
return <span prop={props.step} />;
699
}
700
React.startTransition(() => {
@@ -998,12 +996,12 @@ describe('ReactIncrementalSideEffects', () => {
996
}
997
render() {
998
barInstances.push(this);
1001
- Scheduler.unstable_yieldValue('Bar');
999
+ Scheduler.log('Bar');
1000
return <span prop={this.state.active ? 'X' : this.props.idx} />;
1001
}
1002
}
1003
function Foo(props) {
1006
- Scheduler.unstable_yieldValue('Foo');
1004
+ Scheduler.log('Foo');
1005
return (
1006
<div>
1007
<span prop={props.tick} />
packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.js
+1
-1
@@ -216,7 +216,7 @@ describe('ReactIncrementalTriangle', () => {
216
}
217
render() {
218
if (yieldAfterEachRender) {
219
- Scheduler.unstable_yieldValue(this);
219
+ Scheduler.log(this);
220
}
221
const {counter, remainingDepth} = this.props;
222
return (
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js
+20
-20
@@ -50,7 +50,7 @@ describe('ReactIncrementalUpdates', () => {
50
class Foo extends React.Component {
51
state = {};
52
componentDidMount() {
53
- Scheduler.unstable_yieldValue('commit');
53
+ Scheduler.log('commit');
54
React.startTransition(() => {
55
// Has low priority
56
this.setState({b: 'b'});
@@ -99,13 +99,13 @@ describe('ReactIncrementalUpdates', () => {
99
class Foo extends React.Component {
100
state = {};
101
componentDidMount() {
102
- Scheduler.unstable_yieldValue('componentDidMount');
102
+ Scheduler.log('componentDidMount');
103
}
104
componentDidUpdate() {
105
- Scheduler.unstable_yieldValue('componentDidUpdate');
105
+ Scheduler.log('componentDidUpdate');
106
}
107
render() {
108
- Scheduler.unstable_yieldValue('render');
108
+ Scheduler.log('render');
109
instance = this;
110
return <div />;
111
}
@@ -152,7 +152,7 @@ describe('ReactIncrementalUpdates', () => {
152
153
function createUpdate(letter) {
154
return () => {
155
- Scheduler.unstable_yieldValue(letter);
155
+ Scheduler.log(letter);
156
return {
157
[letter]: letter,
158
};
@@ -239,7 +239,7 @@ describe('ReactIncrementalUpdates', () => {
239
240
function createUpdate(letter) {
241
return () => {
242
- Scheduler.unstable_yieldValue(letter);
242
+ Scheduler.log(letter);
243
return {
244
[letter]: letter,
245
};
@@ -340,16 +340,16 @@ describe('ReactIncrementalUpdates', () => {
340
class Foo extends React.Component {
341
state = {};
342
componentDidMount() {
343
- Scheduler.unstable_yieldValue('did mount');
343
+ Scheduler.log('did mount');
344
this.setState({a: 'a'}, () => {
345
- Scheduler.unstable_yieldValue('callback a');
345
+ Scheduler.log('callback a');
346
this.setState({b: 'b'}, () => {
347
- Scheduler.unstable_yieldValue('callback b');
347
+ Scheduler.log('callback b');
348
});
349
});
350
}
351
render() {
352
- Scheduler.unstable_yieldValue('render');
352
+ Scheduler.log('render');
353
return <div />;
354
}
355
}
@@ -371,11 +371,11 @@ describe('ReactIncrementalUpdates', () => {
371
class Foo extends React.Component {
372
state = {};
373
UNSAFE_componentWillReceiveProps() {
374
- Scheduler.unstable_yieldValue('componentWillReceiveProps');
374
+ Scheduler.log('componentWillReceiveProps');
375
this.setState({b: 'b'});
376
}
377
render() {
378
- Scheduler.unstable_yieldValue('render');
378
+ Scheduler.log('render');
379
instance = this;
380
return <div />;
381
}
@@ -403,7 +403,7 @@ describe('ReactIncrementalUpdates', () => {
403
class Foo extends React.Component {
404
state = {};
405
render() {
406
- Scheduler.unstable_yieldValue('render');
406
+ Scheduler.log('render');
407
instance = this;
408
return <div />;
409
}
@@ -416,7 +416,7 @@ describe('ReactIncrementalUpdates', () => {
416
]);
417
418
instance.setState(function a() {
419
- Scheduler.unstable_yieldValue('setState updater');
419
+ Scheduler.log('setState updater');
420
this.setState({b: 'b'});
421
return {a: 'a'};
422
});
@@ -526,10 +526,10 @@ describe('ReactIncrementalUpdates', () => {
526
function App() {
527
const [count, _setCount] = useState(0);
528
setCount = _setCount;
529
- Scheduler.unstable_yieldValue('Render: ' + count);
529
+ Scheduler.log('Render: ' + count);
530
useLayoutEffect(() => {
531
setCount(prevCount => prevCount + 1);
532
- Scheduler.unstable_yieldValue('Commit: ' + count);
532
+ Scheduler.log('Commit: ' + count);
533
}, []);
534
return null;
535
}
@@ -553,7 +553,7 @@ describe('ReactIncrementalUpdates', () => {
553
554
it('regression: does not expire soon due to previous flushSync', () => {
555
function Text({text}) {
556
- Scheduler.unstable_yieldValue(text);
556
+ Scheduler.log(text);
557
return text;
558
}
559
@@ -573,7 +573,7 @@ describe('ReactIncrementalUpdates', () => {
573
574
it('regression: does not expire soon due to previous expired work', () => {
575
function Text({text}) {
576
- Scheduler.unstable_yieldValue(text);
576
+ Scheduler.log(text);
577
return text;
578
}
579
@@ -604,7 +604,7 @@ describe('ReactIncrementalUpdates', () => {
604
};
605
606
useLayoutEffect(() => {
607
- Scheduler.unstable_yieldValue('Committed: ' + log);
607
+ Scheduler.log('Committed: ' + log);
608
if (log === 'B') {
609
// Right after B commits, schedule additional updates.
610
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
@@ -663,7 +663,7 @@ describe('ReactIncrementalUpdates', () => {
663
this.setState(prevState => ({log: prevState.log + msg}));
664
};
665
componentDidUpdate() {
666
- Scheduler.unstable_yieldValue('Committed: ' + this.state.log);
666
+ Scheduler.log('Committed: ' + this.state.log);
667
if (this.state.log === 'B') {
668
// Right after B commits, schedule additional updates.
669
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js
+1
-1
@@ -28,7 +28,7 @@ describe('ReactInterleavedUpdates', () => {
28
});
29
30
function Text({text}) {
31
- Scheduler.unstable_yieldValue(text);
31
+ Scheduler.log(text);
32
return text;
33
}
34
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
+42
-48
@@ -42,7 +42,7 @@ describe('ReactLazy', () => {
42
});
43
44
function Text(props) {
45
- Scheduler.unstable_yieldValue(props.text);
45
+ Scheduler.log(props.text);
46
return props.text;
47
}
48
@@ -246,10 +246,10 @@ describe('ReactLazy', () => {
246
it('mount and reorder', async () => {
247
class Child extends React.Component {
248
componentDidMount() {
249
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
249
+ Scheduler.log('Did mount: ' + this.props.label);
250
}
251
componentDidUpdate() {
252
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
252
+ Scheduler.log('Did update: ' + this.props.label);
253
}
254
render() {
255
return <Text text={this.props.label} />;
@@ -334,7 +334,7 @@ describe('ReactLazy', () => {
334
335
it('resolves defaultProps without breaking memoization', async () => {
336
function LazyImpl(props) {
337
- Scheduler.unstable_yieldValue('Lazy');
337
+ Scheduler.log('Lazy');
338
return (
339
<>
340
<Text text={props.siblingText} />
@@ -482,42 +482,38 @@ describe('ReactLazy', () => {
482
state = {};
483
484
static getDerivedStateFromProps(props) {
485
- Scheduler.unstable_yieldValue(
486
- `getDerivedStateFromProps: ${props.text}`,
487
- );
485
+ Scheduler.log(`getDerivedStateFromProps: ${props.text}`);
486
return null;
487
}
488
489
constructor(props) {
490
super(props);
493
- Scheduler.unstable_yieldValue(`constructor: ${this.props.text}`);
491
+ Scheduler.log(`constructor: ${this.props.text}`);
492
}
493
494
componentDidMount() {
497
- Scheduler.unstable_yieldValue(`componentDidMount: ${this.props.text}`);
495
+ Scheduler.log(`componentDidMount: ${this.props.text}`);
496
}
497
498
componentDidUpdate(prevProps) {
501
- Scheduler.unstable_yieldValue(
499
+ Scheduler.log(
500
`componentDidUpdate: ${prevProps.text} -> ${this.props.text}`,
501
);
502
}
503
504
componentWillUnmount() {
507
- Scheduler.unstable_yieldValue(
508
- `componentWillUnmount: ${this.props.text}`,
509
- );
505
+ Scheduler.log(`componentWillUnmount: ${this.props.text}`);
506
}
507
508
shouldComponentUpdate(nextProps) {
513
- Scheduler.unstable_yieldValue(
509
+ Scheduler.log(
510
`shouldComponentUpdate: ${this.props.text} -> ${nextProps.text}`,
511
);
512
return true;
513
}
514
515
getSnapshotBeforeUpdate(prevProps) {
520
- Scheduler.unstable_yieldValue(
516
+ Scheduler.log(
517
`getSnapshotBeforeUpdate: ${prevProps.text} -> ${this.props.text}`,
518
);
519
return null;
@@ -586,19 +582,17 @@ describe('ReactLazy', () => {
582
state = {};
583
584
UNSAFE_componentWillMount() {
589
- Scheduler.unstable_yieldValue(
590
- `UNSAFE_componentWillMount: ${this.props.text}`,
591
- );
585
+ Scheduler.log(`UNSAFE_componentWillMount: ${this.props.text}`);
586
}
587
588
UNSAFE_componentWillUpdate(nextProps) {
595
- Scheduler.unstable_yieldValue(
589
+ Scheduler.log(
590
`UNSAFE_componentWillUpdate: ${this.props.text} -> ${nextProps.text}`,
591
);
592
}
593
594
UNSAFE_componentWillReceiveProps(nextProps) {
601
- Scheduler.unstable_yieldValue(
595
+ Scheduler.log(
596
`UNSAFE_componentWillReceiveProps: ${this.props.text} -> ${nextProps.text}`,
597
);
598
}
@@ -649,7 +643,7 @@ describe('ReactLazy', () => {
643
644
it('resolves defaultProps on the outer wrapper but warns', async () => {
645
function T(props) {
652
- Scheduler.unstable_yieldValue(props.inner + ' ' + props.outer);
646
+ Scheduler.log(props.inner + ' ' + props.outer);
647
return props.inner + ' ' + props.outer;
648
}
649
T.defaultProps = {inner: 'Hi'};
@@ -1022,7 +1016,7 @@ describe('ReactLazy', () => {
1016
it('includes lazy-loaded component in warning stack', async () => {
1017
const Foo = props => <div>{[<Text text="A" />, <Text text="B" />]}</div>;
1018
const LazyFoo = lazy(() => {
1025
- Scheduler.unstable_yieldValue('Started loading');
1019
+ Scheduler.log('Started loading');
1020
return fakeImport(Foo);
1021
});
1022
@@ -1062,7 +1056,7 @@ describe('ReactLazy', () => {
1056
}
1057
}
1058
const ForwardRefBar = React.forwardRef((props, ref) => {
1065
- Scheduler.unstable_yieldValue('forwardRef');
1059
+ Scheduler.log('forwardRef');
1060
return <Bar ref={ref} />;
1061
});
1062
@@ -1335,13 +1329,13 @@ describe('ReactLazy', () => {
1329
it('mount and reorder lazy types', async () => {
1330
class Child extends React.Component {
1331
componentWillUnmount() {
1338
- Scheduler.unstable_yieldValue('Did unmount: ' + this.props.label);
1332
+ Scheduler.log('Did unmount: ' + this.props.label);
1333
}
1334
componentDidMount() {
1341
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
1335
+ Scheduler.log('Did mount: ' + this.props.label);
1336
}
1337
componentDidUpdate() {
1344
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
1338
+ Scheduler.log('Did update: ' + this.props.label);
1339
}
1340
render() {
1341
return <Text text={this.props.label} />;
@@ -1357,20 +1351,20 @@ describe('ReactLazy', () => {
1351
}
1352
1353
const LazyChildA = lazy(() => {
1360
- Scheduler.unstable_yieldValue('Init A');
1354
+ Scheduler.log('Init A');
1355
return fakeImport(ChildA);
1356
});
1357
const LazyChildB = lazy(() => {
1364
- Scheduler.unstable_yieldValue('Init B');
1358
+ Scheduler.log('Init B');
1359
return fakeImport(ChildB);
1360
});
1361
const LazyChildA2 = lazy(() => {
1368
- Scheduler.unstable_yieldValue('Init A2');
1362
+ Scheduler.log('Init A2');
1363
return fakeImport(ChildA);
1364
});
1365
let resolveB2;
1366
const LazyChildB2 = lazy(() => {
1373
- Scheduler.unstable_yieldValue('Init B2');
1367
+ Scheduler.log('Init B2');
1368
return new Promise(r => {
1369
resolveB2 = r;
1370
});
@@ -1423,10 +1417,10 @@ describe('ReactLazy', () => {
1417
it('mount and reorder lazy types (legacy mode)', async () => {
1418
class Child extends React.Component {
1419
componentDidMount() {
1426
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
1420
+ Scheduler.log('Did mount: ' + this.props.label);
1421
}
1422
componentDidUpdate() {
1429
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
1423
+ Scheduler.log('Did update: ' + this.props.label);
1424
}
1425
render() {
1426
return <Text text={this.props.label} />;
@@ -1442,19 +1436,19 @@ describe('ReactLazy', () => {
1436
}
1437
1438
const LazyChildA = lazy(() => {
1445
- Scheduler.unstable_yieldValue('Init A');
1439
+ Scheduler.log('Init A');
1440
return fakeImport(ChildA);
1441
});
1442
const LazyChildB = lazy(() => {
1449
- Scheduler.unstable_yieldValue('Init B');
1443
+ Scheduler.log('Init B');
1444
return fakeImport(ChildB);
1445
});
1446
const LazyChildA2 = lazy(() => {
1453
- Scheduler.unstable_yieldValue('Init A2');
1447
+ Scheduler.log('Init A2');
1448
return fakeImport(ChildA);
1449
});
1450
const LazyChildB2 = lazy(() => {
1457
- Scheduler.unstable_yieldValue('Init B2');
1451
+ Scheduler.log('Init B2');
1452
return fakeImport(ChildB);
1453
});
1454
@@ -1496,10 +1490,10 @@ describe('ReactLazy', () => {
1490
it('mount and reorder lazy elements', async () => {
1491
class Child extends React.Component {
1492
componentDidMount() {
1499
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
1493
+ Scheduler.log('Did mount: ' + this.props.label);
1494
}
1495
componentDidUpdate() {
1502
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
1496
+ Scheduler.log('Did update: ' + this.props.label);
1497
}
1498
render() {
1499
return <Text text={this.props.label} />;
@@ -1508,22 +1502,22 @@ describe('ReactLazy', () => {
1502
1503
const ChildA = <Child key="A" label="A" />;
1504
const lazyChildA = lazy(() => {
1511
- Scheduler.unstable_yieldValue('Init A');
1505
+ Scheduler.log('Init A');
1506
return fakeImport(ChildA);
1507
});
1508
const ChildB = <Child key="B" label="B" />;
1509
const lazyChildB = lazy(() => {
1516
- Scheduler.unstable_yieldValue('Init B');
1510
+ Scheduler.log('Init B');
1511
return fakeImport(ChildB);
1512
});
1513
const ChildA2 = <Child key="A" label="a" />;
1514
const lazyChildA2 = lazy(() => {
1521
- Scheduler.unstable_yieldValue('Init A2');
1515
+ Scheduler.log('Init A2');
1516
return fakeImport(ChildA2);
1517
});
1518
const ChildB2 = <Child key="B" label="b" />;
1519
const lazyChildB2 = lazy(() => {
1526
- Scheduler.unstable_yieldValue('Init B2');
1520
+ Scheduler.log('Init B2');
1521
return fakeImport(ChildB2);
1522
});
1523
@@ -1567,10 +1561,10 @@ describe('ReactLazy', () => {
1561
it('mount and reorder lazy elements (legacy mode)', async () => {
1562
class Child extends React.Component {
1563
componentDidMount() {
1570
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
1564
+ Scheduler.log('Did mount: ' + this.props.label);
1565
}
1566
componentDidUpdate() {
1573
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
1567
+ Scheduler.log('Did update: ' + this.props.label);
1568
}
1569
render() {
1570
return <Text text={this.props.label} />;
@@ -1579,22 +1573,22 @@ describe('ReactLazy', () => {
1573
1574
const ChildA = <Child key="A" label="A" />;
1575
const lazyChildA = lazy(() => {
1582
- Scheduler.unstable_yieldValue('Init A');
1576
+ Scheduler.log('Init A');
1577
return fakeImport(ChildA);
1578
});
1579
const ChildB = <Child key="B" label="B" />;
1580
const lazyChildB = lazy(() => {
1587
- Scheduler.unstable_yieldValue('Init B');
1581
+ Scheduler.log('Init B');
1582
return fakeImport(ChildB);
1583
});
1584
const ChildA2 = <Child key="A" label="a" />;
1585
const lazyChildA2 = lazy(() => {
1592
- Scheduler.unstable_yieldValue('Init A2');
1586
+ Scheduler.log('Init A2');
1587
return fakeImport(ChildA2);
1588
});
1589
const ChildB2 = <Child key="B" label="b" />;
1590
const lazyChildB2 = lazy(() => {
1597
- Scheduler.unstable_yieldValue('Init B2');
1591
+ Scheduler.log('Init B2');
1592
return fakeImport(ChildB2);
1593
});
1594
packages/react-reconciler/src/__tests__/ReactMemo-test.js
+5
-7
@@ -38,7 +38,7 @@ describe('memo', () => {
38
});
39
40
function Text(props) {
41
- Scheduler.unstable_yieldValue(props.text);
41
+ Scheduler.log(props.text);
42
return <span prop={props.text} />;
43
}
44
@@ -209,7 +209,7 @@ describe('memo', () => {
209
useEffect(() => {
210
if (props !== prevProps.current) {
211
prevProps.current = props;
212
- Scheduler.unstable_yieldValue('Props changed [SimpleMemo]');
212
+ Scheduler.log('Props changed [SimpleMemo]');
213
}
214
}, [props]);
215
@@ -226,7 +226,7 @@ describe('memo', () => {
226
useEffect(() => {
227
if (props !== prevProps.current) {
228
prevProps.current = props;
229
- Scheduler.unstable_yieldValue('Props changed [ComplexMemo]');
229
+ Scheduler.log('Props changed [ComplexMemo]');
230
}
231
}, [props]);
232
@@ -246,9 +246,7 @@ describe('memo', () => {
246
useEffect(() => {
247
if (props !== prevProps.current) {
248
prevProps.current = props;
249
- Scheduler.unstable_yieldValue(
250
- 'Props changed [MemoWithIndirection]',
251
- );
249
+ Scheduler.log('Props changed [MemoWithIndirection]');
250
}
251
}, [props]);
252
@@ -336,7 +334,7 @@ describe('memo', () => {
334
return <Text text={count} />;
335
}
336
Counter = memo(Counter, (oldProps, newProps) => {
339
- Scheduler.unstable_yieldValue(
337
+ Scheduler.log(
338
`Old count: ${oldProps.count}, New count: ${newProps.count}`,
339
);
340
return oldProps.count === newProps.count;
packages/react-reconciler/src/__tests__/ReactNewContext-test.js
+39
-39
@@ -39,7 +39,7 @@ describe('ReactNewContext', () => {
39
});
40
41
function Text(props) {
42
- Scheduler.unstable_yieldValue(props.text);
42
+ Scheduler.log(props.text);
43
return <span prop={props.text} />;
44
}
45
@@ -153,7 +153,7 @@ describe('ReactNewContext', () => {
153
const ContextConsumer = getConsumer(Context);
154
155
function Provider(props) {
156
- Scheduler.unstable_yieldValue('Provider');
156
+ Scheduler.log('Provider');
157
return (
158
<Context.Provider value={props.value}>
159
{props.children}
@@ -162,11 +162,11 @@ describe('ReactNewContext', () => {
162
}
163
164
function Consumer(props) {
165
- Scheduler.unstable_yieldValue('Consumer');
165
+ Scheduler.log('Consumer');
166
return (
167
<ContextConsumer>
168
{value => {
169
- Scheduler.unstable_yieldValue('Consumer render prop');
169
+ Scheduler.log('Consumer render prop');
170
return <span prop={'Result: ' + value} />;
171
}}
172
</ContextConsumer>
@@ -178,13 +178,13 @@ describe('ReactNewContext', () => {
178
return false;
179
}
180
render() {
181
- Scheduler.unstable_yieldValue('Indirection');
181
+ Scheduler.log('Indirection');
182
return this.props.children;
183
}
184
}
185
186
function App(props) {
187
- Scheduler.unstable_yieldValue('App');
187
+ Scheduler.log('App');
188
return (
189
<Provider value={props.value}>
190
<Indirection>
@@ -218,7 +218,7 @@ describe('ReactNewContext', () => {
218
const ContextConsumer = getConsumer(Context);
219
220
function Provider(props) {
221
- Scheduler.unstable_yieldValue('Provider');
221
+ Scheduler.log('Provider');
222
return (
223
<Context.Provider value={props.value}>
224
{props.children}
@@ -227,11 +227,11 @@ describe('ReactNewContext', () => {
227
}
228
229
function Consumer(props) {
230
- Scheduler.unstable_yieldValue('Consumer');
230
+ Scheduler.log('Consumer');
231
return (
232
<ContextConsumer>
233
{value => {
234
- Scheduler.unstable_yieldValue('Consumer render prop');
234
+ Scheduler.log('Consumer render prop');
235
return <span prop={'Result: ' + value} />;
236
}}
237
</ContextConsumer>
@@ -243,13 +243,13 @@ describe('ReactNewContext', () => {
243
return false;
244
}
245
render() {
246
- Scheduler.unstable_yieldValue('Indirection');
246
+ Scheduler.log('Indirection');
247
return this.props.children;
248
}
249
}
250
251
function App(props) {
252
- Scheduler.unstable_yieldValue('App');
252
+ Scheduler.log('App');
253
return (
254
<Provider value={props.value}>
255
<Indirection>
@@ -458,7 +458,7 @@ describe('ReactNewContext', () => {
458
const ContextConsumer = getConsumer(Context);
459
460
function Provider(props) {
461
- Scheduler.unstable_yieldValue('Provider');
461
+ Scheduler.log('Provider');
462
return (
463
<Context.Provider value={props.value}>
464
{props.children}
@@ -467,11 +467,11 @@ describe('ReactNewContext', () => {
467
}
468
469
function Consumer(props) {
470
- Scheduler.unstable_yieldValue('Consumer');
470
+ Scheduler.log('Consumer');
471
return (
472
<ContextConsumer>
473
{value => {
474
- Scheduler.unstable_yieldValue('Consumer render prop');
474
+ Scheduler.log('Consumer render prop');
475
return <span prop={'Result: ' + value} />;
476
}}
477
</ContextConsumer>
@@ -483,13 +483,13 @@ describe('ReactNewContext', () => {
483
return false;
484
}
485
render() {
486
- Scheduler.unstable_yieldValue('Indirection');
486
+ Scheduler.log('Indirection');
487
return this.props.children;
488
}
489
}
490
491
function App(props) {
492
- Scheduler.unstable_yieldValue('App');
492
+ Scheduler.log('App');
493
return (
494
<Provider value={props.value}>
495
<Indirection>
@@ -583,7 +583,7 @@ describe('ReactNewContext', () => {
583
class Child extends React.Component {
584
state = {step: 0};
585
render() {
586
- Scheduler.unstable_yieldValue('Child');
586
+ Scheduler.log('Child');
587
return (
588
<span
589
prop={`Context: ${this.props.context}, Step: ${this.state.step}`}
@@ -597,7 +597,7 @@ describe('ReactNewContext', () => {
597
<Context.Provider value={props.value}>
598
<Consumer>
599
{value => {
600
- Scheduler.unstable_yieldValue('Consumer render prop');
600
+ Scheduler.log('Consumer render prop');
601
return <Child ref={inst => (child = inst)} context={value} />;
602
}}
603
</Consumer>
@@ -624,24 +624,24 @@ describe('ReactNewContext', () => {
624
const Consumer = getConsumer(Context);
625
626
function renderChildValue(value) {
627
- Scheduler.unstable_yieldValue('Consumer');
627
+ Scheduler.log('Consumer');
628
return <span prop={value} />;
629
}
630
631
function ChildWithInlineRenderCallback() {
632
- Scheduler.unstable_yieldValue('ChildWithInlineRenderCallback');
632
+ Scheduler.log('ChildWithInlineRenderCallback');
633
// Note: we are intentionally passing an inline arrow. Don't refactor.
634
return <Consumer>{value => renderChildValue(value)}</Consumer>;
635
}
636
637
function ChildWithCachedRenderCallback() {
638
- Scheduler.unstable_yieldValue('ChildWithCachedRenderCallback');
638
+ Scheduler.log('ChildWithCachedRenderCallback');
639
return <Consumer>{renderChildValue}</Consumer>;
640
}
641
642
class PureIndirection extends React.PureComponent {
643
render() {
644
- Scheduler.unstable_yieldValue('PureIndirection');
644
+ Scheduler.log('PureIndirection');
645
return (
646
<>
647
<ChildWithInlineRenderCallback />
@@ -653,7 +653,7 @@ describe('ReactNewContext', () => {
653
654
class App extends React.Component {
655
render() {
656
- Scheduler.unstable_yieldValue('App');
656
+ Scheduler.log('App');
657
return (
658
<Context.Provider value={this.props.value}>
659
<PureIndirection />
@@ -781,7 +781,7 @@ describe('ReactNewContext', () => {
781
};
782
783
render() {
784
- Scheduler.unstable_yieldValue('App');
784
+ Scheduler.log('App');
785
return (
786
<Context.Provider value={this.state.step}>
787
<StaticContent />
@@ -809,7 +809,7 @@ describe('ReactNewContext', () => {
809
return (
810
<ContextConsumer>
811
{value => {
812
- Scheduler.unstable_yieldValue('Consumer');
812
+ Scheduler.log('Consumer');
813
return <span prop={value} />;
814
}}
815
</ContextConsumer>
@@ -872,7 +872,7 @@ describe('ReactNewContext', () => {
872
const Context = React.createContext(0);
873
874
function Foo(props) {
875
- Scheduler.unstable_yieldValue('Foo');
875
+ Scheduler.log('Foo');
876
return null;
877
}
878
@@ -917,7 +917,7 @@ describe('ReactNewContext', () => {
917
const Context = React.createContext(0);
918
919
function Foo(props) {
920
- Scheduler.unstable_yieldValue('Foo');
920
+ Scheduler.log('Foo');
921
return null;
922
}
923
@@ -957,14 +957,14 @@ describe('ReactNewContext', () => {
957
const Context = React.createContext(0);
958
959
function Child() {
960
- Scheduler.unstable_yieldValue('Child');
960
+ Scheduler.log('Child');
961
return <span prop="Child" />;
962
}
963
964
const children = <Child />;
965
966
function App(props) {
967
- Scheduler.unstable_yieldValue('App');
967
+ Scheduler.log('App');
968
return (
969
<Context.Provider value={props.value}>{children}</Context.Provider>
970
);
@@ -988,7 +988,7 @@ describe('ReactNewContext', () => {
988
const Context = React.createContext(0);
989
990
function Child() {
991
- Scheduler.unstable_yieldValue('Child');
991
+ Scheduler.log('Child');
992
return <span prop="Child" />;
993
}
994
@@ -1003,7 +1003,7 @@ describe('ReactNewContext', () => {
1003
return {legacyValue: this.state.legacyValue};
1004
}
1005
render() {
1006
- Scheduler.unstable_yieldValue('LegacyProvider');
1006
+ Scheduler.log('LegacyProvider');
1007
return this.props.children;
1008
}
1009
}
@@ -1011,7 +1011,7 @@ describe('ReactNewContext', () => {
1011
class App extends React.Component {
1012
state = {value: 1};
1013
render() {
1014
- Scheduler.unstable_yieldValue('App');
1014
+ Scheduler.log('App');
1015
return (
1016
<Context.Provider value={this.state.value}>
1017
{this.props.children}
@@ -1131,12 +1131,12 @@ describe('ReactNewContext', () => {
1131
};
1132
1133
renderConsumer = context => {
1134
- Scheduler.unstable_yieldValue('App#renderConsumer');
1134
+ Scheduler.log('App#renderConsumer');
1135
return <span prop={this.state.text} />;
1136
};
1137
1138
render() {
1139
- Scheduler.unstable_yieldValue('App');
1139
+ Scheduler.log('App');
1140
return (
1141
<Context.Provider value={this.props.value}>
1142
<Consumer>{this.renderConsumer}</Consumer>
@@ -1274,12 +1274,12 @@ describe('ReactNewContext', () => {
1274
};
1275
1276
renderConsumer = context => {
1277
- Scheduler.unstable_yieldValue('App#renderConsumer');
1277
+ Scheduler.log('App#renderConsumer');
1278
return <span prop={this.state.text} />;
1279
};
1280
1281
render() {
1282
- Scheduler.unstable_yieldValue('App');
1282
+ Scheduler.log('App');
1283
return (
1284
<Context.Provider value={this.props.value}>
1285
<Consumer>{this.renderConsumer}</Consumer>
@@ -1385,12 +1385,12 @@ describe('ReactNewContext', () => {
1385
};
1386
1387
renderConsumer = context => {
1388
- Scheduler.unstable_yieldValue('App#renderConsumer');
1388
+ Scheduler.log('App#renderConsumer');
1389
return <span prop={this.state.text} />;
1390
};
1391
1392
render() {
1393
- Scheduler.unstable_yieldValue('App');
1393
+ Scheduler.log('App');
1394
return (
1395
<Context.Provider value={this.props.value}>
1396
<Consumer>{this.renderConsumer}</Consumer>
@@ -1512,7 +1512,7 @@ describe('ReactNewContext', () => {
1512
return false;
1513
}
1514
render() {
1515
- Scheduler.unstable_yieldValue();
1515
+ Scheduler.log();
1516
if (this.props.depth >= this.props.maxDepth) {
1517
return null;
1518
}
packages/react-reconciler/src/__tests__/ReactNoopRendererAct-test.js
+2
-2
@@ -43,9 +43,9 @@ describe('internal act()', () => {
43
function App() {
44
const [ctr, setCtr] = React.useState(0);
45
async function someAsyncFunction() {
46
- Scheduler.unstable_yieldValue('stage 1');
46
+ Scheduler.log('stage 1');
47
await null;
48
- Scheduler.unstable_yieldValue('stage 2');
48
+ Scheduler.log('stage 2');
49
await null;
50
setCtr(1);
51
}
packages/react-reconciler/src/__tests__/ReactOffscreen-test.js
+52
-52
@@ -38,22 +38,22 @@ describe('ReactOffscreen', () => {
38
});
39
40
function Text(props) {
41
- Scheduler.unstable_yieldValue(props.text);
41
+ Scheduler.log(props.text);
42
return <span prop={props.text}>{props.children}</span>;
43
}
44
45
function LoggedText({text, children}) {
46
useEffect(() => {
47
- Scheduler.unstable_yieldValue(`mount ${text}`);
47
+ Scheduler.log(`mount ${text}`);
48
return () => {
49
- Scheduler.unstable_yieldValue(`unmount ${text}`);
49
+ Scheduler.log(`unmount ${text}`);
50
};
51
});
52
53
useLayoutEffect(() => {
54
- Scheduler.unstable_yieldValue(`mount layout ${text}`);
54
+ Scheduler.log(`mount layout ${text}`);
55
return () => {
56
- Scheduler.unstable_yieldValue(`unmount layout ${text}`);
56
+ Scheduler.log(`unmount layout ${text}`);
57
};
58
});
59
return <Text text={text}>{children}</Text>;
@@ -213,9 +213,9 @@ describe('ReactOffscreen', () => {
213
it('mounts without layout effects when hidden', async () => {
214
function Child({text}) {
215
useLayoutEffect(() => {
216
- Scheduler.unstable_yieldValue('Mount layout');
216
+ Scheduler.log('Mount layout');
217
return () => {
218
- Scheduler.unstable_yieldValue('Unmount layout');
218
+ Scheduler.log('Unmount layout');
219
};
220
}, []);
221
return <Text text="Child" />;
@@ -251,9 +251,9 @@ describe('ReactOffscreen', () => {
251
it('mounts/unmounts layout effects when visibility changes (starting visible)', async () => {
252
function Child({text}) {
253
useLayoutEffect(() => {
254
- Scheduler.unstable_yieldValue('Mount layout');
254
+ Scheduler.log('Mount layout');
255
return () => {
256
- Scheduler.unstable_yieldValue('Unmount layout');
256
+ Scheduler.log('Unmount layout');
257
};
258
}, []);
259
return <Text text="Child" />;
@@ -304,11 +304,11 @@ describe('ReactOffscreen', () => {
304
}
305
306
componentWillUnmount() {
307
- Scheduler.unstable_yieldValue('componentWillUnmount');
307
+ Scheduler.log('componentWillUnmount');
308
}
309
310
componentDidMount() {
311
- Scheduler.unstable_yieldValue('componentDidMount');
311
+ Scheduler.log('componentDidMount');
312
}
313
}
314
@@ -366,7 +366,7 @@ describe('ReactOffscreen', () => {
366
);
367
});
368
369
- Scheduler.unstable_clearYields();
369
+ Scheduler.unstable_clearLog();
370
371
await act(async () => {
372
// Outer offscreen is visible.
@@ -401,9 +401,9 @@ describe('ReactOffscreen', () => {
401
it('mounts/unmounts layout effects when visibility changes (starting hidden)', async () => {
402
function Child({text}) {
403
useLayoutEffect(() => {
404
- Scheduler.unstable_yieldValue('Mount layout');
404
+ Scheduler.log('Mount layout');
405
return () => {
406
- Scheduler.unstable_yieldValue('Unmount layout');
406
+ Scheduler.log('Unmount layout');
407
};
408
}, []);
409
return <Text text="Child" />;
@@ -449,11 +449,11 @@ describe('ReactOffscreen', () => {
449
const root = ReactNoop.createRoot();
450
function Child({text}) {
451
useLayoutEffect(() => {
452
- Scheduler.unstable_yieldValue('Mount layout');
452
+ Scheduler.log('Mount layout');
453
return () => {
454
// The child should not be hidden yet.
455
expect(root).toMatchRenderedOutput(<span prop="Child" />);
456
- Scheduler.unstable_yieldValue('Unmount layout');
456
+ Scheduler.log('Unmount layout');
457
};
458
}, []);
459
return <Text text="Child" />;
@@ -489,9 +489,9 @@ describe('ReactOffscreen', () => {
489
// do anything to effects. Only used by www, as a temporary migration step.
490
function Child({text}) {
491
useLayoutEffect(() => {
492
- Scheduler.unstable_yieldValue('Mount layout');
492
+ Scheduler.log('Mount layout');
493
return () => {
494
- Scheduler.unstable_yieldValue('Unmount layout');
494
+ Scheduler.log('Unmount layout');
495
};
496
}, []);
497
return <Text text="Child" />;
@@ -818,7 +818,7 @@ describe('ReactOffscreen', () => {
818
// the component isn't visible.
819
await act(async () => {
820
child.setState({text: 'B'}, () => {
821
- Scheduler.unstable_yieldValue('B update finished');
821
+ Scheduler.log('B update finished');
822
});
823
});
824
assertLog(['B']);
@@ -834,7 +834,7 @@ describe('ReactOffscreen', () => {
834
</Offscreen>,
835
);
836
child.setState({text: 'C'}, () => {
837
- Scheduler.unstable_yieldValue('C update finished');
837
+ Scheduler.log('C update finished');
838
});
839
});
840
assertLog(['C', 'B update finished', 'C update finished']);
@@ -845,13 +845,13 @@ describe('ReactOffscreen', () => {
845
it('does not call componentDidUpdate when reappearing a hidden class component', async () => {
846
class Child extends React.Component {
847
componentDidMount() {
848
- Scheduler.unstable_yieldValue('componentDidMount');
848
+ Scheduler.log('componentDidMount');
849
}
850
componentDidUpdate() {
851
- Scheduler.unstable_yieldValue('componentDidUpdate');
851
+ Scheduler.log('componentDidUpdate');
852
}
853
componentWillUnmount() {
854
- Scheduler.unstable_yieldValue('componentWillUnmount');
854
+ Scheduler.log('componentWillUnmount');
855
}
856
render() {
857
return 'Child';
@@ -898,9 +898,9 @@ describe('ReactOffscreen', () => {
898
async () => {
899
function Child({label}) {
900
useLayoutEffect(() => {
901
- Scheduler.unstable_yieldValue('Mount ' + label);
901
+ Scheduler.log('Mount ' + label);
902
return () => {
903
- Scheduler.unstable_yieldValue('Unmount ' + label);
903
+ Scheduler.log('Unmount ' + label);
904
};
905
}, [label]);
906
return label;
@@ -951,10 +951,10 @@ describe('ReactOffscreen', () => {
951
async () => {
952
class Child extends React.Component {
953
componentDidMount() {
954
- Scheduler.unstable_yieldValue('Mount ' + this.props.label);
954
+ Scheduler.log('Mount ' + this.props.label);
955
}
956
componentWillUnmount() {
957
- Scheduler.unstable_yieldValue('Unmount ' + this.props.label);
957
+ Scheduler.log('Unmount ' + this.props.label);
958
}
959
render() {
960
return this.props.label;
@@ -990,7 +990,7 @@ describe('ReactOffscreen', () => {
990
// Reappear the component and also add some new siblings.
991
await act(async () => {
992
setStateB(null, () => {
993
- Scheduler.unstable_yieldValue('setState callback B');
993
+ Scheduler.log('setState callback B');
994
});
995
root.render(
996
<Offscreen mode="visible">
@@ -1011,9 +1011,9 @@ describe('ReactOffscreen', () => {
1011
it('defer passive effects when prerendering a new Offscreen tree', async () => {
1012
function Child({label}) {
1013
useEffect(() => {
1014
- Scheduler.unstable_yieldValue('Mount ' + label);
1014
+ Scheduler.log('Mount ' + label);
1015
return () => {
1016
- Scheduler.unstable_yieldValue('Unmount ' + label);
1016
+ Scheduler.log('Unmount ' + label);
1017
};
1018
}, [label]);
1019
return <Text text={label} />;
@@ -1073,9 +1073,9 @@ describe('ReactOffscreen', () => {
1073
it('do not defer passive effects when prerendering a new LegacyHidden tree', async () => {
1074
function Child({label}) {
1075
useEffect(() => {
1076
- Scheduler.unstable_yieldValue('Mount ' + label);
1076
+ Scheduler.log('Mount ' + label);
1077
return () => {
1078
- Scheduler.unstable_yieldValue('Unmount ' + label);
1078
+ Scheduler.log('Unmount ' + label);
1079
};
1080
}, [label]);
1081
return <Text text={label} />;
@@ -1129,9 +1129,9 @@ describe('ReactOffscreen', () => {
1129
it('passive effects are connected and disconnected when the visibility changes', async () => {
1130
function Child({step}) {
1131
useEffect(() => {
1132
- Scheduler.unstable_yieldValue(`Commit mount [${step}]`);
1132
+ Scheduler.log(`Commit mount [${step}]`);
1133
return () => {
1134
- Scheduler.unstable_yieldValue(`Commit unmount [${step}]`);
1134
+ Scheduler.log(`Commit unmount [${step}]`);
1135
};
1136
}, [step]);
1137
return <Text text={step} />;
@@ -1186,18 +1186,18 @@ describe('ReactOffscreen', () => {
1186
it('passive effects are unmounted on hide in the same order as during a deletion: parent before child', async () => {
1187
function Child({label}) {
1188
useEffect(() => {
1189
- Scheduler.unstable_yieldValue('Mount Child');
1189
+ Scheduler.log('Mount Child');
1190
return () => {
1191
- Scheduler.unstable_yieldValue('Unmount Child');
1191
+ Scheduler.log('Unmount Child');
1192
};
1193
}, []);
1194
return <div>Hi</div>;
1195
}
1196
function Parent() {
1197
useEffect(() => {
1198
- Scheduler.unstable_yieldValue('Mount Parent');
1198
+ Scheduler.log('Mount Parent');
1199
return () => {
1200
- Scheduler.unstable_yieldValue('Unmount Parent');
1200
+ Scheduler.log('Unmount Parent');
1201
};
1202
}, []);
1203
return <Child />;
@@ -1244,9 +1244,9 @@ describe('ReactOffscreen', () => {
1244
it.skip("don't defer passive effects when prerendering in a tree whose effects are already connected", async () => {
1245
function Child({label}) {
1246
useEffect(() => {
1247
- Scheduler.unstable_yieldValue('Mount ' + label);
1247
+ Scheduler.log('Mount ' + label);
1248
return () => {
1249
- Scheduler.unstable_yieldValue('Unmount ' + label);
1249
+ Scheduler.log('Unmount ' + label);
1250
};
1251
}, [label]);
1252
return <Text text={label} />;
@@ -1300,9 +1300,9 @@ describe('ReactOffscreen', () => {
1300
it('does not mount effects when prerendering a nested Offscreen boundary', async () => {
1301
function Child({label}) {
1302
useEffect(() => {
1303
- Scheduler.unstable_yieldValue('Mount ' + label);
1303
+ Scheduler.log('Mount ' + label);
1304
return () => {
1305
- Scheduler.unstable_yieldValue('Unmount ' + label);
1305
+ Scheduler.log('Unmount ' + label);
1306
};
1307
}, [label]);
1308
return <Text text={label} />;
@@ -1378,9 +1378,9 @@ describe('ReactOffscreen', () => {
1378
it('reveal an outer Offscreen boundary without revealing an inner one', async () => {
1379
function Child({label}) {
1380
useEffect(() => {
1381
- Scheduler.unstable_yieldValue('Mount ' + label);
1381
+ Scheduler.log('Mount ' + label);
1382
return () => {
1383
- Scheduler.unstable_yieldValue('Unmount ' + label);
1383
+ Scheduler.log('Unmount ' + label);
1384
};
1385
}, [label]);
1386
return <Text text={label} />;
@@ -1819,15 +1819,15 @@ describe('ReactOffscreen', () => {
1819
function Child() {
1820
spanRef = useRef(null);
1821
useEffect(() => {
1822
- Scheduler.unstable_yieldValue('Mount Child');
1822
+ Scheduler.log('Mount Child');
1823
return () => {
1824
- Scheduler.unstable_yieldValue('Unmount Child');
1824
+ Scheduler.log('Unmount Child');
1825
};
1826
});
1827
useLayoutEffect(() => {
1828
- Scheduler.unstable_yieldValue('Mount Layout Child');
1828
+ Scheduler.log('Mount Layout Child');
1829
return () => {
1830
- Scheduler.unstable_yieldValue('Unmount Layout Child');
1830
+ Scheduler.log('Unmount Layout Child');
1831
};
1832
});
1833
@@ -1974,9 +1974,9 @@ describe('ReactOffscreen', () => {
1974
it('batches multiple attach and detach calls scheduled from an event handler', async () => {
1975
function Child() {
1976
useEffect(() => {
1977
- Scheduler.unstable_yieldValue('attach child');
1977
+ Scheduler.log('attach child');
1978
return () => {
1979
- Scheduler.unstable_yieldValue('detach child');
1979
+ Scheduler.log('detach child');
1980
};
1981
}, []);
1982
return 'child';
@@ -2028,9 +2028,9 @@ describe('ReactOffscreen', () => {
2028
it('batches multiple attach and detach calls scheduled from an effect', async () => {
2029
function Child() {
2030
useEffect(() => {
2031
- Scheduler.unstable_yieldValue('attach child');
2031
+ Scheduler.log('attach child');
2032
return () => {
2033
- Scheduler.unstable_yieldValue('detach child');
2033
+ Scheduler.log('detach child');
2034
};
2035
}, []);
2036
return 'child';
packages/react-reconciler/src/__tests__/ReactOffscreenSuspense-test.js
+6
-8
@@ -55,7 +55,7 @@ describe('ReactOffscreen', () => {
55
if (record !== undefined) {
56
switch (record.status) {
57
case 'pending':
58
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
58
+ Scheduler.log(`Suspend! [${text}]`);
59
throw record.value;
60
case 'rejected':
61
throw record.value;
@@ -63,7 +63,7 @@ describe('ReactOffscreen', () => {
63
return record.value;
64
}
65
} else {
66
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
66
+ Scheduler.log(`Suspend! [${text}]`);
67
const thenable = {
68
pings: [],
69
then(resolve) {
@@ -86,13 +86,13 @@ describe('ReactOffscreen', () => {
86
}
87
88
function Text({text}) {
89
- Scheduler.unstable_yieldValue(text);
89
+ Scheduler.log(text);
90
return text;
91
}
92
93
function AsyncText({text}) {
94
readText(text);
95
- Scheduler.unstable_yieldValue(text);
95
+ Scheduler.log(text);
96
return text;
97
}
98
@@ -427,11 +427,9 @@ describe('ReactOffscreen', () => {
427
// Inner and outer values are always updated simultaneously, so they
428
// should always be consistent.
429
if (inner !== outer) {
430
- Scheduler.unstable_yieldValue(
431
- 'Tearing! Inner and outer are inconsistent!',
432
- );
430
+ Scheduler.log('Tearing! Inner and outer are inconsistent!');
431
} else {
434
- Scheduler.unstable_yieldValue('Inner and outer are consistent');
432
+ Scheduler.log('Inner and outer are consistent');
433
}
434
}, [inner, outer]);
435
packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js
+13
-17
@@ -60,25 +60,21 @@ describe('ReactSchedulerIntegration', () => {
60
const {useEffect, useLayoutEffect} = React;
61
function Effects({step}) {
62
useLayoutEffect(() => {
63
- Scheduler.unstable_yieldValue('Layout Effect');
63
+ Scheduler.log('Layout Effect');
64
Scheduler.unstable_scheduleCallback(NormalPriority, () =>
65
- Scheduler.unstable_yieldValue(
66
- 'Scheduled Normal Callback from Layout Effect',
67
- ),
65
+ Scheduler.log('Scheduled Normal Callback from Layout Effect'),
66
);
67
});
68
useEffect(() => {
71
- Scheduler.unstable_yieldValue('Passive Effect');
69
+ Scheduler.log('Passive Effect');
70
});
71
return null;
72
}
73
function CleanupEffect() {
74
useLayoutEffect(() => () => {
77
- Scheduler.unstable_yieldValue('Cleanup Layout Effect');
75
+ Scheduler.log('Cleanup Layout Effect');
76
Scheduler.unstable_scheduleCallback(NormalPriority, () =>
79
- Scheduler.unstable_yieldValue(
80
- 'Scheduled Normal Callback from Cleanup Layout Effect',
81
- ),
77
+ Scheduler.log('Scheduled Normal Callback from Cleanup Layout Effect'),
78
);
79
});
80
return null;
@@ -107,9 +103,9 @@ describe('ReactSchedulerIntegration', () => {
103
root.render('Initial');
104
await waitForAll([]);
105
110
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
111
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
112
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
106
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'));
107
+ scheduleCallback(NormalPriority, () => Scheduler.log('B'));
108
+ scheduleCallback(NormalPriority, () => Scheduler.log('C'));
109
110
// Schedule a React render. React will request a paint after committing it.
111
React.startTransition(() => {
@@ -119,8 +115,8 @@ describe('ReactSchedulerIntegration', () => {
115
// Advance time just to be sure the next tasks have lower priority
116
Scheduler.unstable_advanceTime(2000);
117
122
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
123
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('E'));
118
+ scheduleCallback(NormalPriority, () => Scheduler.log('D'));
119
+ scheduleCallback(NormalPriority, () => Scheduler.log('E'));
120
121
// Flush everything up to the next paint. Should yield after the
122
// React commit.
@@ -131,7 +127,7 @@ describe('ReactSchedulerIntegration', () => {
127
// @gate www
128
it('idle updates are not blocked by offscreen work', async () => {
129
function Text({text}) {
134
- Scheduler.unstable_yieldValue(text);
130
+ Scheduler.log(text);
131
return text;
132
}
133
@@ -200,7 +196,7 @@ describe(
196
...actual,
197
unstable_shouldYield() {
198
if (logDuringShouldYield) {
203
- actual.unstable_yieldValue('shouldYield');
199
+ actual.log('shouldYield');
200
}
201
return actual.unstable_shouldYield();
202
},
@@ -273,7 +269,7 @@ describe(
269
// Scheduler API. That being said, feel free to rewrite or delete this
270
// test if/when the API changes.
271
function Text({text}) {
276
- Scheduler.unstable_yieldValue(text);
272
+ Scheduler.log(text);
273
return text;
274
}
275
packages/react-reconciler/src/__tests__/ReactSubtreeFlagsWarning-test.js
+5
-5
@@ -86,16 +86,16 @@ describe('ReactSuspenseWithNoopRenderer', () => {
86
if (record !== undefined) {
87
switch (record.status) {
88
case 'pending':
89
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
89
+ Scheduler.log(`Suspend! [${text}]`);
90
throw record.value;
91
case 'rejected':
92
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
92
+ Scheduler.log(`Error! [${text}]`);
93
throw record.value;
94
case 'resolved':
95
return textCache.version;
96
}
97
} else {
98
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
98
+ Scheduler.log(`Suspend! [${text}]`);
99
100
const thenable = {
101
pings: [],
@@ -142,10 +142,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
142
readText(text);
143
144
useEffect(() => {
145
- Scheduler.unstable_yieldValue('Effect');
145
+ Scheduler.log('Effect');
146
}, []);
147
148
- Scheduler.unstable_yieldValue(text);
148
+ Scheduler.log(text);
149
return text;
150
});
151
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+62
-74
@@ -47,16 +47,12 @@ describe('ReactSuspense', () => {
47
listeners = [{resolve, reject}];
48
setTimeout(() => {
49
if (textResourceShouldFail) {
50
- Scheduler.unstable_yieldValue(
51
- `Promise rejected [${text}]`,
52
- );
50
+ Scheduler.log(`Promise rejected [${text}]`);
51
status = 'rejected';
52
value = new Error('Failed to load: ' + text);
53
listeners.forEach(listener => listener.reject(value));
54
} else {
57
- Scheduler.unstable_yieldValue(
58
- `Promise resolved [${text}]`,
59
- );
55
+ Scheduler.log(`Promise resolved [${text}]`);
56
status = 'resolved';
57
value = text;
58
listeners.forEach(listener => listener.resolve(value));
@@ -85,7 +81,7 @@ describe('ReactSuspense', () => {
81
});
82
83
function Text(props) {
88
- Scheduler.unstable_yieldValue(props.text);
84
+ Scheduler.log(props.text);
85
return props.text;
86
}
87
@@ -93,13 +89,13 @@ describe('ReactSuspense', () => {
89
const text = props.text;
90
try {
91
TextResource.read([props.text, props.ms]);
96
- Scheduler.unstable_yieldValue(text);
92
+ Scheduler.log(text);
93
return text;
94
} catch (promise) {
95
if (typeof promise.then === 'function') {
100
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
96
+ Scheduler.log(`Suspend! [${text}]`);
97
} else {
102
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
98
+ Scheduler.log(`Error! [${text}]`);
99
}
100
throw promise;
101
}
@@ -107,12 +103,12 @@ describe('ReactSuspense', () => {
103
104
it('suspends rendering and continues later', async () => {
105
function Bar(props) {
110
- Scheduler.unstable_yieldValue('Bar');
106
+ Scheduler.log('Bar');
107
return props.children;
108
}
109
110
function Foo({renderBar}) {
115
- Scheduler.unstable_yieldValue('Foo');
111
+ Scheduler.log('Foo');
112
return (
113
<Suspense fallback={<Text text="Loading..." />}>
114
{renderBar ? (
@@ -226,10 +222,10 @@ describe('ReactSuspense', () => {
222
223
function Async() {
224
if (!didResolve) {
229
- Scheduler.unstable_yieldValue('Suspend!');
225
+ Scheduler.log('Suspend!');
226
throw thenable;
227
}
232
- Scheduler.unstable_yieldValue('Async');
228
+ Scheduler.log('Async');
229
return 'Async';
230
}
231
@@ -277,7 +273,7 @@ describe('ReactSuspense', () => {
273
274
it('throttles fallback committing globally', async () => {
275
function Foo() {
280
- Scheduler.unstable_yieldValue('Foo');
276
+ Scheduler.log('Foo');
277
return (
278
<Suspense fallback={<Text text="Loading..." />}>
279
<AsyncText text="A" ms={200} />
@@ -332,7 +328,7 @@ describe('ReactSuspense', () => {
328
329
it('does not throttle fallback committing for too long', async () => {
330
function Foo() {
335
- Scheduler.unstable_yieldValue('Foo');
331
+ Scheduler.log('Foo');
332
return (
333
<Suspense fallback={<Text text="Loading..." />}>
334
<AsyncText text="A" ms={200} />
@@ -389,10 +385,10 @@ describe('ReactSuspense', () => {
385
it('mounts a lazy class component in non-concurrent mode', async () => {
386
class Class extends React.Component {
387
componentDidMount() {
392
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
388
+ Scheduler.log('Did mount: ' + this.props.label);
389
}
390
componentDidUpdate() {
395
- Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
391
+ Scheduler.log('Did update: ' + this.props.label);
392
}
393
render() {
394
return <Text text={this.props.label} />;
@@ -429,13 +425,13 @@ describe('ReactSuspense', () => {
425
const text = useContext(ValueContext);
426
try {
427
TextResource.read([text, 1000]);
432
- Scheduler.unstable_yieldValue(text);
428
+ Scheduler.log(text);
429
return text;
430
} catch (promise) {
431
if (typeof promise.then === 'function') {
436
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
432
+ Scheduler.log(`Suspend! [${text}]`);
433
} else {
438
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
434
+ Scheduler.log(`Error! [${text}]`);
435
}
436
throw promise;
437
}
@@ -484,13 +480,13 @@ describe('ReactSuspense', () => {
480
const text = useContext(ValueContext);
481
try {
482
TextResource.read([text, 1000]);
487
- Scheduler.unstable_yieldValue(text);
483
+ Scheduler.log(text);
484
return text;
485
} catch (promise) {
486
if (typeof promise.then === 'function') {
491
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
487
+ Scheduler.log(`Suspend! [${text}]`);
488
} else {
493
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
489
+ Scheduler.log(`Error! [${text}]`);
490
}
491
throw promise;
492
}
@@ -542,13 +538,13 @@ describe('ReactSuspense', () => {
538
const text = useContext(ValueContext);
539
try {
540
TextResource.read([text, 1000]);
545
- Scheduler.unstable_yieldValue(text);
541
+ Scheduler.log(text);
542
return text;
543
} catch (promise) {
544
if (typeof promise.then === 'function') {
549
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
545
+ Scheduler.log(`Suspend! [${text}]`);
546
} else {
551
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
547
+ Scheduler.log(`Error! [${text}]`);
548
}
549
throw promise;
550
}
@@ -599,13 +595,13 @@ describe('ReactSuspense', () => {
595
const text = useContext(ValueContext);
596
try {
597
TextResource.read([text, 1000]);
602
- Scheduler.unstable_yieldValue(text);
598
+ Scheduler.log(text);
599
return text;
600
} catch (promise) {
601
if (typeof promise.then === 'function') {
606
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
602
+ Scheduler.log(`Suspend! [${text}]`);
603
} else {
608
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
604
+ Scheduler.log(`Error! [${text}]`);
605
}
606
throw promise;
607
}
@@ -649,11 +645,11 @@ describe('ReactSuspense', () => {
645
646
it('re-fires layout effects when re-showing Suspense', async () => {
647
function TextWithLayout(props) {
652
- Scheduler.unstable_yieldValue(props.text);
648
+ Scheduler.log(props.text);
649
React.useLayoutEffect(() => {
654
- Scheduler.unstable_yieldValue('create layout');
650
+ Scheduler.log('create layout');
651
return () => {
656
- Scheduler.unstable_yieldValue('destroy layout');
652
+ Scheduler.log('destroy layout');
653
};
654
}, []);
655
return props.text;
@@ -692,13 +688,13 @@ describe('ReactSuspense', () => {
688
it('a mounted class component can suspend without losing state', async () => {
689
class TextWithLifecycle extends React.Component {
690
componentDidMount() {
695
- Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
691
+ Scheduler.log(`Mount [${this.props.text}]`);
692
}
693
componentDidUpdate() {
698
- Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
694
+ Scheduler.log(`Update [${this.props.text}]`);
695
}
696
componentWillUnmount() {
701
- Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
697
+ Scheduler.log(`Unmount [${this.props.text}]`);
698
}
699
render() {
700
return <Text {...this.props} />;
@@ -709,19 +705,13 @@ describe('ReactSuspense', () => {
705
class AsyncTextWithLifecycle extends React.Component {
706
state = {step: 1};
707
componentDidMount() {
712
- Scheduler.unstable_yieldValue(
713
- `Mount [${this.props.text}:${this.state.step}]`,
714
- );
708
+ Scheduler.log(`Mount [${this.props.text}:${this.state.step}]`);
709
}
710
componentDidUpdate() {
717
- Scheduler.unstable_yieldValue(
718
- `Update [${this.props.text}:${this.state.step}]`,
719
- );
711
+ Scheduler.log(`Update [${this.props.text}:${this.state.step}]`);
712
}
713
componentWillUnmount() {
722
- Scheduler.unstable_yieldValue(
723
- `Unmount [${this.props.text}:${this.state.step}]`,
724
- );
714
+ Scheduler.log(`Unmount [${this.props.text}:${this.state.step}]`);
715
}
716
render() {
717
instance = this;
@@ -729,13 +719,13 @@ describe('ReactSuspense', () => {
719
const ms = this.props.ms;
720
try {
721
TextResource.read([text, ms]);
732
- Scheduler.unstable_yieldValue(text);
722
+ Scheduler.log(text);
723
return text;
724
} catch (promise) {
725
if (typeof promise.then === 'function') {
736
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
726
+ Scheduler.log(`Suspend! [${text}]`);
727
} else {
738
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
728
+ Scheduler.log(`Error! [${text}]`);
729
}
730
throw promise;
731
}
@@ -896,20 +886,20 @@ describe('ReactSuspense', () => {
886
it('suspends in a class that has componentWillUnmount and is then deleted', () => {
887
class AsyncTextWithUnmount extends React.Component {
888
componentWillUnmount() {
899
- Scheduler.unstable_yieldValue('will unmount');
889
+ Scheduler.log('will unmount');
890
}
891
render() {
892
const text = this.props.text;
893
const ms = this.props.ms;
894
try {
895
TextResource.read([text, ms]);
906
- Scheduler.unstable_yieldValue(text);
896
+ Scheduler.log(text);
897
return text;
898
} catch (promise) {
899
if (typeof promise.then === 'function') {
910
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
900
+ Scheduler.log(`Suspend! [${text}]`);
901
} else {
912
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
902
+ Scheduler.log(`Error! [${text}]`);
903
}
904
throw promise;
905
}
@@ -939,18 +929,18 @@ describe('ReactSuspense', () => {
929
const text = props.text;
930
931
useLayoutEffect(() => {
942
- Scheduler.unstable_yieldValue('Did commit: ' + text);
932
+ Scheduler.log('Did commit: ' + text);
933
}, [text]);
934
935
try {
936
TextResource.read([props.text, props.ms]);
947
- Scheduler.unstable_yieldValue(text);
937
+ Scheduler.log(text);
938
return text;
939
} catch (promise) {
940
if (typeof promise.then === 'function') {
951
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
941
+ Scheduler.log(`Suspend! [${text}]`);
942
} else {
953
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
943
+ Scheduler.log(`Error! [${text}]`);
944
}
945
throw promise;
946
}
@@ -1158,13 +1148,13 @@ describe('ReactSuspense', () => {
1148
const fullText = `${text}:${step}`;
1149
try {
1150
TextResource.read([fullText, ms]);
1161
- Scheduler.unstable_yieldValue(fullText);
1151
+ Scheduler.log(fullText);
1152
return fullText;
1153
} catch (promise) {
1154
if (typeof promise.then === 'function') {
1165
- Scheduler.unstable_yieldValue(`Suspend! [${fullText}]`);
1155
+ Scheduler.log(`Suspend! [${fullText}]`);
1156
} else {
1167
- Scheduler.unstable_yieldValue(`Error! [${fullText}]`);
1157
+ Scheduler.log(`Error! [${fullText}]`);
1158
}
1159
throw promise;
1160
}
@@ -1290,13 +1280,13 @@ describe('ReactSuspense', () => {
1280
const text = useContext(ValueContext);
1281
try {
1282
TextResource.read([text, 1000]);
1293
- Scheduler.unstable_yieldValue(text);
1283
+ Scheduler.log(text);
1284
return text;
1285
} catch (promise) {
1286
if (typeof promise.then === 'function') {
1297
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1287
+ Scheduler.log(`Suspend! [${text}]`);
1288
} else {
1299
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
1289
+ Scheduler.log(`Error! [${text}]`);
1290
}
1291
throw promise;
1292
}
@@ -1343,13 +1333,13 @@ describe('ReactSuspense', () => {
1333
const text = useContext(ValueContext);
1334
try {
1335
TextResource.read([text, 1000]);
1346
- Scheduler.unstable_yieldValue(text);
1336
+ Scheduler.log(text);
1337
return text;
1338
} catch (promise) {
1339
if (typeof promise.then === 'function') {
1350
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1340
+ Scheduler.log(`Suspend! [${text}]`);
1341
} else {
1352
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
1342
+ Scheduler.log(`Error! [${text}]`);
1343
}
1344
throw promise;
1345
}
@@ -1399,13 +1389,13 @@ describe('ReactSuspense', () => {
1389
const text = useContext(ValueContext);
1390
try {
1391
TextResource.read([text, 1000]);
1402
- Scheduler.unstable_yieldValue(text);
1392
+ Scheduler.log(text);
1393
return text;
1394
} catch (promise) {
1395
if (typeof promise.then === 'function') {
1406
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1396
+ Scheduler.log(`Suspend! [${text}]`);
1397
} else {
1408
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
1398
+ Scheduler.log(`Error! [${text}]`);
1399
}
1400
throw promise;
1401
}
@@ -1455,13 +1445,13 @@ describe('ReactSuspense', () => {
1445
const text = useContext(ValueContext);
1446
try {
1447
TextResource.read([text, 1000]);
1458
- Scheduler.unstable_yieldValue(text);
1448
+ Scheduler.log(text);
1449
return text;
1450
} catch (promise) {
1451
if (typeof promise.then === 'function') {
1462
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1452
+ Scheduler.log(`Suspend! [${text}]`);
1453
} else {
1464
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
1454
+ Scheduler.log(`Error! [${text}]`);
1455
}
1456
throw promise;
1457
}
@@ -1508,9 +1498,7 @@ describe('ReactSuspense', () => {
1498
return (
1499
<ValueContext.Consumer>
1500
{value => {
1511
- Scheduler.unstable_yieldValue(
1512
- `Received context value [${value}]`,
1513
- );
1501
+ Scheduler.log(`Received context value [${value}]`);
1502
if (value === 'default') return <Text text="default" />;
1503
throw promiseThatNeverResolves;
1504
}}
packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js
+120
-154
@@ -47,10 +47,10 @@ describe('ReactSuspenseEffectsSemantics', () => {
47
}
48
render() {
49
if (this.state.error) {
50
- Scheduler.unstable_yieldValue('ErrorBoundary render: catch');
50
+ Scheduler.log('ErrorBoundary render: catch');
51
return this.props.fallback;
52
}
53
- Scheduler.unstable_yieldValue('ErrorBoundary render: try');
53
+ Scheduler.log('ErrorBoundary render: try');
54
return this.props.children;
55
}
56
};
@@ -112,16 +112,16 @@ describe('ReactSuspenseEffectsSemantics', () => {
112
if (record !== undefined) {
113
switch (record.status) {
114
case 'pending':
115
- Scheduler.unstable_yieldValue(`Suspend:${text}`);
115
+ Scheduler.log(`Suspend:${text}`);
116
throw record.value;
117
case 'rejected':
118
- Scheduler.unstable_yieldValue(`Error:${text}`);
118
+ Scheduler.log(`Error:${text}`);
119
throw record.value;
120
case 'resolved':
121
return textCache.version;
122
}
123
} else {
124
- Scheduler.unstable_yieldValue(`Suspend:${text}`);
124
+ Scheduler.log(`Suspend:${text}`);
125
126
const thenable = {
127
pings: [],
@@ -145,17 +145,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
145
}
146
147
function Text({children = null, text}) {
148
- Scheduler.unstable_yieldValue(`Text:${text} render`);
148
+ Scheduler.log(`Text:${text} render`);
149
React.useLayoutEffect(() => {
150
- Scheduler.unstable_yieldValue(`Text:${text} create layout`);
150
+ Scheduler.log(`Text:${text} create layout`);
151
return () => {
152
- Scheduler.unstable_yieldValue(`Text:${text} destroy layout`);
152
+ Scheduler.log(`Text:${text} destroy layout`);
153
};
154
}, []);
155
React.useEffect(() => {
156
- Scheduler.unstable_yieldValue(`Text:${text} create passive`);
156
+ Scheduler.log(`Text:${text} create passive`);
157
return () => {
158
- Scheduler.unstable_yieldValue(`Text:${text} destroy passive`);
158
+ Scheduler.log(`Text:${text} destroy passive`);
159
};
160
}, []);
161
return <span prop={text}>{children}</span>;
@@ -163,17 +163,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
163
164
function AsyncText({children = null, text}) {
165
readText(text);
166
- Scheduler.unstable_yieldValue(`AsyncText:${text} render`);
166
+ Scheduler.log(`AsyncText:${text} render`);
167
React.useLayoutEffect(() => {
168
- Scheduler.unstable_yieldValue(`AsyncText:${text} create layout`);
168
+ Scheduler.log(`AsyncText:${text} create layout`);
169
return () => {
170
- Scheduler.unstable_yieldValue(`AsyncText:${text} destroy layout`);
170
+ Scheduler.log(`AsyncText:${text} destroy layout`);
171
};
172
}, []);
173
React.useEffect(() => {
174
- Scheduler.unstable_yieldValue(`AsyncText:${text} create passive`);
174
+ Scheduler.log(`AsyncText:${text} create passive`);
175
return () => {
176
- Scheduler.unstable_yieldValue(`AsyncText:${text} destroy passive`);
176
+ Scheduler.log(`AsyncText:${text} destroy passive`);
177
};
178
}, []);
179
return <span prop={text}>{children}</span>;
@@ -209,37 +209,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
209
class ClassText extends React.Component {
210
componentDidMount() {
211
const {text} = this.props;
212
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
212
+ Scheduler.log(`ClassText:${text} componentDidMount`);
213
}
214
componentDidUpdate() {
215
const {text} = this.props;
216
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
216
+ Scheduler.log(`ClassText:${text} componentDidUpdate`);
217
}
218
componentWillUnmount() {
219
const {text} = this.props;
220
- Scheduler.unstable_yieldValue(
221
- `ClassText:${text} componentWillUnmount`,
222
- );
220
+ Scheduler.log(`ClassText:${text} componentWillUnmount`);
221
}
222
render() {
223
const {children, text} = this.props;
226
- Scheduler.unstable_yieldValue(`ClassText:${text} render`);
224
+ Scheduler.log(`ClassText:${text} render`);
225
return <span prop={text}>{children}</span>;
226
}
227
}
228
229
function App({children = null}) {
232
- Scheduler.unstable_yieldValue('App render');
230
+ Scheduler.log('App render');
231
React.useLayoutEffect(() => {
234
- Scheduler.unstable_yieldValue('App create layout');
232
+ Scheduler.log('App create layout');
233
return () => {
236
- Scheduler.unstable_yieldValue('App destroy layout');
234
+ Scheduler.log('App destroy layout');
235
};
236
}, []);
237
React.useEffect(() => {
240
- Scheduler.unstable_yieldValue('App create passive');
238
+ Scheduler.log('App create passive');
239
return () => {
242
- Scheduler.unstable_yieldValue('App destroy passive');
240
+ Scheduler.log('App destroy passive');
241
};
242
}, []);
243
return (
@@ -330,37 +328,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
328
class ClassText extends React.Component {
329
componentDidMount() {
330
const {text} = this.props;
333
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
331
+ Scheduler.log(`ClassText:${text} componentDidMount`);
332
}
333
componentDidUpdate() {
334
const {text} = this.props;
337
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
335
+ Scheduler.log(`ClassText:${text} componentDidUpdate`);
336
}
337
componentWillUnmount() {
338
const {text} = this.props;
341
- Scheduler.unstable_yieldValue(
342
- `ClassText:${text} componentWillUnmount`,
343
- );
339
+ Scheduler.log(`ClassText:${text} componentWillUnmount`);
340
}
341
render() {
342
const {children, text} = this.props;
347
- Scheduler.unstable_yieldValue(`ClassText:${text} render`);
343
+ Scheduler.log(`ClassText:${text} render`);
344
return <span prop={text}>{children}</span>;
345
}
346
}
347
348
function App({children = null}) {
353
- Scheduler.unstable_yieldValue('App render');
349
+ Scheduler.log('App render');
350
React.useLayoutEffect(() => {
355
- Scheduler.unstable_yieldValue('App create layout');
351
+ Scheduler.log('App create layout');
352
return () => {
357
- Scheduler.unstable_yieldValue('App destroy layout');
353
+ Scheduler.log('App destroy layout');
354
};
355
}, []);
356
React.useEffect(() => {
361
- Scheduler.unstable_yieldValue('App create passive');
357
+ Scheduler.log('App create passive');
358
return () => {
363
- Scheduler.unstable_yieldValue('App destroy passive');
359
+ Scheduler.log('App destroy passive');
360
};
361
}, []);
362
return (
@@ -451,17 +447,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
447
// @gate enableLegacyCache
448
it('should not be destroyed or recreated in legacy roots', async () => {
449
function App({children = null}) {
454
- Scheduler.unstable_yieldValue('App render');
450
+ Scheduler.log('App render');
451
React.useLayoutEffect(() => {
456
- Scheduler.unstable_yieldValue('App create layout');
452
+ Scheduler.log('App create layout');
453
return () => {
458
- Scheduler.unstable_yieldValue('App destroy layout');
454
+ Scheduler.log('App destroy layout');
455
};
456
}, []);
457
React.useEffect(() => {
462
- Scheduler.unstable_yieldValue('App create passive');
458
+ Scheduler.log('App create passive');
459
return () => {
464
- Scheduler.unstable_yieldValue('App destroy passive');
460
+ Scheduler.log('App destroy passive');
461
};
462
}, []);
463
return (
@@ -582,17 +578,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
578
// @gate enableLegacyCache
579
it('should be destroyed and recreated for function components', async () => {
580
function App({children = null}) {
585
- Scheduler.unstable_yieldValue('App render');
581
+ Scheduler.log('App render');
582
React.useLayoutEffect(() => {
587
- Scheduler.unstable_yieldValue('App create layout');
583
+ Scheduler.log('App create layout');
584
return () => {
589
- Scheduler.unstable_yieldValue('App destroy layout');
585
+ Scheduler.log('App destroy layout');
586
};
587
}, []);
588
React.useEffect(() => {
593
- Scheduler.unstable_yieldValue('App create passive');
589
+ Scheduler.log('App create passive');
590
return () => {
595
- Scheduler.unstable_yieldValue('App destroy passive');
591
+ Scheduler.log('App destroy passive');
592
};
593
}, []);
594
return (
@@ -720,37 +716,35 @@ describe('ReactSuspenseEffectsSemantics', () => {
716
class ClassText extends React.Component {
717
componentDidMount() {
718
const {text} = this.props;
723
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
719
+ Scheduler.log(`ClassText:${text} componentDidMount`);
720
}
721
componentDidUpdate() {
722
const {text} = this.props;
727
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
723
+ Scheduler.log(`ClassText:${text} componentDidUpdate`);
724
}
725
componentWillUnmount() {
726
const {text} = this.props;
731
- Scheduler.unstable_yieldValue(
732
- `ClassText:${text} componentWillUnmount`,
733
- );
727
+ Scheduler.log(`ClassText:${text} componentWillUnmount`);
728
}
729
render() {
730
const {children, text} = this.props;
737
- Scheduler.unstable_yieldValue(`ClassText:${text} render`);
731
+ Scheduler.log(`ClassText:${text} render`);
732
return <span prop={text}>{children}</span>;
733
}
734
}
735
736
function App({children = null}) {
743
- Scheduler.unstable_yieldValue('App render');
737
+ Scheduler.log('App render');
738
React.useLayoutEffect(() => {
745
- Scheduler.unstable_yieldValue('App create layout');
739
+ Scheduler.log('App create layout');
740
return () => {
747
- Scheduler.unstable_yieldValue('App destroy layout');
741
+ Scheduler.log('App destroy layout');
742
};
743
}, []);
744
React.useEffect(() => {
751
- Scheduler.unstable_yieldValue('App create passive');
745
+ Scheduler.log('App create passive');
746
return () => {
753
- Scheduler.unstable_yieldValue('App destroy passive');
747
+ Scheduler.log('App destroy passive');
748
};
749
}, []);
750
return (
@@ -869,17 +863,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
863
// @gate enableLegacyCache
864
it('should be destroyed and recreated when nested below host components', async () => {
865
function App({children = null}) {
872
- Scheduler.unstable_yieldValue('App render');
866
+ Scheduler.log('App render');
867
React.useLayoutEffect(() => {
874
- Scheduler.unstable_yieldValue('App create layout');
868
+ Scheduler.log('App create layout');
869
return () => {
876
- Scheduler.unstable_yieldValue('App destroy layout');
870
+ Scheduler.log('App destroy layout');
871
};
872
}, []);
873
React.useEffect(() => {
880
- Scheduler.unstable_yieldValue('App create passive');
874
+ Scheduler.log('App create passive');
875
return () => {
882
- Scheduler.unstable_yieldValue('App destroy passive');
876
+ Scheduler.log('App destroy passive');
877
};
878
}, []);
879
return (
@@ -996,17 +990,17 @@ describe('ReactSuspenseEffectsSemantics', () => {
990
const MemoizedText = React.memo(Text, () => true);
991
992
function App({children = null}) {
999
- Scheduler.unstable_yieldValue('App render');
993
+ Scheduler.log('App render');
994
React.useLayoutEffect(() => {
1001
- Scheduler.unstable_yieldValue('App create layout');
995
+ Scheduler.log('App create layout');
996
return () => {
1003
- Scheduler.unstable_yieldValue('App destroy layout');
997
+ Scheduler.log('App destroy layout');
998
};
999
}, []);
1000
React.useEffect(() => {
1007
- Scheduler.unstable_yieldValue('App create passive');
1001
+ Scheduler.log('App create passive');
1002
return () => {
1009
- Scheduler.unstable_yieldValue('App destroy passive');
1003
+ Scheduler.log('App destroy passive');
1004
};
1005
}, []);
1006
return (
@@ -1853,28 +1847,26 @@ describe('ReactSuspenseEffectsSemantics', () => {
1847
1848
class ThrowsInDidMount extends React.Component {
1849
componentWillUnmount() {
1856
- Scheduler.unstable_yieldValue(
1857
- 'ThrowsInDidMount componentWillUnmount',
1858
- );
1850
+ Scheduler.log('ThrowsInDidMount componentWillUnmount');
1851
}
1852
componentDidMount() {
1861
- Scheduler.unstable_yieldValue('ThrowsInDidMount componentDidMount');
1853
+ Scheduler.log('ThrowsInDidMount componentDidMount');
1854
if (componentDidMountShouldThrow) {
1855
throw Error('expected');
1856
}
1857
}
1858
render() {
1867
- Scheduler.unstable_yieldValue('ThrowsInDidMount render');
1859
+ Scheduler.log('ThrowsInDidMount render');
1860
return <span prop="ThrowsInDidMount" />;
1861
}
1862
}
1863
1864
function App({children = null}) {
1873
- Scheduler.unstable_yieldValue('App render');
1865
+ Scheduler.log('App render');
1866
React.useLayoutEffect(() => {
1875
- Scheduler.unstable_yieldValue('App create layout');
1867
+ Scheduler.log('App create layout');
1868
return () => {
1877
- Scheduler.unstable_yieldValue('App destroy layout');
1869
+ Scheduler.log('App destroy layout');
1870
};
1871
}, []);
1872
return (
@@ -1993,28 +1985,24 @@ describe('ReactSuspenseEffectsSemantics', () => {
1985
it('are properly handled for componentWillUnmount', async () => {
1986
class ThrowsInWillUnmount extends React.Component {
1987
componentDidMount() {
1996
- Scheduler.unstable_yieldValue(
1997
- 'ThrowsInWillUnmount componentDidMount',
1998
- );
1988
+ Scheduler.log('ThrowsInWillUnmount componentDidMount');
1989
}
1990
componentWillUnmount() {
2001
- Scheduler.unstable_yieldValue(
2002
- 'ThrowsInWillUnmount componentWillUnmount',
2003
- );
1991
+ Scheduler.log('ThrowsInWillUnmount componentWillUnmount');
1992
throw Error('expected');
1993
}
1994
render() {
2007
- Scheduler.unstable_yieldValue('ThrowsInWillUnmount render');
1995
+ Scheduler.log('ThrowsInWillUnmount render');
1996
return <span prop="ThrowsInWillUnmount" />;
1997
}
1998
}
1999
2000
function App({children = null}) {
2013
- Scheduler.unstable_yieldValue('App render');
2001
+ Scheduler.log('App render');
2002
React.useLayoutEffect(() => {
2015
- Scheduler.unstable_yieldValue('App create layout');
2003
+ Scheduler.log('App create layout');
2004
return () => {
2017
- Scheduler.unstable_yieldValue('App destroy layout');
2005
+ Scheduler.log('App destroy layout');
2006
};
2007
}, []);
2008
return (
@@ -2108,29 +2096,25 @@ describe('ReactSuspenseEffectsSemantics', () => {
2096
let useLayoutEffectShouldThrow = false;
2097
2098
function ThrowsInLayoutEffect() {
2111
- Scheduler.unstable_yieldValue('ThrowsInLayoutEffect render');
2099
+ Scheduler.log('ThrowsInLayoutEffect render');
2100
React.useLayoutEffect(() => {
2113
- Scheduler.unstable_yieldValue(
2114
- 'ThrowsInLayoutEffect useLayoutEffect create',
2115
- );
2101
+ Scheduler.log('ThrowsInLayoutEffect useLayoutEffect create');
2102
if (useLayoutEffectShouldThrow) {
2103
throw Error('expected');
2104
}
2105
return () => {
2120
- Scheduler.unstable_yieldValue(
2121
- 'ThrowsInLayoutEffect useLayoutEffect destroy',
2122
- );
2106
+ Scheduler.log('ThrowsInLayoutEffect useLayoutEffect destroy');
2107
};
2108
}, []);
2109
return <span prop="ThrowsInLayoutEffect" />;
2110
}
2111
2112
function App({children = null}) {
2129
- Scheduler.unstable_yieldValue('App render');
2113
+ Scheduler.log('App render');
2114
React.useLayoutEffect(() => {
2131
- Scheduler.unstable_yieldValue('App create layout');
2115
+ Scheduler.log('App create layout');
2116
return () => {
2133
- Scheduler.unstable_yieldValue('App destroy layout');
2117
+ Scheduler.log('App destroy layout');
2118
};
2119
}, []);
2120
return (
@@ -2249,13 +2233,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
2233
// @gate replayFailedUnitOfWorkWithInvokeGuardedCallback
2234
it('are properly handled for layout effect destruction', async () => {
2235
function ThrowsInLayoutEffectDestroy() {
2252
- Scheduler.unstable_yieldValue('ThrowsInLayoutEffectDestroy render');
2236
+ Scheduler.log('ThrowsInLayoutEffectDestroy render');
2237
React.useLayoutEffect(() => {
2254
- Scheduler.unstable_yieldValue(
2255
- 'ThrowsInLayoutEffectDestroy useLayoutEffect create',
2256
- );
2238
+ Scheduler.log('ThrowsInLayoutEffectDestroy useLayoutEffect create');
2239
return () => {
2258
- Scheduler.unstable_yieldValue(
2240
+ Scheduler.log(
2241
'ThrowsInLayoutEffectDestroy useLayoutEffect destroy',
2242
);
2243
throw Error('expected');
@@ -2265,11 +2247,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
2247
}
2248
2249
function App({children = null}) {
2268
- Scheduler.unstable_yieldValue('App render');
2250
+ Scheduler.log('App render');
2251
React.useLayoutEffect(() => {
2270
- Scheduler.unstable_yieldValue('App create layout');
2252
+ Scheduler.log('App create layout');
2253
return () => {
2272
- Scheduler.unstable_yieldValue('App destroy layout');
2254
+ Scheduler.log('App destroy layout');
2255
};
2256
}, []);
2257
return (
@@ -2363,21 +2345,19 @@ describe('ReactSuspenseEffectsSemantics', () => {
2345
class ClassText extends React.Component {
2346
componentDidMount() {
2347
const {text} = this.props;
2366
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
2348
+ Scheduler.log(`ClassText:${text} componentDidMount`);
2349
}
2350
componentDidUpdate() {
2351
const {text} = this.props;
2370
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
2352
+ Scheduler.log(`ClassText:${text} componentDidUpdate`);
2353
}
2354
componentWillUnmount() {
2355
const {text} = this.props;
2374
- Scheduler.unstable_yieldValue(
2375
- `ClassText:${text} componentWillUnmount`,
2376
- );
2356
+ Scheduler.log(`ClassText:${text} componentWillUnmount`);
2357
}
2358
render() {
2359
const {children, text} = this.props;
2380
- Scheduler.unstable_yieldValue(`ClassText:${text} render`);
2360
+ Scheduler.log(`ClassText:${text} render`);
2361
return <span prop={text}>{children}</span>;
2362
}
2363
}
@@ -2511,21 +2491,19 @@ describe('ReactSuspenseEffectsSemantics', () => {
2491
class ClassText extends React.Component {
2492
componentDidMount() {
2493
const {text} = this.props;
2514
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidMount`);
2494
+ Scheduler.log(`ClassText:${text} componentDidMount`);
2495
}
2496
componentDidUpdate() {
2497
const {text} = this.props;
2518
- Scheduler.unstable_yieldValue(`ClassText:${text} componentDidUpdate`);
2498
+ Scheduler.log(`ClassText:${text} componentDidUpdate`);
2499
}
2500
componentWillUnmount() {
2501
const {text} = this.props;
2522
- Scheduler.unstable_yieldValue(
2523
- `ClassText:${text} componentWillUnmount`,
2524
- );
2502
+ Scheduler.log(`ClassText:${text} componentWillUnmount`);
2503
}
2504
render() {
2505
const {children, text} = this.props;
2528
- Scheduler.unstable_yieldValue(`ClassText:${text} render`);
2506
+ Scheduler.log(`ClassText:${text} render`);
2507
return <span prop={text}>{children}</span>;
2508
}
2509
}
@@ -2533,7 +2511,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
2511
let textToRead = null;
2512
2513
function Suspender() {
2536
- Scheduler.unstable_yieldValue(`Suspender "${textToRead}" render`);
2514
+ Scheduler.log(`Suspender "${textToRead}" render`);
2515
if (textToRead !== null) {
2516
readText(textToRead);
2517
}
@@ -2663,22 +2641,20 @@ describe('ReactSuspenseEffectsSemantics', () => {
2641
2642
const manualRef = React.useMemo(() => ({current: null}), []);
2643
const refCallback = React.useCallback(value => {
2666
- Scheduler.unstable_yieldValue(
2667
- `RefCheckerOuter refCallback value? ${value != null}`,
2668
- );
2644
+ Scheduler.log(`RefCheckerOuter refCallback value? ${value != null}`);
2645
manualRef.current = value;
2646
}, []);
2647
2672
- Scheduler.unstable_yieldValue(`RefCheckerOuter render`);
2648
+ Scheduler.log(`RefCheckerOuter render`);
2649
2650
React.useLayoutEffect(() => {
2675
- Scheduler.unstable_yieldValue(
2651
+ Scheduler.log(
2652
`RefCheckerOuter create layout refObject? ${
2653
refObject.current != null
2654
} refCallback? ${manualRef.current != null}`,
2655
);
2656
return () => {
2681
- Scheduler.unstable_yieldValue(
2657
+ Scheduler.log(
2658
`RefCheckerOuter destroy layout refObject? ${
2659
refObject.current != null
2660
} refCallback? ${manualRef.current != null}`,
@@ -2699,15 +2675,15 @@ describe('ReactSuspenseEffectsSemantics', () => {
2675
}
2676
2677
function RefCheckerInner({forwardedRef, text}) {
2702
- Scheduler.unstable_yieldValue(`RefCheckerInner:${text} render`);
2678
+ Scheduler.log(`RefCheckerInner:${text} render`);
2679
React.useLayoutEffect(() => {
2704
- Scheduler.unstable_yieldValue(
2680
+ Scheduler.log(
2681
`RefCheckerInner:${text} create layout ref? ${
2682
forwardedRef.current != null
2683
}`,
2684
);
2685
return () => {
2710
- Scheduler.unstable_yieldValue(
2686
+ Scheduler.log(
2687
`RefCheckerInner:${text} destroy layout ref? ${
2688
forwardedRef.current != null
2689
}`,
@@ -2721,15 +2697,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
2697
it('should not be cleared within legacy roots', async () => {
2698
class ClassComponent extends React.Component {
2699
render() {
2724
- Scheduler.unstable_yieldValue(
2725
- `ClassComponent:${this.props.prop} render`,
2726
- );
2700
+ Scheduler.log(`ClassComponent:${this.props.prop} render`);
2701
return this.props.children;
2702
}
2703
}
2704
2705
function App({children}) {
2732
- Scheduler.unstable_yieldValue(`App render`);
2706
+ Scheduler.log(`App render`);
2707
return (
2708
<Suspense fallback={<Text text="Fallback" />}>
2709
{children}
@@ -2806,7 +2780,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
2780
// @gate enableLegacyCache
2781
it('should be cleared and reset for host components', async () => {
2782
function App({children}) {
2809
- Scheduler.unstable_yieldValue(`App render`);
2783
+ Scheduler.log(`App render`);
2784
return (
2785
<Suspense fallback={<Text text="Fallback" />}>
2786
{children}
@@ -2909,15 +2883,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
2883
it('should be cleared and reset for class components', async () => {
2884
class ClassComponent extends React.Component {
2885
render() {
2912
- Scheduler.unstable_yieldValue(
2913
- `ClassComponent:${this.props.prop} render`,
2914
- );
2886
+ Scheduler.log(`ClassComponent:${this.props.prop} render`);
2887
return this.props.children;
2888
}
2889
}
2890
2891
function App({children}) {
2920
- Scheduler.unstable_yieldValue(`App render`);
2892
+ Scheduler.log(`App render`);
2893
return (
2894
<Suspense fallback={<Text text="Fallback" />}>
2895
{children}
@@ -3008,7 +2980,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
2980
// @gate enableLegacyCache
2981
it('should be cleared and reset for function components with useImperativeHandle', async () => {
2982
const FunctionComponent = React.forwardRef((props, ref) => {
3011
- Scheduler.unstable_yieldValue('FunctionComponent render');
2983
+ Scheduler.log('FunctionComponent render');
2984
React.useImperativeHandle(
2985
ref,
2986
() => ({
@@ -3021,7 +2993,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
2993
FunctionComponent.displayName = 'FunctionComponent';
2994
2995
function App({children}) {
3024
- Scheduler.unstable_yieldValue(`App render`);
2996
+ Scheduler.log(`App render`);
2997
return (
2998
<Suspense fallback={<Text text="Fallback" />}>
2999
{children}
@@ -3112,13 +3084,13 @@ describe('ReactSuspenseEffectsSemantics', () => {
3084
// @gate enableLegacyCache
3085
it('should not reset for user-managed values', async () => {
3086
function RefChecker({forwardedRef}) {
3115
- Scheduler.unstable_yieldValue(`RefChecker render`);
3087
+ Scheduler.log(`RefChecker render`);
3088
React.useLayoutEffect(() => {
3117
- Scheduler.unstable_yieldValue(
3089
+ Scheduler.log(
3090
`RefChecker create layout ref? ${forwardedRef.current === 'test'}`,
3091
);
3092
return () => {
3121
- Scheduler.unstable_yieldValue(
3093
+ Scheduler.log(
3094
`RefChecker destroy layout ref? ${
3095
forwardedRef.current === 'test'
3096
}`,
@@ -3130,15 +3102,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
3102
3103
function App({children = null}) {
3104
const ref = React.useRef('test');
3133
- Scheduler.unstable_yieldValue(`App render`);
3105
+ Scheduler.log(`App render`);
3106
React.useLayoutEffect(() => {
3135
- Scheduler.unstable_yieldValue(
3136
- `App create layout ref? ${ref.current === 'test'}`,
3137
- );
3107
+ Scheduler.log(`App create layout ref? ${ref.current === 'test'}`);
3108
return () => {
3139
- Scheduler.unstable_yieldValue(
3140
- `App destroy layout ref? ${ref.current === 'test'}`,
3141
- );
3109
+ Scheduler.log(`App destroy layout ref? ${ref.current === 'test'}`);
3110
};
3111
}, []);
3112
return (
@@ -3213,11 +3181,9 @@ describe('ReactSuspenseEffectsSemantics', () => {
3181
let useRefCallbackShouldThrow = false;
3182
3183
function ThrowsInRefCallback() {
3216
- Scheduler.unstable_yieldValue('ThrowsInRefCallback render');
3184
+ Scheduler.log('ThrowsInRefCallback render');
3185
const refCallback = React.useCallback(value => {
3218
- Scheduler.unstable_yieldValue(
3219
- 'ThrowsInRefCallback refCallback ref? ' + !!value,
3220
- );
3186
+ Scheduler.log('ThrowsInRefCallback refCallback ref? ' + !!value);
3187
if (useRefCallbackShouldThrow) {
3188
throw Error('expected');
3189
}
@@ -3226,11 +3192,11 @@ describe('ReactSuspenseEffectsSemantics', () => {
3192
}
3193
3194
function App({children = null}) {
3229
- Scheduler.unstable_yieldValue('App render');
3195
+ Scheduler.log('App render');
3196
React.useLayoutEffect(() => {
3231
- Scheduler.unstable_yieldValue('App create layout');
3197
+ Scheduler.log('App create layout');
3198
return () => {
3233
- Scheduler.unstable_yieldValue('App destroy layout');
3199
+ Scheduler.log('App destroy layout');
3200
};
3201
}, []);
3202
return (
packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemanticsDOM-test.js
+23
-23
@@ -45,7 +45,7 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
45
}
46
47
function Text(props) {
48
- Scheduler.unstable_yieldValue(props.text);
48
+ Scheduler.log(props.text);
49
return props.text;
50
}
51
@@ -105,9 +105,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
105
<span
106
ref={node => {
107
if (node) {
108
- Scheduler.unstable_yieldValue('Ref mount: ' + label);
108
+ Scheduler.log('Ref mount: ' + label);
109
} else {
110
- Scheduler.unstable_yieldValue('Ref unmount: ' + label);
110
+ Scheduler.log('Ref unmount: ' + label);
111
}
112
}}>
113
<Text text={label} />
@@ -120,9 +120,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
120
<span
121
ref={node => {
122
if (node) {
123
- Scheduler.unstable_yieldValue('Ref mount: ' + label);
123
+ Scheduler.log('Ref mount: ' + label);
124
} else {
125
- Scheduler.unstable_yieldValue('Ref unmount: ' + label);
125
+ Scheduler.log('Ref unmount: ' + label);
126
}
127
}}>
128
<Text text={label} />
@@ -168,10 +168,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
168
it('does not call componentWillUnmount twice when hidden child is removed', async () => {
169
class ChildA extends React.Component {
170
componentDidMount() {
171
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
171
+ Scheduler.log('Did mount: ' + this.props.label);
172
}
173
componentWillUnmount() {
174
- Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
174
+ Scheduler.log('Will unmount: ' + this.props.label);
175
}
176
render() {
177
return <Text text={this.props.label} />;
@@ -180,10 +180,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
180
181
class ChildB extends React.Component {
182
componentDidMount() {
183
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
183
+ Scheduler.log('Did mount: ' + this.props.label);
184
}
185
componentWillUnmount() {
186
- Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
186
+ Scheduler.log('Will unmount: ' + this.props.label);
187
}
188
render() {
189
return <Text text={this.props.label} />;
@@ -226,18 +226,18 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
226
it('does not destroy layout effects twice when parent suspense is removed', async () => {
227
function ChildA({label}) {
228
React.useLayoutEffect(() => {
229
- Scheduler.unstable_yieldValue('Did mount: ' + label);
229
+ Scheduler.log('Did mount: ' + label);
230
return () => {
231
- Scheduler.unstable_yieldValue('Will unmount: ' + label);
231
+ Scheduler.log('Will unmount: ' + label);
232
};
233
}, []);
234
return <Text text={label} />;
235
}
236
function ChildB({label}) {
237
React.useLayoutEffect(() => {
238
- Scheduler.unstable_yieldValue('Did mount: ' + label);
238
+ Scheduler.log('Did mount: ' + label);
239
return () => {
240
- Scheduler.unstable_yieldValue('Will unmount: ' + label);
240
+ Scheduler.log('Will unmount: ' + label);
241
};
242
}, []);
243
return <Text text={label} />;
@@ -284,9 +284,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
284
<span
285
ref={node => {
286
if (node) {
287
- Scheduler.unstable_yieldValue('Ref mount: ' + label);
287
+ Scheduler.log('Ref mount: ' + label);
288
} else {
289
- Scheduler.unstable_yieldValue('Ref unmount: ' + label);
289
+ Scheduler.log('Ref unmount: ' + label);
290
}
291
}}>
292
<Text text={label} />
@@ -299,9 +299,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
299
<span
300
ref={node => {
301
if (node) {
302
- Scheduler.unstable_yieldValue('Ref mount: ' + label);
302
+ Scheduler.log('Ref mount: ' + label);
303
} else {
304
- Scheduler.unstable_yieldValue('Ref unmount: ' + label);
304
+ Scheduler.log('Ref unmount: ' + label);
305
}
306
}}>
307
<Text text={label} />
@@ -350,10 +350,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
350
it('does not call componentWillUnmount twice when parent suspense is removed', async () => {
351
class ChildA extends React.Component {
352
componentDidMount() {
353
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
353
+ Scheduler.log('Did mount: ' + this.props.label);
354
}
355
componentWillUnmount() {
356
- Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
356
+ Scheduler.log('Will unmount: ' + this.props.label);
357
}
358
render() {
359
return <Text text={this.props.label} />;
@@ -362,10 +362,10 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
362
363
class ChildB extends React.Component {
364
componentDidMount() {
365
- Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
365
+ Scheduler.log('Did mount: ' + this.props.label);
366
}
367
componentWillUnmount() {
368
- Scheduler.unstable_yieldValue('Will unmount: ' + this.props.label);
368
+ Scheduler.log('Will unmount: ' + this.props.label);
369
}
370
render() {
371
return <Text text={this.props.label} />;
@@ -414,9 +414,9 @@ describe('ReactSuspenseEffectsSemanticsDOM', () => {
414
415
function Child() {
416
React.useLayoutEffect(() => {
417
- Scheduler.unstable_yieldValue('Mount');
417
+ Scheduler.log('Mount');
418
return () => {
419
- Scheduler.unstable_yieldValue('Unmount');
419
+ Scheduler.log('Unmount');
420
};
421
}, []);
422
return <Text text="Child" />;
packages/react-reconciler/src/__tests__/ReactSuspenseFallback-test.js
+5
-5
@@ -87,16 +87,16 @@ describe('ReactSuspenseFallback', () => {
87
if (record !== undefined) {
88
switch (record.status) {
89
case 'pending':
90
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
90
+ Scheduler.log(`Suspend! [${text}]`);
91
throw record.value;
92
case 'rejected':
93
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
93
+ Scheduler.log(`Error! [${text}]`);
94
throw record.value;
95
case 'resolved':
96
return textCache.version;
97
}
98
} else {
99
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
99
+ Scheduler.log(`Suspend! [${text}]`);
100
101
const thenable = {
102
pings: [],
@@ -120,14 +120,14 @@ describe('ReactSuspenseFallback', () => {
120
}
121
122
function Text({text}) {
123
- Scheduler.unstable_yieldValue(text);
123
+ Scheduler.log(text);
124
return <span prop={text} />;
125
}
126
127
function AsyncText({text, showVersion}) {
128
const version = readText(text);
129
const fullText = showVersion ? `${text} [v${version}]` : text;
130
- Scheduler.unstable_yieldValue(fullText);
130
+ Scheduler.log(fullText);
131
return <span prop={fullText} />;
132
}
133
packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js
+6
-6
@@ -57,7 +57,7 @@ describe('ReactSuspenseFuzz', () => {
57
};
58
const timeoutID = setTimeout(() => {
59
pendingTasks.delete(task);
60
- Scheduler.unstable_yieldValue(task.label);
60
+ Scheduler.log(task.label);
61
setStep(i + 1);
62
}, remountAfter);
63
pendingTasks.add(task);
@@ -87,7 +87,7 @@ describe('ReactSuspenseFuzz', () => {
87
};
88
const timeoutID = setTimeout(() => {
89
pendingTasks.delete(task);
90
- Scheduler.unstable_yieldValue(task.label);
90
+ Scheduler.log(task.label);
91
setStep([i + 1, suspendFor]);
92
}, beginAfter);
93
pendingTasks.add(task);
@@ -117,24 +117,24 @@ describe('ReactSuspenseFuzz', () => {
117
setTimeout(() => {
118
cache.set(fullText, fullText);
119
pendingTasks.delete(task);
120
- Scheduler.unstable_yieldValue(task.label);
120
+ Scheduler.log(task.label);
121
resolve();
122
}, delay);
123
},
124
};
125
cache.set(fullText, thenable);
126
- Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
126
+ Scheduler.log(`Suspended! [${fullText}]`);
127
throw thenable;
128
} else if (typeof resolvedText.then === 'function') {
129
const thenable = resolvedText;
130
- Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
130
+ Scheduler.log(`Suspended! [${fullText}]`);
131
throw thenable;
132
}
133
} else {
134
resolvedText = fullText;
135
}
136
137
- Scheduler.unstable_yieldValue(resolvedText);
137
+ Scheduler.log(resolvedText);
138
return resolvedText;
139
}
140
packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js
+8
-8
@@ -30,7 +30,7 @@ describe('ReactSuspenseList', () => {
30
});
31
32
function Text(props) {
33
- Scheduler.unstable_yieldValue(props.text);
33
+ Scheduler.log(props.text);
34
return <span>{props.text}</span>;
35
}
36
@@ -38,7 +38,7 @@ describe('ReactSuspenseList', () => {
38
let resolved = false;
39
const Component = function () {
40
if (!resolved) {
41
- Scheduler.unstable_yieldValue('Suspend! [' + text + ']');
41
+ Scheduler.log('Suspend! [' + text + ']');
42
throw promise;
43
}
44
return <Text text={text} />;
@@ -2607,7 +2607,7 @@ describe('ReactSuspenseList', () => {
2607
function TwoPass({text}) {
2608
const [pass, setPass] = React.useState(0);
2609
React.useLayoutEffect(() => {
2610
- Scheduler.unstable_yieldValue('Mount ' + text);
2610
+ Scheduler.log('Mount ' + text);
2611
setPass(1);
2612
}, []);
2613
return <Text text={pass === 0 ? 'First Pass ' + text : text} />;
@@ -2619,7 +2619,7 @@ describe('ReactSuspenseList', () => {
2619
}
2620
2621
function App() {
2622
- Scheduler.unstable_yieldValue('App');
2622
+ Scheduler.log('App');
2623
return (
2624
<SuspenseList revealOrder="forwards" tail="hidden">
2625
<Suspense fallback={<Text text="Loading A" />}>
@@ -2668,7 +2668,7 @@ describe('ReactSuspenseList', () => {
2668
function TwoPass({text}) {
2669
const [pass, setPass] = React.useState(0);
2670
React.useLayoutEffect(() => {
2671
- Scheduler.unstable_yieldValue('Mount ' + text);
2671
+ Scheduler.log('Mount ' + text);
2672
setPass(1);
2673
}, []);
2674
return <Text text={pass === 0 ? 'First Pass ' + text : text} />;
@@ -2680,7 +2680,7 @@ describe('ReactSuspenseList', () => {
2680
}
2681
2682
function App() {
2683
- Scheduler.unstable_yieldValue('App');
2683
+ Scheduler.log('App');
2684
return (
2685
<SuspenseList revealOrder="forwards">
2686
<Suspense fallback={<Text text="Loading A" />}>
@@ -2747,7 +2747,7 @@ describe('ReactSuspenseList', () => {
2747
const onRender = jest.fn();
2748
2749
const Fallback = () => {
2750
- Scheduler.unstable_yieldValue('Fallback');
2750
+ Scheduler.log('Fallback');
2751
Scheduler.unstable_advanceTime(3);
2752
return <span>Loading...</span>;
2753
};
@@ -2765,7 +2765,7 @@ describe('ReactSuspenseList', () => {
2765
}
2766
2767
function App({addRow, suspendTail}) {
2768
- Scheduler.unstable_yieldValue('App');
2768
+ Scheduler.log('App');
2769
return (
2770
<Profiler id="root" onRender={onRender}>
2771
<SuspenseList revealOrder="forwards">
packages/react-reconciler/src/__tests__/ReactSuspensePlaceholder-test.internal.js
+10
-14
@@ -53,16 +53,12 @@ describe('ReactSuspensePlaceholder', () => {
53
listeners = [{resolve, reject}];
54
setTimeout(() => {
55
if (textResourceShouldFail) {
56
- Scheduler.unstable_yieldValue(
57
- `Promise rejected [${text}]`,
58
- );
56
+ Scheduler.log(`Promise rejected [${text}]`);
57
status = 'rejected';
58
value = new Error('Failed to load: ' + text);
59
listeners.forEach(listener => listener.reject(value));
60
} else {
63
- Scheduler.unstable_yieldValue(
64
- `Promise resolved [${text}]`,
65
- );
61
+ Scheduler.log(`Promise resolved [${text}]`);
62
status = 'resolved';
63
value = text;
64
listeners.forEach(listener => listener.resolve(value));
@@ -92,7 +88,7 @@ describe('ReactSuspensePlaceholder', () => {
88
89
function Text({fakeRenderDuration = 0, text = 'Text'}) {
90
Scheduler.unstable_advanceTime(fakeRenderDuration);
95
- Scheduler.unstable_yieldValue(text);
91
+ Scheduler.log(text);
92
return text;
93
}
94
@@ -100,13 +96,13 @@ describe('ReactSuspensePlaceholder', () => {
96
Scheduler.unstable_advanceTime(fakeRenderDuration);
97
try {
98
TextResource.read([text, ms]);
103
- Scheduler.unstable_yieldValue(text);
99
+ Scheduler.log(text);
100
return text;
101
} catch (promise) {
102
if (typeof promise.then === 'function') {
107
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
103
+ Scheduler.log(`Suspend! [${text}]`);
104
} else {
109
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
105
+ Scheduler.log(`Error! [${text}]`);
106
}
107
throw promise;
108
}
@@ -116,7 +112,7 @@ describe('ReactSuspensePlaceholder', () => {
112
class HiddenText extends React.PureComponent {
113
render() {
114
const text = this.props.text;
119
- Scheduler.unstable_yieldValue(text);
115
+ Scheduler.log(text);
116
return <span hidden={true}>{text}</span>;
117
}
118
}
@@ -281,19 +277,19 @@ describe('ReactSuspensePlaceholder', () => {
277
onRender = jest.fn();
278
279
const Fallback = () => {
284
- Scheduler.unstable_yieldValue('Fallback');
280
+ Scheduler.log('Fallback');
281
Scheduler.unstable_advanceTime(10);
282
return 'Loading...';
283
};
284
285
const Suspending = () => {
290
- Scheduler.unstable_yieldValue('Suspending');
286
+ Scheduler.log('Suspending');
287
Scheduler.unstable_advanceTime(2);
288
return <AsyncText ms={1000} text="Loaded" fakeRenderDuration={1} />;
289
};
290
291
App = ({shouldSuspend, text = 'Text', textRenderDuration = 5}) => {
296
- Scheduler.unstable_yieldValue('App');
292
+ Scheduler.log('App');
293
return (
294
<Profiler id="root" onRender={onRender}>
295
<Suspense fallback={<Fallback />}>
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js
+65
-77
@@ -91,16 +91,16 @@ describe('ReactSuspenseWithNoopRenderer', () => {
91
if (record !== undefined) {
92
switch (record.status) {
93
case 'pending':
94
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
94
+ Scheduler.log(`Suspend! [${text}]`);
95
throw record.value;
96
case 'rejected':
97
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
97
+ Scheduler.log(`Error! [${text}]`);
98
throw record.value;
99
case 'resolved':
100
return textCache.version;
101
}
102
} else {
103
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
103
+ Scheduler.log(`Suspend! [${text}]`);
104
105
const thenable = {
106
pings: [],
@@ -124,14 +124,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
124
}
125
126
function Text({text}) {
127
- Scheduler.unstable_yieldValue(text);
127
+ Scheduler.log(text);
128
return <span prop={text} />;
129
}
130
131
function AsyncText({text, showVersion}) {
132
const version = readText(text);
133
const fullText = showVersion ? `${text} [v${version}]` : text;
134
- Scheduler.unstable_yieldValue(fullText);
134
+ Scheduler.log(fullText);
135
return <span prop={fullText} />;
136
}
137
@@ -194,12 +194,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
194
// @gate enableLegacyCache
195
it('does not restart rendering for initial render', async () => {
196
function Bar(props) {
197
- Scheduler.unstable_yieldValue('Bar');
197
+ Scheduler.log('Bar');
198
return props.children;
199
}
200
201
function Foo() {
202
- Scheduler.unstable_yieldValue('Foo');
202
+ Scheduler.log('Foo');
203
return (
204
<>
205
<Suspense fallback={<Text text="Loading..." />}>
@@ -260,12 +260,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
260
// @gate enableLegacyCache
261
it('suspends rendering and continues later', async () => {
262
function Bar(props) {
263
- Scheduler.unstable_yieldValue('Bar');
263
+ Scheduler.log('Bar');
264
return props.children;
265
}
266
267
function Foo({renderBar}) {
268
- Scheduler.unstable_yieldValue('Foo');
268
+ Scheduler.log('Foo');
269
return (
270
<Suspense fallback={<Text text="Loading..." />}>
271
{renderBar ? (
@@ -1153,10 +1153,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1153
it('flushes all expired updates in a single batch', async () => {
1154
class Foo extends React.Component {
1155
componentDidUpdate() {
1156
- Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
1156
+ Scheduler.log('Commit: ' + this.props.text);
1157
}
1158
componentDidMount() {
1159
- Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
1159
+ Scheduler.log('Commit: ' + this.props.text);
1160
}
1161
render() {
1162
return (
@@ -1292,7 +1292,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1292
1293
// Update.
1294
text.current.setState({step: 2}, () =>
1295
- Scheduler.unstable_yieldValue('Update did commit'),
1295
+ Scheduler.log('Update did commit'),
1296
);
1297
1298
expect(ReactNoop.flushNextYield()).toEqual([
@@ -1328,10 +1328,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1328
it('does not re-render siblings in loose mode', async () => {
1329
class TextWithLifecycle extends React.Component {
1330
componentDidMount() {
1331
- Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1331
+ Scheduler.log(`Mount [${this.props.text}]`);
1332
}
1333
componentDidUpdate() {
1334
- Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1334
+ Scheduler.log(`Update [${this.props.text}]`);
1335
}
1336
render() {
1337
return <Text {...this.props} />;
@@ -1340,10 +1340,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1340
1341
class AsyncTextWithLifecycle extends React.Component {
1342
componentDidMount() {
1343
- Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1343
+ Scheduler.log(`Mount [${this.props.text}]`);
1344
}
1345
componentDidUpdate() {
1346
- Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1346
+ Scheduler.log(`Update [${this.props.text}]`);
1347
}
1348
render() {
1349
return <AsyncText {...this.props} />;
@@ -1361,7 +1361,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1361
}
1362
1363
ReactNoop.renderLegacySyncRoot(<App />, () =>
1364
- Scheduler.unstable_yieldValue('Commit root'),
1364
+ Scheduler.log('Commit root'),
1365
);
1366
assertLog([
1367
'A',
@@ -1405,15 +1405,15 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1405
constructor(props) {
1406
super(props);
1407
const text = props.text;
1408
- Scheduler.unstable_yieldValue('constructor');
1408
+ Scheduler.log('constructor');
1409
readText(text);
1410
this.state = {text};
1411
}
1412
componentDidMount() {
1413
- Scheduler.unstable_yieldValue('componentDidMount');
1413
+ Scheduler.log('componentDidMount');
1414
}
1415
render() {
1416
- Scheduler.unstable_yieldValue(this.state.text);
1416
+ Scheduler.log(this.state.text);
1417
return <span prop={this.state.text} />;
1418
}
1419
}
@@ -1486,7 +1486,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1486
const child = useRef(null);
1487
1488
useLayoutEffect(() => {
1489
- Scheduler.unstable_yieldValue(ReactNoop.getPendingChildrenAsJSX());
1489
+ Scheduler.log(ReactNoop.getPendingChildrenAsJSX());
1490
});
1491
1492
return (
@@ -1530,9 +1530,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1530
const child = useRef(null);
1531
1532
useLayoutEffect(() => {
1533
- Scheduler.unstable_yieldValue(
1534
- 'Child is hidden: ' + child.current.hidden,
1535
- );
1533
+ Scheduler.log('Child is hidden: ' + child.current.hidden);
1534
});
1535
1536
return (
@@ -1622,9 +1620,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1620
}
1621
1622
React.useEffect(() => {
1625
- Scheduler.unstable_yieldValue('Mount');
1623
+ Scheduler.log('Mount');
1624
return () => {
1627
- Scheduler.unstable_yieldValue('Unmount');
1625
+ Scheduler.log('Unmount');
1626
};
1627
}, []);
1628
@@ -1656,13 +1654,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1654
it('does not call lifecycles of a suspended component', async () => {
1655
class TextWithLifecycle extends React.Component {
1656
componentDidMount() {
1659
- Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1657
+ Scheduler.log(`Mount [${this.props.text}]`);
1658
}
1659
componentDidUpdate() {
1662
- Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1660
+ Scheduler.log(`Update [${this.props.text}]`);
1661
}
1662
componentWillUnmount() {
1665
- Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
1663
+ Scheduler.log(`Unmount [${this.props.text}]`);
1664
}
1665
render() {
1666
return <Text {...this.props} />;
@@ -1671,18 +1669,18 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1669
1670
class AsyncTextWithLifecycle extends React.Component {
1671
componentDidMount() {
1674
- Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1672
+ Scheduler.log(`Mount [${this.props.text}]`);
1673
}
1674
componentDidUpdate() {
1677
- Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1675
+ Scheduler.log(`Update [${this.props.text}]`);
1676
}
1677
componentWillUnmount() {
1680
- Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
1678
+ Scheduler.log(`Unmount [${this.props.text}]`);
1679
}
1680
render() {
1681
const text = this.props.text;
1682
readText(text);
1685
- Scheduler.unstable_yieldValue(text);
1683
+ Scheduler.log(text);
1684
return <span prop={text} />;
1685
}
1686
}
@@ -1697,9 +1695,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1695
);
1696
}
1697
1700
- ReactNoop.renderLegacySyncRoot(<App />, () =>
1701
- Scheduler.unstable_yieldValue('Commit root'),
1702
- );
1698
+ ReactNoop.renderLegacySyncRoot(<App />, () => Scheduler.log('Commit root'));
1699
assertLog([
1700
'A',
1701
'Suspend! [B]',
@@ -1726,17 +1722,15 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1722
it('does not call lifecycles of a suspended component (hooks)', async () => {
1723
function TextWithLifecycle(props) {
1724
React.useLayoutEffect(() => {
1729
- Scheduler.unstable_yieldValue(`Layout Effect [${props.text}]`);
1725
+ Scheduler.log(`Layout Effect [${props.text}]`);
1726
return () => {
1731
- Scheduler.unstable_yieldValue(
1732
- `Destroy Layout Effect [${props.text}]`,
1733
- );
1727
+ Scheduler.log(`Destroy Layout Effect [${props.text}]`);
1728
};
1729
}, [props.text]);
1730
React.useEffect(() => {
1737
- Scheduler.unstable_yieldValue(`Effect [${props.text}]`);
1731
+ Scheduler.log(`Effect [${props.text}]`);
1732
return () => {
1739
- Scheduler.unstable_yieldValue(`Destroy Effect [${props.text}]`);
1733
+ Scheduler.log(`Destroy Effect [${props.text}]`);
1734
};
1735
}, [props.text]);
1736
return <Text {...props} />;
@@ -1744,22 +1738,20 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1738
1739
function AsyncTextWithLifecycle(props) {
1740
React.useLayoutEffect(() => {
1747
- Scheduler.unstable_yieldValue(`Layout Effect [${props.text}]`);
1741
+ Scheduler.log(`Layout Effect [${props.text}]`);
1742
return () => {
1749
- Scheduler.unstable_yieldValue(
1750
- `Destroy Layout Effect [${props.text}]`,
1751
- );
1743
+ Scheduler.log(`Destroy Layout Effect [${props.text}]`);
1744
};
1745
}, [props.text]);
1746
React.useEffect(() => {
1755
- Scheduler.unstable_yieldValue(`Effect [${props.text}]`);
1747
+ Scheduler.log(`Effect [${props.text}]`);
1748
return () => {
1757
- Scheduler.unstable_yieldValue(`Destroy Effect [${props.text}]`);
1749
+ Scheduler.log(`Destroy Effect [${props.text}]`);
1750
};
1751
}, [props.text]);
1752
const text = props.text;
1753
readText(text);
1762
- Scheduler.unstable_yieldValue(text);
1754
+ Scheduler.log(text);
1755
return <span prop={text} />;
1756
}
1757
@@ -1774,7 +1766,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1766
}
1767
1768
ReactNoop.renderLegacySyncRoot(<App text="B" />, () =>
1777
- Scheduler.unstable_yieldValue('Commit root'),
1769
+ Scheduler.log('Commit root'),
1770
);
1771
assertLog([
1772
'A',
@@ -1821,7 +1813,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1813
1814
// Update
1815
ReactNoop.renderLegacySyncRoot(<App text="B2" />, () =>
1824
- Scheduler.unstable_yieldValue('Commit root'),
1816
+ Scheduler.log('Commit root'),
1817
);
1818
1819
assertLog([
@@ -1861,7 +1853,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1853
// @gate enableLegacyCache
1854
it('suspends for longer if something took a long (CPU bound) time to render', async () => {
1855
function Foo({renderContent}) {
1864
- Scheduler.unstable_yieldValue('Foo');
1856
+ Scheduler.log('Foo');
1857
return (
1858
<Suspense fallback={<Text text="Loading..." />}>
1859
{renderContent ? <AsyncText text="A" /> : null}
@@ -1917,7 +1909,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1909
// @gate enableLegacyCache
1910
it('does not suspends if a fallback has been shown for a long time', async () => {
1911
function Foo() {
1920
- Scheduler.unstable_yieldValue('Foo');
1912
+ Scheduler.log('Foo');
1913
return (
1914
<Suspense fallback={<Text text="Loading..." />}>
1915
<AsyncText text="A" />
@@ -1978,7 +1970,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1970
// @gate enableLegacyCache
1971
it('does suspend if a fallback has been shown for a short time', async () => {
1972
function Foo() {
1981
- Scheduler.unstable_yieldValue('Foo');
1973
+ Scheduler.log('Foo');
1974
return (
1975
<Suspense fallback={<Text text="Loading..." />}>
1976
<AsyncText text="A" />
@@ -2033,7 +2025,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2025
// @gate enableLegacyCache
2026
it('does not suspend for very long after a higher priority update', async () => {
2027
function Foo({renderContent}) {
2036
- Scheduler.unstable_yieldValue('Foo');
2028
+ Scheduler.log('Foo');
2029
return (
2030
<Suspense fallback={<Text text="Loading..." />}>
2031
{renderContent ? <AsyncText text="A" /> : null}
@@ -2245,7 +2237,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2237
// @gate enableLegacyCache && enableSuspenseAvoidThisFallback
2238
it('shows the parent fallback if the inner fallback should be avoided', async () => {
2239
function Foo({showC}) {
2248
- Scheduler.unstable_yieldValue('Foo');
2240
+ Scheduler.log('Foo');
2241
return (
2242
<Suspense fallback={<Text text="Initial load..." />}>
2243
<Suspense
@@ -2304,7 +2296,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2296
// @gate enableLegacyCache
2297
it('does not show the parent fallback if the inner fallback is not defined', async () => {
2298
function Foo({showC}) {
2307
- Scheduler.unstable_yieldValue('Foo');
2299
+ Scheduler.log('Foo');
2300
return (
2301
<Suspense fallback={<Text text="Initial load..." />}>
2302
<Suspense>
@@ -2369,7 +2361,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2361
// @gate enableLegacyCache
2362
it('favors showing the inner fallback for nested top level avoided fallback', async () => {
2363
function Foo({showB}) {
2372
- Scheduler.unstable_yieldValue('Foo');
2364
+ Scheduler.log('Foo');
2365
return (
2366
<Suspense
2367
unstable_avoidThisFallback={true}
@@ -2401,7 +2393,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2393
// @gate enableLegacyCache && enableSuspenseAvoidThisFallback
2394
it('keeps showing an avoided parent fallback if it is already showing', async () => {
2395
function Foo({showB}) {
2404
- Scheduler.unstable_yieldValue('Foo');
2396
+ Scheduler.log('Foo');
2397
return (
2398
<Suspense fallback={<Text text="Initial load..." />}>
2399
<Suspense
@@ -2443,7 +2435,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2435
// @gate enableLegacyCache
2436
it('keeps showing an undefined fallback if it is already showing', async () => {
2437
function Foo({showB}) {
2446
- Scheduler.unstable_yieldValue('Foo');
2438
+ Scheduler.log('Foo');
2439
return (
2440
<Suspense fallback={<Text text="Initial load..." />}>
2441
<Suspense fallback={undefined}>
@@ -3053,7 +3045,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3045
foo = this;
3046
3047
if (this.state.suspend) {
3056
- Scheduler.unstable_yieldValue('Suspend!');
3048
+ Scheduler.log('Suspend!');
3049
throw thenable;
3050
}
3051
@@ -3091,12 +3083,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3083
// @gate enableLegacyCache && enableLegacyHidden
3084
it('should not render hidden content while suspended on higher pri', async () => {
3085
function Offscreen() {
3094
- Scheduler.unstable_yieldValue('Offscreen');
3086
+ Scheduler.log('Offscreen');
3087
return 'Offscreen';
3088
}
3089
function App({showContent}) {
3090
React.useLayoutEffect(() => {
3099
- Scheduler.unstable_yieldValue('Commit');
3091
+ Scheduler.log('Commit');
3092
});
3093
return (
3094
<>
@@ -3141,12 +3133,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3133
// @gate enableLegacyCache && enableLegacyHidden
3134
it('should be able to unblock higher pri content before suspended hidden', async () => {
3135
function Offscreen() {
3144
- Scheduler.unstable_yieldValue('Offscreen');
3136
+ Scheduler.log('Offscreen');
3137
return 'Offscreen';
3138
}
3139
function App({showContent}) {
3140
React.useLayoutEffect(() => {
3149
- Scheduler.unstable_yieldValue('Commit');
3141
+ Scheduler.log('Commit');
3142
});
3143
return (
3144
<Suspense fallback={<Text text="Loading..." />}>
@@ -3589,11 +3581,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3581
// This will log if the component commits in an inconsistent state
3582
useEffect(() => {
3583
if (text === outerText) {
3592
- Scheduler.unstable_yieldValue('Commit Child');
3584
+ Scheduler.log('Commit Child');
3585
} else {
3594
- Scheduler.unstable_yieldValue(
3595
- 'FIXME: Texts are inconsistent (tearing)',
3596
- );
3586
+ Scheduler.log('FIXME: Texts are inconsistent (tearing)');
3587
}
3588
}, [text, outerText]);
3589
@@ -3725,11 +3715,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3715
// This will log if the component commits in an inconsistent state
3716
useEffect(() => {
3717
if (text === outerText) {
3728
- Scheduler.unstable_yieldValue('Commit Child');
3718
+ Scheduler.log('Commit Child');
3719
} else {
3730
- Scheduler.unstable_yieldValue(
3731
- 'FIXME: Texts are inconsistent (tearing)',
3732
- );
3720
+ Scheduler.log('FIXME: Texts are inconsistent (tearing)');
3721
}
3722
}, [text, outerText]);
3723
@@ -4014,9 +4002,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
4002
4003
function Child() {
4004
useEffect(() => {
4017
- Scheduler.unstable_yieldValue('Mount Child');
4005
+ Scheduler.log('Mount Child');
4006
return () => {
4019
- Scheduler.unstable_yieldValue('Unmount Child');
4007
+ Scheduler.log('Unmount Child');
4008
};
4009
}, []);
4010
return <span prop="Child" />;
@@ -4062,9 +4050,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
4050
4051
function Child() {
4052
useEffect(() => {
4065
- Scheduler.unstable_yieldValue('Mount Child');
4053
+ Scheduler.log('Mount Child');
4054
return () => {
4067
- Scheduler.unstable_yieldValue('Unmount Child');
4055
+ Scheduler.log('Unmount Child');
4056
};
4057
}, []);
4058
return <span prop="Child" />;
packages/react-reconciler/src/__tests__/ReactThenable-test.js
+11
-11
@@ -54,7 +54,7 @@ describe('ReactThenable', () => {
54
// getAsyncText is completely uncached — it performs a new async operation
55
// every time it's called. During a transition, React should be able to
56
// unwrap it anyway.
57
- Scheduler.unstable_yieldValue(`Async text requested [${text}]`);
57
+ Scheduler.log(`Async text requested [${text}]`);
58
return new Promise(resolve => {
59
const requests = pendingTextRequests.get(text);
60
if (requests !== undefined) {
@@ -67,7 +67,7 @@ describe('ReactThenable', () => {
67
}
68
69
function Text({text}) {
70
- Scheduler.unstable_yieldValue(text);
70
+ Scheduler.log(text);
71
return text;
72
}
73
@@ -82,9 +82,9 @@ describe('ReactThenable', () => {
82
if (fulfilled) {
83
return <Text text="Async" />;
84
}
85
- Scheduler.unstable_yieldValue('Suspend!');
85
+ Scheduler.log('Suspend!');
86
throw Promise.resolve().then(() => {
87
- Scheduler.unstable_yieldValue('Resolve in microtask');
87
+ Scheduler.log('Resolve in microtask');
88
fulfilled = true;
89
});
90
}
@@ -121,9 +121,9 @@ describe('ReactThenable', () => {
121
if (fulfilled) {
122
return <Text text="Async" />;
123
}
124
- Scheduler.unstable_yieldValue('Suspend!');
124
+ Scheduler.log('Suspend!');
125
throw Promise.resolve().then(() => {
126
- Scheduler.unstable_yieldValue('Resolve in microtask');
126
+ Scheduler.log('Resolve in microtask');
127
fulfilled = true;
128
});
129
}
@@ -160,7 +160,7 @@ describe('ReactThenable', () => {
160
if (i++ > 50) {
161
throw new Error('Infinite loop detected');
162
}
163
- Scheduler.unstable_yieldValue('Suspend!');
163
+ Scheduler.log('Suspend!');
164
// This thenable should never be thrown because it already fulfilled.
165
// But if it is thrown, React should handle it gracefully.
166
throw thenable;
@@ -381,7 +381,7 @@ describe('ReactThenable', () => {
381
try {
382
use(Promise.resolve('Async'));
383
} catch (e) {
384
- Scheduler.unstable_yieldValue('Suspend! [Async]');
384
+ Scheduler.log('Suspend! [Async]');
385
throw e;
386
}
387
throw new Error('Oops!');
@@ -730,7 +730,7 @@ describe('ReactThenable', () => {
730
const [childShouldSuspend, _setChildShouldSuspend] = useState(false);
731
setChildShouldSuspend = _setChildShouldSuspend;
732
733
- Scheduler.unstable_yieldValue(
733
+ Scheduler.log(
734
`childShouldSuspend: ${childShouldSuspend}, showChild: ${showChild}`,
735
);
736
return showChild ? (
@@ -795,7 +795,7 @@ describe('ReactThenable', () => {
795
// This computes the uppercased version of some text. Pretend it's an
796
// expensive operation that we want to reuse.
797
const uppercaseText = useMemo(() => {
798
- Scheduler.unstable_yieldValue('Compute uppercase: ' + text);
798
+ Scheduler.log('Compute uppercase: ' + text);
799
return text.toUpperCase();
800
}, [text]);
801
@@ -807,7 +807,7 @@ describe('ReactThenable', () => {
807
// is to show that you can suspend in the middle of a sequence of hooks
808
// without breaking anything.
809
const sparklingText = useMemo(() => {
810
- Scheduler.unstable_yieldValue('Add sparkles: ' + exclamatoryText);
810
+ Scheduler.log('Add sparkles: ' + exclamatoryText);
811
return `✨ ${exclamatoryText} ✨`;
812
}, [exclamatoryText]);
813
packages/react-reconciler/src/__tests__/ReactTransition-test.js
+9
-11
@@ -108,16 +108,16 @@ describe('ReactTransition', () => {
108
if (record !== undefined) {
109
switch (record.status) {
110
case 'pending':
111
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
111
+ Scheduler.log(`Suspend! [${text}]`);
112
throw record.value;
113
case 'rejected':
114
- Scheduler.unstable_yieldValue(`Error! [${text}]`);
114
+ Scheduler.log(`Error! [${text}]`);
115
throw record.value;
116
case 'resolved':
117
return textCache.version;
118
}
119
} else {
120
- Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
120
+ Scheduler.log(`Suspend! [${text}]`);
121
122
const thenable = {
123
pings: [],
@@ -141,13 +141,13 @@ describe('ReactTransition', () => {
141
}
142
143
function Text({text}) {
144
- Scheduler.unstable_yieldValue(text);
144
+ Scheduler.log(text);
145
return text;
146
}
147
148
function AsyncText({text}) {
149
readText(text);
150
- Scheduler.unstable_yieldValue(text);
150
+ Scheduler.log(text);
151
return text;
152
}
153
@@ -622,9 +622,7 @@ describe('ReactTransition', () => {
622
function Parent({children}) {
623
const [shouldHideInParent, _setShouldHideInParent] = useState(false);
624
setShouldHideInParent = _setShouldHideInParent;
625
- Scheduler.unstable_yieldValue(
626
- 'shouldHideInParent: ' + shouldHideInParent,
627
- );
625
+ Scheduler.log('shouldHideInParent: ' + shouldHideInParent);
626
if (shouldHideInParent) {
627
return <Text text="(empty)" />;
628
}
@@ -782,7 +780,7 @@ describe('ReactTransition', () => {
780
updateNormalPri = () => setNormalPri(n => n + 1);
781
782
useLayoutEffect(() => {
785
- Scheduler.unstable_yieldValue('Commit');
783
+ Scheduler.log('Commit');
784
});
785
786
return (
@@ -834,7 +832,7 @@ describe('ReactTransition', () => {
832
updateNormalPri = () => setNormalPri(n => n + 1);
833
834
useLayoutEffect(() => {
837
- Scheduler.unstable_yieldValue('Commit');
835
+ Scheduler.log('Commit');
836
});
837
838
return (
@@ -897,7 +895,7 @@ describe('ReactTransition', () => {
895
updateNormalPri = () => setNormalPri(n => n + 1);
896
897
useLayoutEffect(() => {
900
- Scheduler.unstable_yieldValue('Commit');
898
+ Scheduler.log('Commit');
899
});
900
return (
901
<>
packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js
+95
-137
@@ -112,16 +112,16 @@ describe('ReactInteractionTracing', () => {
112
if (record !== undefined) {
113
switch (record.status) {
114
case 'pending':
115
- Scheduler.unstable_yieldValue(`Suspend [${text}]`);
115
+ Scheduler.log(`Suspend [${text}]`);
116
throw record.value;
117
case 'rejected':
118
- Scheduler.unstable_yieldValue(`Error [${text}]`);
118
+ Scheduler.log(`Error [${text}]`);
119
throw record.value;
120
case 'resolved':
121
return record.value;
122
}
123
} else {
124
- Scheduler.unstable_yieldValue(`Suspend [${text}]`);
124
+ Scheduler.log(`Suspend [${text}]`);
125
126
const thenable = {
127
pings: [],
@@ -146,12 +146,12 @@ describe('ReactInteractionTracing', () => {
146
147
function AsyncText({text}) {
148
const fullText = readText(text);
149
- Scheduler.unstable_yieldValue(fullText);
149
+ Scheduler.log(fullText);
150
return fullText;
151
}
152
153
function Text({text}) {
154
- Scheduler.unstable_yieldValue(text);
154
+ Scheduler.log(text);
155
return text;
156
}
157
@@ -183,18 +183,16 @@ describe('ReactInteractionTracing', () => {
183
it(' should not call callbacks when transition is not defined', async () => {
184
const transitionCallbacks = {
185
onTransitionStart: (name, startTime) => {
186
- Scheduler.unstable_yieldValue(
187
- `onTransitionStart(${name}, ${startTime})`,
188
- );
186
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
187
},
188
onTransitionProgress: (name, startTime, endTime, pending) => {
189
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
192
- Scheduler.unstable_yieldValue(
190
+ Scheduler.log(
191
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
192
);
193
},
194
onTransitionComplete: (name, startTime, endTime) => {
197
- Scheduler.unstable_yieldValue(
195
+ Scheduler.log(
196
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
197
);
198
},
@@ -206,12 +204,12 @@ describe('ReactInteractionTracing', () => {
204
pending,
205
) => {
206
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
209
- Scheduler.unstable_yieldValue(
207
+ Scheduler.log(
208
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
209
);
210
},
211
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
214
- Scheduler.unstable_yieldValue(
212
+ Scheduler.log(
213
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
214
);
215
},
@@ -266,18 +264,16 @@ describe('ReactInteractionTracing', () => {
264
it('should correctly trace basic interaction', async () => {
265
const transitionCallbacks = {
266
onTransitionStart: (name, startTime) => {
269
- Scheduler.unstable_yieldValue(
270
- `onTransitionStart(${name}, ${startTime})`,
271
- );
267
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
268
},
269
onTransitionProgress: (name, startTime, endTime, pending) => {
270
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
275
- Scheduler.unstable_yieldValue(
271
+ Scheduler.log(
272
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
273
);
274
},
275
onTransitionComplete: (name, startTime, endTime) => {
280
- Scheduler.unstable_yieldValue(
276
+ Scheduler.log(
277
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
278
);
279
},
@@ -326,12 +322,10 @@ describe('ReactInteractionTracing', () => {
322
it('multiple updates in transition callback should only result in one transitionStart/transitionComplete call', async () => {
323
const transitionCallbacks = {
324
onTransitionStart: (name, startTime) => {
329
- Scheduler.unstable_yieldValue(
330
- `onTransitionStart(${name}, ${startTime})`,
331
- );
325
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
326
},
327
onTransitionComplete: (name, startTime, endTime) => {
334
- Scheduler.unstable_yieldValue(
328
+ Scheduler.log(
329
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
330
);
331
},
@@ -391,18 +385,16 @@ describe('ReactInteractionTracing', () => {
385
it('should correctly trace interactions for async roots', async () => {
386
const transitionCallbacks = {
387
onTransitionStart: (name, startTime) => {
394
- Scheduler.unstable_yieldValue(
395
- `onTransitionStart(${name}, ${startTime})`,
396
- );
388
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
389
},
390
onTransitionProgress: (name, startTime, endTime, pending) => {
391
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
400
- Scheduler.unstable_yieldValue(
392
+ Scheduler.log(
393
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
394
);
395
},
396
onTransitionComplete: (name, startTime, endTime) => {
405
- Scheduler.unstable_yieldValue(
397
+ Scheduler.log(
398
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
399
);
400
},
@@ -469,18 +461,16 @@ describe('ReactInteractionTracing', () => {
461
it('should correctly trace multiple separate root interactions', async () => {
462
const transitionCallbacks = {
463
onTransitionStart: (name, startTime) => {
472
- Scheduler.unstable_yieldValue(
473
- `onTransitionStart(${name}, ${startTime})`,
474
- );
464
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
465
},
466
onTransitionProgress: (name, startTime, endTime, pending) => {
467
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
478
- Scheduler.unstable_yieldValue(
468
+ Scheduler.log(
469
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
470
);
471
},
472
onTransitionComplete: (name, startTime, endTime) => {
483
- Scheduler.unstable_yieldValue(
473
+ Scheduler.log(
474
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
475
);
476
},
@@ -578,18 +568,16 @@ describe('ReactInteractionTracing', () => {
568
it('should correctly trace multiple intertwined root interactions', async () => {
569
const transitionCallbacks = {
570
onTransitionStart: (name, startTime) => {
581
- Scheduler.unstable_yieldValue(
582
- `onTransitionStart(${name}, ${startTime})`,
583
- );
571
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
572
},
573
onTransitionProgress: (name, startTime, endTime, pending) => {
574
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
587
- Scheduler.unstable_yieldValue(
575
+ Scheduler.log(
576
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
577
);
578
},
579
onTransitionComplete: (name, startTime, endTime) => {
592
- Scheduler.unstable_yieldValue(
580
+ Scheduler.log(
581
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
582
);
583
},
@@ -695,18 +683,16 @@ describe('ReactInteractionTracing', () => {
683
it('trace interaction with nested and sibling suspense boundaries', async () => {
684
const transitionCallbacks = {
685
onTransitionStart: (name, startTime) => {
698
- Scheduler.unstable_yieldValue(
699
- `onTransitionStart(${name}, ${startTime})`,
700
- );
686
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
687
},
688
onTransitionProgress: (name, startTime, endTime, pending) => {
689
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
704
- Scheduler.unstable_yieldValue(
690
+ Scheduler.log(
691
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
692
);
693
},
694
onTransitionComplete: (name, startTime, endTime) => {
709
- Scheduler.unstable_yieldValue(
695
+ Scheduler.log(
696
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
697
);
698
},
@@ -813,18 +799,16 @@ describe('ReactInteractionTracing', () => {
799
it('trace interactions with the same child suspense boundaries', async () => {
800
const transitionCallbacks = {
801
onTransitionStart: (name, startTime) => {
816
- Scheduler.unstable_yieldValue(
817
- `onTransitionStart(${name}, ${startTime})`,
818
- );
802
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
803
},
804
onTransitionProgress: (name, startTime, endTime, pending) => {
805
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
822
- Scheduler.unstable_yieldValue(
806
+ Scheduler.log(
807
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
808
);
809
},
810
onTransitionComplete: (name, startTime, endTime) => {
827
- Scheduler.unstable_yieldValue(
811
+ Scheduler.log(
812
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
813
);
814
},
@@ -979,18 +963,16 @@ describe('ReactInteractionTracing', () => {
963
it('should correctly trace basic interaction with tracing markers', async () => {
964
const transitionCallbacks = {
965
onTransitionStart: (name, startTime) => {
982
- Scheduler.unstable_yieldValue(
983
- `onTransitionStart(${name}, ${startTime})`,
984
- );
966
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
967
},
968
onTransitionProgress: (name, startTime, endTime, pending) => {
969
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
988
- Scheduler.unstable_yieldValue(
970
+ Scheduler.log(
971
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
972
);
973
},
974
onTransitionComplete: (name, startTime, endTime) => {
993
- Scheduler.unstable_yieldValue(
975
+ Scheduler.log(
976
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
977
);
978
},
@@ -1002,12 +984,12 @@ describe('ReactInteractionTracing', () => {
984
pending,
985
) => {
986
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1005
- Scheduler.unstable_yieldValue(
987
+ Scheduler.log(
988
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
989
);
990
},
991
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1010
- Scheduler.unstable_yieldValue(
992
+ Scheduler.log(
993
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
994
);
995
},
@@ -1065,12 +1047,10 @@ describe('ReactInteractionTracing', () => {
1047
it('should correctly trace interactions for tracing markers', async () => {
1048
const transitionCallbacks = {
1049
onTransitionStart: (name, startTime) => {
1068
- Scheduler.unstable_yieldValue(
1069
- `onTransitionStart(${name}, ${startTime})`,
1070
- );
1050
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1051
},
1052
onTransitionComplete: (name, startTime, endTime) => {
1073
- Scheduler.unstable_yieldValue(
1053
+ Scheduler.log(
1054
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1055
);
1056
},
@@ -1082,12 +1062,12 @@ describe('ReactInteractionTracing', () => {
1062
pending,
1063
) => {
1064
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1085
- Scheduler.unstable_yieldValue(
1065
+ Scheduler.log(
1066
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1067
);
1068
},
1069
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1090
- Scheduler.unstable_yieldValue(
1070
+ Scheduler.log(
1071
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1072
);
1073
},
@@ -1176,12 +1156,10 @@ describe('ReactInteractionTracing', () => {
1156
it('trace interaction with multiple tracing markers', async () => {
1157
const transitionCallbacks = {
1158
onTransitionStart: (name, startTime) => {
1179
- Scheduler.unstable_yieldValue(
1180
- `onTransitionStart(${name}, ${startTime})`,
1181
- );
1159
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1160
},
1161
onTransitionComplete: (name, startTime, endTime) => {
1184
- Scheduler.unstable_yieldValue(
1162
+ Scheduler.log(
1163
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1164
);
1165
},
@@ -1193,12 +1171,12 @@ describe('ReactInteractionTracing', () => {
1171
pending,
1172
) => {
1173
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1196
- Scheduler.unstable_yieldValue(
1174
+ Scheduler.log(
1175
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1176
);
1177
},
1178
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1201
- Scheduler.unstable_yieldValue(
1179
+ Scheduler.log(
1180
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1181
);
1182
},
@@ -1304,18 +1282,16 @@ describe('ReactInteractionTracing', () => {
1282
it.skip('warn and calls marker incomplete if name changes before transition completes', async () => {
1283
const transitionCallbacks = {
1284
onTransitionStart: (name, startTime) => {
1307
- Scheduler.unstable_yieldValue(
1308
- `onTransitionStart(${name}, ${startTime})`,
1309
- );
1285
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1286
},
1287
onTransitionProgress: (name, startTime, endTime, pending) => {
1288
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1313
- Scheduler.unstable_yieldValue(
1289
+ Scheduler.log(
1290
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1291
);
1292
},
1293
onTransitionComplete: (name, startTime, endTime) => {
1318
- Scheduler.unstable_yieldValue(
1294
+ Scheduler.log(
1295
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1296
);
1297
},
@@ -1327,7 +1303,7 @@ describe('ReactInteractionTracing', () => {
1303
pending,
1304
) => {
1305
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1330
- Scheduler.unstable_yieldValue(
1306
+ Scheduler.log(
1307
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1308
);
1309
},
@@ -1337,14 +1313,14 @@ describe('ReactInteractionTracing', () => {
1313
startTime,
1314
deletions,
1315
) => {
1340
- Scheduler.unstable_yieldValue(
1316
+ Scheduler.log(
1317
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1318
deletions,
1319
)}])`,
1320
);
1321
},
1322
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1347
- Scheduler.unstable_yieldValue(
1323
+ Scheduler.log(
1324
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1325
);
1326
},
@@ -1420,18 +1396,16 @@ describe('ReactInteractionTracing', () => {
1396
it('marker incomplete for tree with parent and sibling tracing markers', async () => {
1397
const transitionCallbacks = {
1398
onTransitionStart: (name, startTime) => {
1423
- Scheduler.unstable_yieldValue(
1424
- `onTransitionStart(${name}, ${startTime})`,
1425
- );
1399
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1400
},
1401
onTransitionProgress: (name, startTime, endTime, pending) => {
1402
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1429
- Scheduler.unstable_yieldValue(
1403
+ Scheduler.log(
1404
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1405
);
1406
},
1407
onTransitionComplete: (name, startTime, endTime) => {
1434
- Scheduler.unstable_yieldValue(
1408
+ Scheduler.log(
1409
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1410
);
1411
},
@@ -1443,7 +1417,7 @@ describe('ReactInteractionTracing', () => {
1417
pending,
1418
) => {
1419
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1446
- Scheduler.unstable_yieldValue(
1420
+ Scheduler.log(
1421
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1422
);
1423
},
@@ -1453,14 +1427,14 @@ describe('ReactInteractionTracing', () => {
1427
startTime,
1428
deletions,
1429
) => {
1456
- Scheduler.unstable_yieldValue(
1430
+ Scheduler.log(
1431
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1432
deletions,
1433
)}])`,
1434
);
1435
},
1436
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1463
- Scheduler.unstable_yieldValue(
1437
+ Scheduler.log(
1438
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1439
);
1440
},
@@ -1576,18 +1550,16 @@ describe('ReactInteractionTracing', () => {
1550
it('marker gets deleted', async () => {
1551
const transitionCallbacks = {
1552
onTransitionStart: (name, startTime) => {
1579
- Scheduler.unstable_yieldValue(
1580
- `onTransitionStart(${name}, ${startTime})`,
1581
- );
1553
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1554
},
1555
onTransitionProgress: (name, startTime, endTime, pending) => {
1556
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1585
- Scheduler.unstable_yieldValue(
1557
+ Scheduler.log(
1558
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1559
);
1560
},
1561
onTransitionComplete: (name, startTime, endTime) => {
1590
- Scheduler.unstable_yieldValue(
1562
+ Scheduler.log(
1563
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1564
);
1565
},
@@ -1599,7 +1571,7 @@ describe('ReactInteractionTracing', () => {
1571
pending,
1572
) => {
1573
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1602
- Scheduler.unstable_yieldValue(
1574
+ Scheduler.log(
1575
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1576
);
1577
},
@@ -1609,14 +1581,14 @@ describe('ReactInteractionTracing', () => {
1581
startTime,
1582
deletions,
1583
) => {
1612
- Scheduler.unstable_yieldValue(
1584
+ Scheduler.log(
1585
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1586
deletions,
1587
)}])`,
1588
);
1589
},
1590
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1619
- Scheduler.unstable_yieldValue(
1591
+ Scheduler.log(
1592
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1593
);
1594
},
@@ -1711,18 +1683,16 @@ describe('ReactInteractionTracing', () => {
1683
it('Suspense boundary added by the transition is deleted', async () => {
1684
const transitionCallbacks = {
1685
onTransitionStart: (name, startTime) => {
1714
- Scheduler.unstable_yieldValue(
1715
- `onTransitionStart(${name}, ${startTime})`,
1716
- );
1686
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1687
},
1688
onTransitionProgress: (name, startTime, endTime, pending) => {
1689
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1720
- Scheduler.unstable_yieldValue(
1690
+ Scheduler.log(
1691
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1692
);
1693
},
1694
onTransitionComplete: (name, startTime, endTime) => {
1725
- Scheduler.unstable_yieldValue(
1695
+ Scheduler.log(
1696
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1697
);
1698
},
@@ -1734,7 +1704,7 @@ describe('ReactInteractionTracing', () => {
1704
pending,
1705
) => {
1706
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1737
- Scheduler.unstable_yieldValue(
1707
+ Scheduler.log(
1708
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1709
);
1710
},
@@ -1744,14 +1714,14 @@ describe('ReactInteractionTracing', () => {
1714
startTime,
1715
deletions,
1716
) => {
1747
- Scheduler.unstable_yieldValue(
1717
+ Scheduler.log(
1718
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1719
deletions,
1720
)}])`,
1721
);
1722
},
1723
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1754
- Scheduler.unstable_yieldValue(
1724
+ Scheduler.log(
1725
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1726
);
1727
},
@@ -1869,18 +1839,16 @@ describe('ReactInteractionTracing', () => {
1839
it('Suspense boundary not added by the transition is deleted ', async () => {
1840
const transitionCallbacks = {
1841
onTransitionStart: (name, startTime) => {
1872
- Scheduler.unstable_yieldValue(
1873
- `onTransitionStart(${name}, ${startTime})`,
1874
- );
1842
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1843
},
1844
onTransitionProgress: (name, startTime, endTime, pending) => {
1845
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1878
- Scheduler.unstable_yieldValue(
1846
+ Scheduler.log(
1847
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1848
);
1849
},
1850
onTransitionComplete: (name, startTime, endTime) => {
1883
- Scheduler.unstable_yieldValue(
1851
+ Scheduler.log(
1852
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1853
);
1854
},
@@ -1892,7 +1860,7 @@ describe('ReactInteractionTracing', () => {
1860
pending,
1861
) => {
1862
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1895
- Scheduler.unstable_yieldValue(
1863
+ Scheduler.log(
1864
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1865
);
1866
},
@@ -1902,14 +1870,14 @@ describe('ReactInteractionTracing', () => {
1870
startTime,
1871
deletions,
1872
) => {
1905
- Scheduler.unstable_yieldValue(
1873
+ Scheduler.log(
1874
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1875
deletions,
1876
)}])`,
1877
);
1878
},
1879
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
1912
- Scheduler.unstable_yieldValue(
1880
+ Scheduler.log(
1881
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1882
);
1883
},
@@ -1979,18 +1947,16 @@ describe('ReactInteractionTracing', () => {
1947
it('marker incomplete gets called properly if child suspense marker is not part of it', async () => {
1948
const transitionCallbacks = {
1949
onTransitionStart: (name, startTime) => {
1982
- Scheduler.unstable_yieldValue(
1983
- `onTransitionStart(${name}, ${startTime})`,
1984
- );
1950
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
1951
},
1952
onTransitionProgress: (name, startTime, endTime, pending) => {
1953
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
1988
- Scheduler.unstable_yieldValue(
1954
+ Scheduler.log(
1955
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
1956
);
1957
},
1958
onTransitionComplete: (name, startTime, endTime) => {
1993
- Scheduler.unstable_yieldValue(
1959
+ Scheduler.log(
1960
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
1961
);
1962
},
@@ -2002,7 +1968,7 @@ describe('ReactInteractionTracing', () => {
1968
pending,
1969
) => {
1970
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
2005
- Scheduler.unstable_yieldValue(
1971
+ Scheduler.log(
1972
`onMarkerProgress(${transitioName}, ${markerName}, ${startTime}, ${currentTime}, [${suspenseNames}])`,
1973
);
1974
},
@@ -2012,14 +1978,14 @@ describe('ReactInteractionTracing', () => {
1978
startTime,
1979
deletions,
1980
) => {
2015
- Scheduler.unstable_yieldValue(
1981
+ Scheduler.log(
1982
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
1983
deletions,
1984
)}])`,
1985
);
1986
},
1987
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
2022
- Scheduler.unstable_yieldValue(
1988
+ Scheduler.log(
1989
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
1990
);
1991
},
@@ -2118,12 +2084,10 @@ describe('ReactInteractionTracing', () => {
2084
it('warns when marker name changes', async () => {
2085
const transitionCallbacks = {
2086
onTransitionStart: (name, startTime) => {
2121
- Scheduler.unstable_yieldValue(
2122
- `onTransitionStart(${name}, ${startTime})`,
2123
- );
2087
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
2088
},
2089
onTransitionComplete: (name, startTime, endTime) => {
2126
- Scheduler.unstable_yieldValue(
2090
+ Scheduler.log(
2091
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
2092
);
2093
},
@@ -2133,14 +2097,14 @@ describe('ReactInteractionTracing', () => {
2097
startTime,
2098
deletions,
2099
) => {
2136
- Scheduler.unstable_yieldValue(
2100
+ Scheduler.log(
2101
`onMarkerIncomplete(${transitionName}, ${markerName}, ${startTime}, [${stringifyDeletions(
2102
deletions,
2103
)}])`,
2104
);
2105
},
2106
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
2143
- Scheduler.unstable_yieldValue(
2107
+ Scheduler.log(
2108
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
2109
);
2110
},
@@ -2212,17 +2176,15 @@ describe('ReactInteractionTracing', () => {
2176
it('offscreen trees should not stop transition from completing', async () => {
2177
const transitionCallbacks = {
2178
onTransitionStart: (name, startTime) => {
2215
- Scheduler.unstable_yieldValue(
2216
- `onTransitionStart(${name}, ${startTime})`,
2217
- );
2179
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
2180
},
2181
onTransitionComplete: (name, startTime, endTime) => {
2220
- Scheduler.unstable_yieldValue(
2182
+ Scheduler.log(
2183
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
2184
);
2185
},
2186
onMarkerComplete: (transitioName, markerName, startTime, endTime) => {
2225
- Scheduler.unstable_yieldValue(
2187
+ Scheduler.log(
2188
`onMarkerComplete(${transitioName}, ${markerName}, ${startTime}, ${endTime})`,
2189
);
2190
},
@@ -2282,18 +2244,16 @@ describe('ReactInteractionTracing', () => {
2244
it('discrete events', async () => {
2245
const transitionCallbacks = {
2246
onTransitionStart: (name, startTime) => {
2285
- Scheduler.unstable_yieldValue(
2286
- `onTransitionStart(${name}, ${startTime})`,
2287
- );
2247
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
2248
},
2249
onTransitionProgress: (name, startTime, endTime, pending) => {
2250
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
2291
- Scheduler.unstable_yieldValue(
2251
+ Scheduler.log(
2252
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
2253
);
2254
},
2255
onTransitionComplete: (name, startTime, endTime) => {
2296
- Scheduler.unstable_yieldValue(
2256
+ Scheduler.log(
2257
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
2258
);
2259
},
@@ -2344,18 +2304,16 @@ describe('ReactInteractionTracing', () => {
2304
it('multiple commits happen before a paint', async () => {
2305
const transitionCallbacks = {
2306
onTransitionStart: (name, startTime) => {
2347
- Scheduler.unstable_yieldValue(
2348
- `onTransitionStart(${name}, ${startTime})`,
2349
- );
2307
+ Scheduler.log(`onTransitionStart(${name}, ${startTime})`);
2308
},
2309
onTransitionProgress: (name, startTime, endTime, pending) => {
2310
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
2353
- Scheduler.unstable_yieldValue(
2311
+ Scheduler.log(
2312
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
2313
);
2314
},
2315
onTransitionComplete: (name, startTime, endTime) => {
2358
- Scheduler.unstable_yieldValue(
2316
+ Scheduler.log(
2317
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
2318
);
2319
},
@@ -2420,18 +2378,18 @@ describe('ReactInteractionTracing', () => {
2378
const getTransitionCallbacks = transitionName => {
2379
return {
2380
onTransitionStart: (name, startTime) => {
2423
- Scheduler.unstable_yieldValue(
2381
+ Scheduler.log(
2382
`onTransitionStart(${name}, ${startTime}) /${transitionName}/`,
2383
);
2384
},
2385
onTransitionProgress: (name, startTime, endTime, pending) => {
2386
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
2429
- Scheduler.unstable_yieldValue(
2387
+ Scheduler.log(
2388
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}]) /${transitionName}/`,
2389
);
2390
},
2391
onTransitionComplete: (name, startTime, endTime) => {
2434
- Scheduler.unstable_yieldValue(
2392
+ Scheduler.log(
2393
`onTransitionComplete(${name}, ${startTime}, ${endTime}) /${transitionName}/`,
2394
);
2395
},
packages/react-reconciler/src/__tests__/ReactUpdatePriority-test.js
+2
-2
@@ -31,7 +31,7 @@ describe('ReactUpdatePriority', () => {
31
});
32
33
function Text({text}) {
34
- Scheduler.unstable_yieldValue(text);
34
+ Scheduler.log(text);
35
return text;
36
}
37
@@ -65,7 +65,7 @@ describe('ReactUpdatePriority', () => {
65
const [defaultState, _setDefaultState] = useState(1);
66
setDefaultState = _setDefaultState;
67
useEffect(() => {
68
- Scheduler.unstable_yieldValue('Idle update');
68
+ Scheduler.log('Idle update');
69
setIdleState(2);
70
}, []);
71
return <Text text={`Idle: ${idleState}, Default: ${defaultState}`} />;
packages/react-reconciler/src/__tests__/ReactUpdaters-test.internal.js
+6
-6
@@ -41,7 +41,7 @@ describe('updaters', () => {
41
isDevToolsPresent: true,
42
onCommitRoot: jest.fn(fiberRoot => {
43
if (onCommitRootShouldYield) {
44
- Scheduler.unstable_yieldValue('onCommitRoot');
44
+ Scheduler.log('onCommitRoot');
45
}
46
const schedulerTags = [];
47
const schedulerTypes = [];
@@ -199,7 +199,7 @@ describe('updaters', () => {
199
};
200
const CascadingChild = ({cascade}) => {
201
const [count, setCount] = React.useState(0);
202
- Scheduler.unstable_yieldValue(`CascadingChild ${count}`);
202
+ Scheduler.log(`CascadingChild ${count}`);
203
React.useLayoutEffect(() => {
204
if (cascade === 'active') {
205
setCount(prevCount => prevCount + 1);
@@ -348,7 +348,7 @@ describe('updaters', () => {
348
}
349
}
350
const Yield = ({value}) => {
351
- Scheduler.unstable_yieldValue(value);
351
+ Scheduler.log(value);
352
return null;
353
};
354
const BrokenRender = () => {
@@ -387,7 +387,7 @@ describe('updaters', () => {
387
const SyncPriorityUpdater = () => {
388
const [count, setCount] = React.useState(0);
389
triggerSyncPriorityUpdate = () => setCount(prevCount => prevCount + 1);
390
- Scheduler.unstable_yieldValue(`SyncPriorityUpdater ${count}`);
390
+ Scheduler.log(`SyncPriorityUpdater ${count}`);
391
return <Yield value={`HighPriority ${count}`} />;
392
};
393
const LowPriorityUpdater = () => {
@@ -397,11 +397,11 @@ describe('updaters', () => {
397
setCount(prevCount => prevCount + 1);
398
});
399
};
400
- Scheduler.unstable_yieldValue(`LowPriorityUpdater ${count}`);
400
+ Scheduler.log(`LowPriorityUpdater ${count}`);
401
return <Yield value={`LowPriority ${count}`} />;
402
};
403
const Yield = ({value}) => {
404
- Scheduler.unstable_yieldValue(`Yield ${value}`);
404
+ Scheduler.log(`Yield ${value}`);
405
return null;
406
};
407
packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js
+46
-50
@@ -39,13 +39,13 @@ describe('StrictEffectsMode', () => {
39
it('should not double invoke effects in legacy mode', () => {
40
function App({text}) {
41
React.useEffect(() => {
42
- Scheduler.unstable_yieldValue('useEffect mount');
43
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
42
+ Scheduler.log('useEffect mount');
43
+ return () => Scheduler.log('useEffect unmount');
44
});
45
46
React.useLayoutEffect(() => {
47
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
48
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
47
+ Scheduler.log('useLayoutEffect mount');
48
+ return () => Scheduler.log('useLayoutEffect unmount');
49
});
50
51
return text;
@@ -61,13 +61,13 @@ describe('StrictEffectsMode', () => {
61
it('double invoking for effects works properly', () => {
62
function App({text}) {
63
React.useEffect(() => {
64
- Scheduler.unstable_yieldValue('useEffect mount');
65
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
64
+ Scheduler.log('useEffect mount');
65
+ return () => Scheduler.log('useEffect unmount');
66
});
67
68
React.useLayoutEffect(() => {
69
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
70
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
69
+ Scheduler.log('useLayoutEffect mount');
70
+ return () => Scheduler.log('useLayoutEffect unmount');
71
});
72
73
return text;
@@ -114,13 +114,13 @@ describe('StrictEffectsMode', () => {
114
it('multiple effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
115
function App({text}) {
116
React.useEffect(() => {
117
- Scheduler.unstable_yieldValue('useEffect One mount');
118
- return () => Scheduler.unstable_yieldValue('useEffect One unmount');
117
+ Scheduler.log('useEffect One mount');
118
+ return () => Scheduler.log('useEffect One unmount');
119
});
120
121
React.useEffect(() => {
122
- Scheduler.unstable_yieldValue('useEffect Two mount');
123
- return () => Scheduler.unstable_yieldValue('useEffect Two unmount');
122
+ Scheduler.log('useEffect Two mount');
123
+ return () => Scheduler.log('useEffect Two unmount');
124
});
125
126
return text;
@@ -167,15 +167,13 @@ describe('StrictEffectsMode', () => {
167
it('multiple layout effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
168
function App({text}) {
169
React.useLayoutEffect(() => {
170
- Scheduler.unstable_yieldValue('useLayoutEffect One mount');
171
- return () =>
172
- Scheduler.unstable_yieldValue('useLayoutEffect One unmount');
170
+ Scheduler.log('useLayoutEffect One mount');
171
+ return () => Scheduler.log('useLayoutEffect One unmount');
172
});
173
174
React.useLayoutEffect(() => {
176
- Scheduler.unstable_yieldValue('useLayoutEffect Two mount');
177
- return () =>
178
- Scheduler.unstable_yieldValue('useLayoutEffect Two unmount');
175
+ Scheduler.log('useLayoutEffect Two mount');
176
+ return () => Scheduler.log('useLayoutEffect Two unmount');
177
});
178
179
return text;
@@ -222,11 +220,11 @@ describe('StrictEffectsMode', () => {
220
it('useEffect and useLayoutEffect is called twice when there is no unmount', () => {
221
function App({text}) {
222
React.useEffect(() => {
225
- Scheduler.unstable_yieldValue('useEffect mount');
223
+ Scheduler.log('useEffect mount');
224
});
225
226
React.useLayoutEffect(() => {
229
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
227
+ Scheduler.log('useLayoutEffect mount');
228
});
229
230
return text;
@@ -269,17 +267,17 @@ describe('StrictEffectsMode', () => {
267
268
componentDidMount() {
269
this.test();
272
- Scheduler.unstable_yieldValue('componentDidMount');
270
+ Scheduler.log('componentDidMount');
271
}
272
273
componentDidUpdate() {
274
this.test();
277
- Scheduler.unstable_yieldValue('componentDidUpdate');
275
+ Scheduler.log('componentDidUpdate');
276
}
277
278
componentWillUnmount() {
279
this.test();
282
- Scheduler.unstable_yieldValue('componentWillUnmount');
280
+ Scheduler.log('componentWillUnmount');
281
}
282
283
render() {
@@ -305,15 +303,15 @@ describe('StrictEffectsMode', () => {
303
it('double invoking works for class components', () => {
304
class App extends React.PureComponent {
305
componentDidMount() {
308
- Scheduler.unstable_yieldValue('componentDidMount');
306
+ Scheduler.log('componentDidMount');
307
}
308
309
componentDidUpdate() {
312
- Scheduler.unstable_yieldValue('componentDidUpdate');
310
+ Scheduler.log('componentDidUpdate');
311
}
312
313
componentWillUnmount() {
316
- Scheduler.unstable_yieldValue('componentWillUnmount');
314
+ Scheduler.log('componentWillUnmount');
315
}
316
317
render() {
@@ -354,15 +352,15 @@ describe('StrictEffectsMode', () => {
352
it('should not double invoke class lifecycles in legacy mode', () => {
353
class App extends React.PureComponent {
354
componentDidMount() {
357
- Scheduler.unstable_yieldValue('componentDidMount');
355
+ Scheduler.log('componentDidMount');
356
}
357
358
componentDidUpdate() {
361
- Scheduler.unstable_yieldValue('componentDidUpdate');
359
+ Scheduler.log('componentDidUpdate');
360
}
361
362
componentWillUnmount() {
365
- Scheduler.unstable_yieldValue('componentWillUnmount');
363
+ Scheduler.log('componentWillUnmount');
364
}
365
366
render() {
@@ -384,16 +382,16 @@ describe('StrictEffectsMode', () => {
382
if (state !== 1) {
383
setState(1);
384
}
387
- Scheduler.unstable_yieldValue('useEffect mount');
388
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
385
+ Scheduler.log('useEffect mount');
386
+ return () => Scheduler.log('useEffect unmount');
387
});
388
389
React.useLayoutEffect(() => {
392
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
393
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
390
+ Scheduler.log('useLayoutEffect mount');
391
+ return () => Scheduler.log('useLayoutEffect unmount');
392
});
393
396
- Scheduler.unstable_yieldValue(text);
394
+ Scheduler.log(text);
395
return text;
396
}
397
@@ -436,13 +434,12 @@ describe('StrictEffectsMode', () => {
434
let _setShowChild;
435
function Child() {
436
React.useEffect(() => {
439
- Scheduler.unstable_yieldValue('Child useEffect mount');
440
- return () => Scheduler.unstable_yieldValue('Child useEffect unmount');
437
+ Scheduler.log('Child useEffect mount');
438
+ return () => Scheduler.log('Child useEffect unmount');
439
});
440
React.useLayoutEffect(() => {
443
- Scheduler.unstable_yieldValue('Child useLayoutEffect mount');
444
- return () =>
445
- Scheduler.unstable_yieldValue('Child useLayoutEffect unmount');
441
+ Scheduler.log('Child useLayoutEffect mount');
442
+ return () => Scheduler.log('Child useLayoutEffect unmount');
443
});
444
445
return null;
@@ -452,13 +449,12 @@ describe('StrictEffectsMode', () => {
449
const [showChild, setShowChild] = React.useState(false);
450
_setShowChild = setShowChild;
451
React.useEffect(() => {
455
- Scheduler.unstable_yieldValue('App useEffect mount');
456
- return () => Scheduler.unstable_yieldValue('App useEffect unmount');
452
+ Scheduler.log('App useEffect mount');
453
+ return () => Scheduler.log('App useEffect unmount');
454
});
455
React.useLayoutEffect(() => {
459
- Scheduler.unstable_yieldValue('App useLayoutEffect mount');
460
- return () =>
461
- Scheduler.unstable_yieldValue('App useLayoutEffect unmount');
456
+ Scheduler.log('App useLayoutEffect mount');
457
+ return () => Scheduler.log('App useLayoutEffect unmount');
458
});
459
460
return showChild && <Child />;
@@ -513,11 +509,11 @@ describe('StrictEffectsMode', () => {
509
it('classes and functions are double invoked together correctly', () => {
510
class ClassChild extends React.PureComponent {
511
componentDidMount() {
516
- Scheduler.unstable_yieldValue('componentDidMount');
512
+ Scheduler.log('componentDidMount');
513
}
514
515
componentWillUnmount() {
520
- Scheduler.unstable_yieldValue('componentWillUnmount');
516
+ Scheduler.log('componentWillUnmount');
517
}
518
519
render() {
@@ -527,12 +523,12 @@ describe('StrictEffectsMode', () => {
523
524
function FunctionChild({text}) {
525
React.useEffect(() => {
530
- Scheduler.unstable_yieldValue('useEffect mount');
531
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
526
+ Scheduler.log('useEffect mount');
527
+ return () => Scheduler.log('useEffect unmount');
528
});
529
React.useLayoutEffect(() => {
534
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
535
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
530
+ Scheduler.log('useLayoutEffect mount');
531
+ return () => Scheduler.log('useLayoutEffect unmount');
532
});
533
return text;
534
}
packages/react-reconciler/src/__tests__/StrictEffectsModeDefaults-test.internal.js
+52
-59
@@ -40,13 +40,13 @@ describe('StrictEffectsMode defaults', () => {
40
it('should not double invoke effects in legacy mode', () => {
41
function App({text}) {
42
React.useEffect(() => {
43
- Scheduler.unstable_yieldValue('useEffect mount');
44
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
43
+ Scheduler.log('useEffect mount');
44
+ return () => Scheduler.log('useEffect unmount');
45
});
46
47
React.useLayoutEffect(() => {
48
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
49
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
48
+ Scheduler.log('useLayoutEffect mount');
49
+ return () => Scheduler.log('useLayoutEffect unmount');
50
});
51
52
return text;
@@ -62,15 +62,15 @@ describe('StrictEffectsMode defaults', () => {
62
it('should not double invoke class lifecycles in legacy mode', () => {
63
class App extends React.PureComponent {
64
componentDidMount() {
65
- Scheduler.unstable_yieldValue('componentDidMount');
65
+ Scheduler.log('componentDidMount');
66
}
67
68
componentDidUpdate() {
69
- Scheduler.unstable_yieldValue('componentDidUpdate');
69
+ Scheduler.log('componentDidUpdate');
70
}
71
72
componentWillUnmount() {
73
- Scheduler.unstable_yieldValue('componentWillUnmount');
73
+ Scheduler.log('componentWillUnmount');
74
}
75
76
render() {
@@ -89,9 +89,8 @@ describe('StrictEffectsMode defaults', () => {
89
it('should flush double-invoked effects within the same frame as layout effects if there are no passive effects', async () => {
90
function ComponentWithEffects({label}) {
91
React.useLayoutEffect(() => {
92
- Scheduler.unstable_yieldValue(`useLayoutEffect mount "${label}"`);
93
- return () =>
94
- Scheduler.unstable_yieldValue(`useLayoutEffect unmount "${label}"`);
92
+ Scheduler.log(`useLayoutEffect mount "${label}"`);
93
+ return () => Scheduler.log(`useLayoutEffect unmount "${label}"`);
94
});
95
96
return label;
@@ -138,15 +137,13 @@ describe('StrictEffectsMode defaults', () => {
137
it('should double invoke effects only for newly mounted components', async () => {
138
function ComponentWithEffects({label}) {
139
React.useEffect(() => {
141
- Scheduler.unstable_yieldValue(`useEffect mount "${label}"`);
142
- return () =>
143
- Scheduler.unstable_yieldValue(`useEffect unmount "${label}"`);
140
+ Scheduler.log(`useEffect mount "${label}"`);
141
+ return () => Scheduler.log(`useEffect unmount "${label}"`);
142
});
143
144
React.useLayoutEffect(() => {
147
- Scheduler.unstable_yieldValue(`useLayoutEffect mount "${label}"`);
148
- return () =>
149
- Scheduler.unstable_yieldValue(`useLayoutEffect unmount "${label}"`);
145
+ Scheduler.log(`useLayoutEffect mount "${label}"`);
146
+ return () => Scheduler.log(`useLayoutEffect unmount "${label}"`);
147
});
148
149
return label;
@@ -200,13 +197,13 @@ describe('StrictEffectsMode defaults', () => {
197
it('double invoking for effects for modern roots', () => {
198
function App({text}) {
199
React.useEffect(() => {
203
- Scheduler.unstable_yieldValue('useEffect mount');
204
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
200
+ Scheduler.log('useEffect mount');
201
+ return () => Scheduler.log('useEffect unmount');
202
});
203
204
React.useLayoutEffect(() => {
208
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
209
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
205
+ Scheduler.log('useLayoutEffect mount');
206
+ return () => Scheduler.log('useLayoutEffect unmount');
207
});
208
209
return text;
@@ -245,13 +242,13 @@ describe('StrictEffectsMode defaults', () => {
242
it('multiple effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
243
function App({text}) {
244
React.useEffect(() => {
248
- Scheduler.unstable_yieldValue('useEffect One mount');
249
- return () => Scheduler.unstable_yieldValue('useEffect One unmount');
245
+ Scheduler.log('useEffect One mount');
246
+ return () => Scheduler.log('useEffect One unmount');
247
});
248
249
React.useEffect(() => {
253
- Scheduler.unstable_yieldValue('useEffect Two mount');
254
- return () => Scheduler.unstable_yieldValue('useEffect Two unmount');
250
+ Scheduler.log('useEffect Two mount');
251
+ return () => Scheduler.log('useEffect Two unmount');
252
});
253
254
return text;
@@ -291,15 +288,13 @@ describe('StrictEffectsMode defaults', () => {
288
it('multiple layout effects are double invoked in the right order (all mounted, all unmounted, all remounted)', () => {
289
function App({text}) {
290
React.useLayoutEffect(() => {
294
- Scheduler.unstable_yieldValue('useLayoutEffect One mount');
295
- return () =>
296
- Scheduler.unstable_yieldValue('useLayoutEffect One unmount');
291
+ Scheduler.log('useLayoutEffect One mount');
292
+ return () => Scheduler.log('useLayoutEffect One unmount');
293
});
294
295
React.useLayoutEffect(() => {
300
- Scheduler.unstable_yieldValue('useLayoutEffect Two mount');
301
- return () =>
302
- Scheduler.unstable_yieldValue('useLayoutEffect Two unmount');
296
+ Scheduler.log('useLayoutEffect Two mount');
297
+ return () => Scheduler.log('useLayoutEffect Two unmount');
298
});
299
300
return text;
@@ -339,11 +334,11 @@ describe('StrictEffectsMode defaults', () => {
334
it('useEffect and useLayoutEffect is called twice when there is no unmount', () => {
335
function App({text}) {
336
React.useEffect(() => {
342
- Scheduler.unstable_yieldValue('useEffect mount');
337
+ Scheduler.log('useEffect mount');
338
});
339
340
React.useLayoutEffect(() => {
346
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
341
+ Scheduler.log('useLayoutEffect mount');
342
});
343
344
return text;
@@ -403,17 +398,17 @@ describe('StrictEffectsMode defaults', () => {
398
399
componentDidMount() {
400
this.test();
406
- Scheduler.unstable_yieldValue('componentDidMount');
401
+ Scheduler.log('componentDidMount');
402
}
403
404
componentDidUpdate() {
405
this.test();
411
- Scheduler.unstable_yieldValue('componentDidUpdate');
406
+ Scheduler.log('componentDidUpdate');
407
}
408
409
componentWillUnmount() {
410
this.test();
416
- Scheduler.unstable_yieldValue('componentWillUnmount');
411
+ Scheduler.log('componentWillUnmount');
412
}
413
414
render() {
@@ -435,15 +430,15 @@ describe('StrictEffectsMode defaults', () => {
430
it('double invoking works for class components', () => {
431
class App extends React.PureComponent {
432
componentDidMount() {
438
- Scheduler.unstable_yieldValue('componentDidMount');
433
+ Scheduler.log('componentDidMount');
434
}
435
436
componentDidUpdate() {
442
- Scheduler.unstable_yieldValue('componentDidUpdate');
437
+ Scheduler.log('componentDidUpdate');
438
}
439
440
componentWillUnmount() {
446
- Scheduler.unstable_yieldValue('componentWillUnmount');
441
+ Scheduler.log('componentWillUnmount');
442
}
443
444
render() {
@@ -481,16 +476,16 @@ describe('StrictEffectsMode defaults', () => {
476
if (state !== 1) {
477
setState(1);
478
}
484
- Scheduler.unstable_yieldValue('useEffect mount');
485
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
479
+ Scheduler.log('useEffect mount');
480
+ return () => Scheduler.log('useEffect unmount');
481
});
482
483
React.useLayoutEffect(() => {
489
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
490
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
484
+ Scheduler.log('useLayoutEffect mount');
485
+ return () => Scheduler.log('useLayoutEffect unmount');
486
});
487
493
- Scheduler.unstable_yieldValue(text);
488
+ Scheduler.log(text);
489
return text;
490
}
491
@@ -518,13 +513,12 @@ describe('StrictEffectsMode defaults', () => {
513
let _setShowChild;
514
function Child() {
515
React.useEffect(() => {
521
- Scheduler.unstable_yieldValue('Child useEffect mount');
522
- return () => Scheduler.unstable_yieldValue('Child useEffect unmount');
516
+ Scheduler.log('Child useEffect mount');
517
+ return () => Scheduler.log('Child useEffect unmount');
518
});
519
React.useLayoutEffect(() => {
525
- Scheduler.unstable_yieldValue('Child useLayoutEffect mount');
526
- return () =>
527
- Scheduler.unstable_yieldValue('Child useLayoutEffect unmount');
520
+ Scheduler.log('Child useLayoutEffect mount');
521
+ return () => Scheduler.log('Child useLayoutEffect unmount');
522
});
523
524
return null;
@@ -534,13 +528,12 @@ describe('StrictEffectsMode defaults', () => {
528
const [showChild, setShowChild] = React.useState(false);
529
_setShowChild = setShowChild;
530
React.useEffect(() => {
537
- Scheduler.unstable_yieldValue('App useEffect mount');
538
- return () => Scheduler.unstable_yieldValue('App useEffect unmount');
531
+ Scheduler.log('App useEffect mount');
532
+ return () => Scheduler.log('App useEffect unmount');
533
});
534
React.useLayoutEffect(() => {
541
- Scheduler.unstable_yieldValue('App useLayoutEffect mount');
542
- return () =>
543
- Scheduler.unstable_yieldValue('App useLayoutEffect unmount');
535
+ Scheduler.log('App useLayoutEffect mount');
536
+ return () => Scheduler.log('App useLayoutEffect unmount');
537
});
538
539
return showChild && <Child />;
@@ -580,11 +573,11 @@ describe('StrictEffectsMode defaults', () => {
573
it('classes and functions are double invoked together correctly', () => {
574
class ClassChild extends React.PureComponent {
575
componentDidMount() {
583
- Scheduler.unstable_yieldValue('componentDidMount');
576
+ Scheduler.log('componentDidMount');
577
}
578
579
componentWillUnmount() {
587
- Scheduler.unstable_yieldValue('componentWillUnmount');
580
+ Scheduler.log('componentWillUnmount');
581
}
582
583
render() {
@@ -594,12 +587,12 @@ describe('StrictEffectsMode defaults', () => {
587
588
function FunctionChild({text}) {
589
React.useEffect(() => {
597
- Scheduler.unstable_yieldValue('useEffect mount');
598
- return () => Scheduler.unstable_yieldValue('useEffect unmount');
590
+ Scheduler.log('useEffect mount');
591
+ return () => Scheduler.log('useEffect unmount');
592
});
593
React.useLayoutEffect(() => {
601
- Scheduler.unstable_yieldValue('useLayoutEffect mount');
602
- return () => Scheduler.unstable_yieldValue('useLayoutEffect unmount');
594
+ Scheduler.log('useLayoutEffect mount');
595
+ return () => Scheduler.log('useLayoutEffect unmount');
596
});
597
return text;
598
}
packages/react-reconciler/src/__tests__/useEffectEvent-test.js
+10
-10
@@ -51,7 +51,7 @@ describe('useEffectEvent', () => {
51
});
52
53
function Text(props) {
54
- Scheduler.unstable_yieldValue(props.text);
54
+ Scheduler.log(props.text);
55
return <span prop={props.text} />;
56
}
57
@@ -298,7 +298,7 @@ describe('useEffectEvent', () => {
298
);
299
300
useLayoutEffect(() => {
301
- Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
301
+ Scheduler.log('Effect: by ' + incrementBy * 2);
302
increment(incrementBy * 2);
303
}, [incrementBy]);
304
@@ -398,7 +398,7 @@ describe('useEffectEvent', () => {
398
);
399
400
useEffect(() => {
401
- Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
401
+ Scheduler.log('Effect: by ' + incrementBy * 2);
402
increment(incrementBy * 2);
403
}, [incrementBy]);
404
@@ -503,7 +503,7 @@ describe('useEffectEvent', () => {
503
const [count, increment] = useCount(incrementBy);
504
505
useEffect(() => {
506
- Scheduler.unstable_yieldValue('Effect: by ' + incrementBy * 2);
506
+ Scheduler.log('Effect: by ' + incrementBy * 2);
507
increment(incrementBy * 2);
508
}, [incrementBy]);
509
@@ -588,14 +588,14 @@ describe('useEffectEvent', () => {
588
it('is mutated before all other effects', async () => {
589
function Counter({value}) {
590
useInsertionEffect(() => {
591
- Scheduler.unstable_yieldValue('Effect value: ' + value);
591
+ Scheduler.log('Effect value: ' + value);
592
increment();
593
}, [value]);
594
595
// This is defined after the insertion effect, but it should
596
// update the event fn _before_ the insertion effect fires.
597
const increment = useEffectEvent(() => {
598
- Scheduler.unstable_yieldValue('Event value: ' + value);
598
+ Scheduler.log('Event value: ' + value);
599
});
600
601
return <></>;
@@ -612,7 +612,7 @@ describe('useEffectEvent', () => {
612
it("doesn't provide a stable identity", async () => {
613
function Counter({shouldRender, value}) {
614
const onClick = useEffectEvent(() => {
615
- Scheduler.unstable_yieldValue(
615
+ Scheduler.log(
616
'onClick, shouldRender=' + shouldRender + ', value=' + value,
617
);
618
});
@@ -662,7 +662,7 @@ describe('useEffectEvent', () => {
662
() => {
663
// Log when the effect fires. In the test below, we'll assert that this
664
// only happens during initial render, not during updates.
665
- Scheduler.unstable_yieldValue('Commit new event handler');
665
+ Scheduler.log('Commit new event handler');
666
committedEventHandler = event;
667
return () => {
668
committedEventHandler = null;
@@ -727,7 +727,7 @@ describe('useEffectEvent', () => {
727
728
function ChatRoom({roomId, theme}) {
729
const onConnected = useEffectEvent(() => {
730
- Scheduler.unstable_yieldValue('Connected! theme: ' + theme);
730
+ Scheduler.log('Connected! theme: ' + theme);
731
});
732
733
useEffect(() => {
@@ -815,7 +815,7 @@ describe('useEffectEvent', () => {
815
const numberOfItems = items.length;
816
817
const onVisit = useEffectEvent(visitedUrl => {
818
- Scheduler.unstable_yieldValue(
818
+ Scheduler.log(
819
'url: ' + visitedUrl + ', numberOfItems: ' + numberOfItems,
820
);
821
});
packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js
+41
-43
@@ -145,7 +145,7 @@ describe('useMutableSource', () => {
145
146
function Component({getSnapshot, label, mutableSource, subscribe}) {
147
const snapshot = useMutableSource(mutableSource, getSnapshot, subscribe);
148
- Scheduler.unstable_yieldValue(`${label}:${snapshot}`);
148
+ Scheduler.log(`${label}:${snapshot}`);
149
return <div>{`${label}:${snapshot}`}</div>;
150
}
151
@@ -173,7 +173,7 @@ describe('useMutableSource', () => {
173
/>
174
</>,
175
'root',
176
- () => Scheduler.unstable_yieldValue('Sync effect'),
176
+ () => Scheduler.log('Sync effect'),
177
);
178
await waitFor(['a:one', 'b:one', 'Sync effect']);
179
@@ -197,7 +197,7 @@ describe('useMutableSource', () => {
197
/>
198
</>,
199
'root',
200
- () => Scheduler.unstable_yieldValue('Sync effect'),
200
+ () => Scheduler.log('Sync effect'),
201
);
202
await waitForAll(['a:two', 'Sync effect']);
203
ReactNoop.flushPassiveEffects();
@@ -237,7 +237,7 @@ describe('useMutableSource', () => {
237
subscribe={defaultSubscribe}
238
/>
239
</>,
240
- () => Scheduler.unstable_yieldValue('Sync effect'),
240
+ () => Scheduler.log('Sync effect'),
241
);
242
});
243
// Do enough work to read from one component
@@ -272,7 +272,7 @@ describe('useMutableSource', () => {
272
subscribe={defaultSubscribe}
273
/>
274
</>,
275
- () => Scheduler.unstable_yieldValue('Sync effect'),
275
+ () => Scheduler.log('Sync effect'),
276
);
277
278
// Finish rendering
@@ -309,7 +309,7 @@ describe('useMutableSource', () => {
309
mutableSource={mutableSourceA}
310
subscribe={defaultSubscribe}
311
/>,
312
- () => Scheduler.unstable_yieldValue('Sync effect'),
312
+ () => Scheduler.log('Sync effect'),
313
);
314
await waitForAll(['only:a-one', 'Sync effect']);
315
ReactNoop.flushPassiveEffects();
@@ -327,7 +327,7 @@ describe('useMutableSource', () => {
327
mutableSource={mutableSourceB}
328
subscribe={defaultSubscribe}
329
/>,
330
- () => Scheduler.unstable_yieldValue('Sync effect'),
330
+ () => Scheduler.log('Sync effect'),
331
);
332
await waitForAll(['only:b-one', 'Sync effect']);
333
ReactNoop.flushPassiveEffects();
@@ -375,7 +375,7 @@ describe('useMutableSource', () => {
375
subscribe={subscribeA}
376
/>,
377
'root',
378
- () => Scheduler.unstable_yieldValue('Sync effect'),
378
+ () => Scheduler.log('Sync effect'),
379
);
380
await waitForAll(['only:a-one', 'Sync effect']);
381
ReactNoop.flushPassiveEffects();
@@ -392,7 +392,7 @@ describe('useMutableSource', () => {
392
subscribe={subscribeB}
393
/>,
394
'root',
395
- () => Scheduler.unstable_yieldValue('Sync effect'),
395
+ () => Scheduler.log('Sync effect'),
396
);
397
await waitForAll(['only:a-one', 'Sync effect']);
398
ReactNoop.flushPassiveEffects();
@@ -430,7 +430,7 @@ describe('useMutableSource', () => {
430
subscribe={defaultSubscribe}
431
/>
432
</>,
433
- () => Scheduler.unstable_yieldValue('Sync effect'),
433
+ () => Scheduler.log('Sync effect'),
434
);
435
await waitForAll(['a:one', 'b:one', 'Sync effect']);
436
@@ -459,7 +459,7 @@ describe('useMutableSource', () => {
459
subscribe={defaultSubscribe}
460
/>
461
</>,
462
- () => Scheduler.unstable_yieldValue('Sync effect'),
462
+ () => Scheduler.log('Sync effect'),
463
);
464
});
465
assertLog(['a:one', 'b:one', 'Sync effect']);
@@ -483,7 +483,7 @@ describe('useMutableSource', () => {
483
subscribe={defaultSubscribe}
484
/>
485
</>,
486
- () => Scheduler.unstable_yieldValue('Sync effect'),
486
+ () => Scheduler.log('Sync effect'),
487
);
488
await waitForAll(['a:one', 'Sync effect']);
489
@@ -502,7 +502,7 @@ describe('useMutableSource', () => {
502
subscribe={defaultSubscribe}
503
/>
504
</>,
505
- () => Scheduler.unstable_yieldValue('Sync effect'),
505
+ () => Scheduler.log('Sync effect'),
506
);
507
await waitForAll(['a:one', 'b:one', 'Sync effect']);
508
});
@@ -529,7 +529,7 @@ describe('useMutableSource', () => {
529
subscribe={defaultSubscribe}
530
/>
531
</>,
532
- () => Scheduler.unstable_yieldValue('Sync effect'),
532
+ () => Scheduler.log('Sync effect'),
533
);
534
await waitForAll(['a:one', 'b:one', 'Sync effect']);
535
ReactNoop.flushPassiveEffects();
@@ -562,7 +562,7 @@ describe('useMutableSource', () => {
562
subscribe={defaultSubscribe}
563
/>
564
</>,
565
- () => Scheduler.unstable_yieldValue('Sync effect'),
565
+ () => Scheduler.log('Sync effect'),
566
);
567
});
568
assertLog(['a:new:two', 'b:new:two', 'Sync effect']);
@@ -590,7 +590,7 @@ describe('useMutableSource', () => {
590
subscribe={defaultSubscribe}
591
/>
592
</>,
593
- () => Scheduler.unstable_yieldValue('Sync effect'),
593
+ () => Scheduler.log('Sync effect'),
594
);
595
await waitForAll(['a:one', 'b:one', 'Sync effect']);
596
ReactNoop.flushPassiveEffects();
@@ -623,7 +623,7 @@ describe('useMutableSource', () => {
623
subscribe={defaultSubscribe}
624
/>
625
</>,
626
- () => Scheduler.unstable_yieldValue('Sync effect'),
626
+ () => Scheduler.log('Sync effect'),
627
);
628
});
629
assertLog(['a:new:two', 'b:new:two', 'Sync effect']);
@@ -657,7 +657,7 @@ describe('useMutableSource', () => {
657
subscribe={subscribeB}
658
/>
659
</>,
660
- () => Scheduler.unstable_yieldValue('Sync effect'),
660
+ () => Scheduler.log('Sync effect'),
661
);
662
await waitForAll(['a:a:one', 'b:b:one', 'Sync effect']);
663
@@ -690,7 +690,7 @@ describe('useMutableSource', () => {
690
subscribe={subscribeA}
691
/>
692
</>,
693
- () => Scheduler.unstable_yieldValue('Sync effect'),
693
+ () => Scheduler.log('Sync effect'),
694
);
695
await waitForAll(['a:a:one', 'Sync effect']);
696
@@ -718,7 +718,7 @@ describe('useMutableSource', () => {
718
subscribe={subscribeB}
719
/>
720
</>,
721
- () => Scheduler.unstable_yieldValue('Sync effect'),
721
+ () => Scheduler.log('Sync effect'),
722
);
723
});
724
await waitFor(['a:a:one', 'b:b:one']);
@@ -746,7 +746,7 @@ describe('useMutableSource', () => {
746
mutableSource={mutableSource}
747
subscribe={defaultSubscribe}
748
/>,
749
- () => Scheduler.unstable_yieldValue('Sync effect'),
749
+ () => Scheduler.log('Sync effect'),
750
);
751
await waitFor(['only:one', 'Sync effect']);
752
ReactNoop.flushPassiveEffects();
@@ -782,7 +782,7 @@ describe('useMutableSource', () => {
782
783
await act(async () => {
784
ReactNoop.render(<WrapperWithState />, () =>
785
- Scheduler.unstable_yieldValue('Sync effect'),
785
+ Scheduler.log('Sync effect'),
786
);
787
await waitForAll(['only:one', 'Sync effect']);
788
ReactNoop.flushPassiveEffects();
@@ -873,7 +873,7 @@ describe('useMutableSource', () => {
873
<WrapperWithState />
874
</React.Profiler>
875
</>,
876
- () => Scheduler.unstable_yieldValue('Sync effect'),
876
+ () => Scheduler.log('Sync effect'),
877
);
878
await waitForAll(['a:one', 'b:one', 'Sync effect']);
879
ReactNoop.flushPassiveEffects();
@@ -914,7 +914,7 @@ describe('useMutableSource', () => {
914
915
await act(async () => {
916
ReactNoop.render(<WrapperWithState />, () =>
917
- Scheduler.unstable_yieldValue('Sync effect'),
917
+ Scheduler.log('Sync effect'),
918
);
919
await waitForAll(['only:one', 'Sync effect']);
920
ReactNoop.flushPassiveEffects();
@@ -973,14 +973,12 @@ describe('useMutableSource', () => {
973
getSnapshot,
974
defaultSubscribe,
975
);
976
- Scheduler.unstable_yieldValue(`${id}:${name}`);
976
+ Scheduler.log(`${id}:${name}`);
977
return <li>{name}</li>;
978
}
979
980
await act(async () => {
981
- ReactNoop.render(<FriendsList />, () =>
982
- Scheduler.unstable_yieldValue('Sync effect'),
983
- );
981
+ ReactNoop.render(<FriendsList />, () => Scheduler.log('Sync effect'));
982
await waitForAll(['1:Foo', '2:Bar', 'Sync effect']);
983
984
// This mutation will cause the "Bar" component to throw,
@@ -1004,7 +1002,7 @@ describe('useMutableSource', () => {
1002
1003
function Wrapper() {
1004
React.useLayoutEffect(() => () => {
1007
- Scheduler.unstable_yieldValue('layout unmount');
1005
+ Scheduler.log('layout unmount');
1006
});
1007
return (
1008
<Component
@@ -1018,7 +1016,7 @@ describe('useMutableSource', () => {
1016
1017
await act(async () => {
1018
ReactNoop.renderToRootWithID(<Wrapper />, 'root', () =>
1021
- Scheduler.unstable_yieldValue('Sync effect'),
1019
+ Scheduler.log('Sync effect'),
1020
);
1021
await waitForAll(['only:one', 'Sync effect']);
1022
ReactNoop.flushPassiveEffects();
@@ -1222,7 +1220,7 @@ describe('useMutableSource', () => {
1220
}
1221
1222
React.useEffect(() => {
1225
- Scheduler.unstable_yieldValue(result);
1223
+ Scheduler.log(result);
1224
}, [result]);
1225
1226
return result;
@@ -1296,9 +1294,9 @@ describe('useMutableSource', () => {
1294
defaultSubscribe,
1295
);
1296
1299
- Scheduler.unstable_yieldValue('Render: ' + value);
1297
+ Scheduler.log('Render: ' + value);
1298
React.useEffect(() => {
1301
- Scheduler.unstable_yieldValue('Commit: ' + value);
1299
+ Scheduler.log('Commit: ' + value);
1300
}, [value]);
1301
1302
return value;
@@ -1436,12 +1434,12 @@ describe('useMutableSource', () => {
1434
getSnapshot,
1435
defaultSubscribe,
1436
);
1439
- Scheduler.unstable_yieldValue(value);
1437
+ Scheduler.log(value);
1438
return value;
1439
}
1440
1441
function Text({text}) {
1444
- Scheduler.unstable_yieldValue(text);
1442
+ Scheduler.log(text);
1443
return text;
1444
}
1445
@@ -1513,7 +1511,7 @@ describe('useMutableSource', () => {
1511
function Read() {
1512
const fn = useMutableSource(mutableSource, getSnapshot, defaultSubscribe);
1513
const value = fn();
1516
- Scheduler.unstable_yieldValue(value);
1514
+ Scheduler.log(value);
1515
return value;
1516
}
1517
@@ -1553,7 +1551,7 @@ describe('useMutableSource', () => {
1551
subscribe,
1552
);
1553
1556
- Scheduler.unstable_yieldValue('Parent: ' + parentValue);
1554
+ Scheduler.log('Parent: ' + parentValue);
1555
1556
return (
1557
<Child
@@ -1572,7 +1570,7 @@ describe('useMutableSource', () => {
1570
subscribe,
1571
);
1572
1575
- Scheduler.unstable_yieldValue('Child: ' + childValue);
1573
+ Scheduler.log('Child: ' + childValue);
1574
1575
let result = `${parentValue}, ${childValue}`;
1576
@@ -1585,7 +1583,7 @@ describe('useMutableSource', () => {
1583
}
1584
1585
useEffect(() => {
1588
- Scheduler.unstable_yieldValue('Commit: ' + result);
1586
+ Scheduler.log('Commit: ' + result);
1587
}, [result]);
1588
1589
return result;
@@ -1648,7 +1646,7 @@ describe('useMutableSource', () => {
1646
defaultGetSnapshot,
1647
defaultSubscribe,
1648
);
1651
- Scheduler.unstable_yieldValue(`a:${snapshot}`);
1649
+ Scheduler.log(`a:${snapshot}`);
1650
React.useEffect(() => {
1651
committedA = snapshot;
1652
}, [snapshot]);
@@ -1660,7 +1658,7 @@ describe('useMutableSource', () => {
1658
defaultGetSnapshot,
1659
defaultSubscribe,
1660
);
1663
- Scheduler.unstable_yieldValue(`b:${snapshot}`);
1661
+ Scheduler.log(`b:${snapshot}`);
1662
React.useEffect(() => {
1663
committedB = snapshot;
1664
}, [snapshot]);
@@ -1673,7 +1671,7 @@ describe('useMutableSource', () => {
1671
<React.Profiler id="root" onRender={onRender}>
1672
<ComponentA />
1673
</React.Profiler>,
1676
- () => Scheduler.unstable_yieldValue('Sync effect'),
1674
+ () => Scheduler.log('Sync effect'),
1675
);
1676
});
1677
assertLog(['a:one', 'Sync effect']);
@@ -1686,7 +1684,7 @@ describe('useMutableSource', () => {
1684
<ComponentA />
1685
<ComponentB />
1686
</React.Profiler>,
1689
- () => Scheduler.unstable_yieldValue('Sync effect'),
1687
+ () => Scheduler.log('Sync effect'),
1688
);
1689
await waitFor(['a:one', 'b:one', 'Sync effect']);
1690
expect(source.listenerCount).toBe(1);
packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js
+4
-4
@@ -137,7 +137,7 @@ describe('useMutableSourceHydration', () => {
137
138
function Component({getSnapshot, label, mutableSource, subscribe}) {
139
const snapshot = useMutableSource(mutableSource, getSnapshot, subscribe);
140
- Scheduler.unstable_yieldValue(`${label}:${snapshot}`);
140
+ Scheduler.log(`${label}:${snapshot}`);
141
return <div>{`${label}:${snapshot}`}</div>;
142
}
143
@@ -204,7 +204,7 @@ describe('useMutableSourceHydration', () => {
204
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
205
mutableSources: [mutableSource],
206
onRecoverableError(error) {
207
- Scheduler.unstable_yieldValue('Log error: ' + error.message);
207
+ Scheduler.log('Log error: ' + error.message);
208
},
209
});
210
@@ -264,7 +264,7 @@ describe('useMutableSourceHydration', () => {
264
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
265
mutableSources: [mutableSource],
266
onRecoverableError(error) {
267
- Scheduler.unstable_yieldValue('Log error: ' + error.message);
267
+ Scheduler.log('Log error: ' + error.message);
268
},
269
});
270
});
@@ -348,7 +348,7 @@ describe('useMutableSourceHydration', () => {
348
ReactDOMClient.hydrateRoot(container, fragment, {
349
mutableSources: [mutableSource],
350
onRecoverableError(error) {
351
- Scheduler.unstable_yieldValue('Log error: ' + error.message);
351
+ Scheduler.log('Log error: ' + error.message);
352
},
353
});
354
});
packages/react-reconciler/src/__tests__/useRef-test.internal.js
+2
-2
@@ -46,7 +46,7 @@ describe('useRef', () => {
46
});
47
48
function Text(props) {
49
- Scheduler.unstable_yieldValue(props.text);
49
+ Scheduler.log(props.text);
50
return <span prop={props.text} />;
51
}
52
@@ -74,7 +74,7 @@ describe('useRef', () => {
74
function App() {
75
ping = useDebouncedCallback(
76
value => {
77
- Scheduler.unstable_yieldValue('ping: ' + value);
77
+ Scheduler.log('ping: ' + value);
78
},
79
100,
80
[],
packages/react-reconciler/src/__tests__/useSyncExternalStore-test.js
+2
-2
@@ -53,7 +53,7 @@ describe('useSyncExternalStore', () => {
53
});
54
55
function Text({text}) {
56
- Scheduler.unstable_yieldValue(text);
56
+ Scheduler.log(text);
57
return text;
58
}
59
@@ -110,7 +110,7 @@ describe('useSyncExternalStore', () => {
110
const aText = refA.current;
111
const bText = refB.current;
112
const cText = refC.current;
113
- Scheduler.unstable_yieldValue(
113
+ Scheduler.log(
114
`Children observed during layout: A${aText}B${bText}C${cText}`,
115
);
116
});
packages/react-refresh/src/__tests__/ReactFresh-test.js
+4
-4
@@ -2423,7 +2423,7 @@ describe('ReactFresh', () => {
2423
const AppV1 = prepare(() => {
2424
function Hello() {
2425
React.useLayoutEffect(() => {
2426
- Scheduler.unstable_yieldValue('Hello#layout');
2426
+ Scheduler.log('Hello#layout');
2427
});
2428
const [val, setVal] = React.useState(0);
2429
return (
@@ -2436,7 +2436,7 @@ describe('ReactFresh', () => {
2436
2437
return function App({offscreen}) {
2438
React.useLayoutEffect(() => {
2439
- Scheduler.unstable_yieldValue('App#layout');
2439
+ Scheduler.log('App#layout');
2440
});
2441
return (
2442
<LegacyHiddenDiv mode={offscreen ? 'hidden' : 'visible'}>
@@ -2457,7 +2457,7 @@ describe('ReactFresh', () => {
2457
patch(() => {
2458
function Hello() {
2459
React.useLayoutEffect(() => {
2460
- Scheduler.unstable_yieldValue('Hello#layout');
2460
+ Scheduler.log('Hello#layout');
2461
});
2462
const [val, setVal] = React.useState(0);
2463
return (
@@ -2496,7 +2496,7 @@ describe('ReactFresh', () => {
2496
patch(() => {
2497
function Hello() {
2498
React.useLayoutEffect(() => {
2499
- Scheduler.unstable_yieldValue('Hello#layout');
2499
+ Scheduler.log('Hello#layout');
2500
});
2501
const [val, setVal] = React.useState(0);
2502
return (
packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js
+2
-2
@@ -83,9 +83,9 @@ describe('ReactTestRenderer.act()', () => {
83
// This component will keep updating itself until step === 3
84
const [step, proceed] = useReducer(s => (s === 3 ? 3 : s + 1), 1);
85
useEffect(() => {
86
- Scheduler.unstable_yieldValue('Effect');
86
+ Scheduler.log('Effect');
87
alreadyResolvedPromise.then(() => {
88
- Scheduler.unstable_yieldValue('Microtask');
88
+ Scheduler.log('Microtask');
89
proceed();
90
});
91
});
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js
+3
-133
@@ -15,7 +15,6 @@ let ReactTestRenderer;
15
let Scheduler;
16
let waitForAll;
17
let waitFor;
18
-let assertLog;
18
19
describe('ReactTestRendererAsync', () => {
20
beforeEach(() => {
@@ -28,7 +27,6 @@ describe('ReactTestRendererAsync', () => {
27
const InternalTestUtils = require('internal-test-utils');
28
waitForAll = InternalTestUtils.waitForAll;
29
waitFor = InternalTestUtils.waitFor;
31
- assertLog = InternalTestUtils.assertLog;
30
});
31
32
it('flushAll flushes all work', async () => {
@@ -57,7 +55,7 @@ describe('ReactTestRendererAsync', () => {
55
56
it('flushAll returns array of yielded values', async () => {
57
function Child(props) {
60
- Scheduler.unstable_yieldValue(props.children);
58
+ Scheduler.log(props.children);
59
return props.children;
60
}
61
function Parent(props) {
@@ -83,7 +81,7 @@ describe('ReactTestRendererAsync', () => {
81
82
it('flushThrough flushes until the expected values is yielded', async () => {
83
function Child(props) {
86
- Scheduler.unstable_yieldValue(props.children);
84
+ Scheduler.log(props.children);
85
return props.children;
86
}
87
function Parent(props) {
@@ -115,7 +113,7 @@ describe('ReactTestRendererAsync', () => {
113
114
it('supports high priority interruptions', async () => {
115
function Child(props) {
118
- Scheduler.unstable_yieldValue(props.children);
116
+ Scheduler.log(props.children);
117
return props.children;
118
}
119
@@ -155,132 +153,4 @@ describe('ReactTestRendererAsync', () => {
153
// Only the higher priority properties have been committed
154
expect(renderer.toJSON()).toEqual(['A:2', 'B:2']);
155
});
158
-
159
- describe('Jest matchers', () => {
160
- it('toFlushAndYieldThrough', () => {
161
- const Yield = ({id}) => {
162
- Scheduler.unstable_yieldValue(id);
163
- return id;
164
- };
165
-
166
- ReactTestRenderer.create(
167
- <div>
168
- <Yield id="foo" />
169
- <Yield id="bar" />
170
- <Yield id="baz" />
171
- </div>,
172
- {
173
- unstable_isConcurrent: true,
174
- },
175
- );
176
-
177
- expect(() =>
178
- expect(Scheduler).toFlushAndYieldThrough(['foo', 'baz']),
179
- ).toThrow('// deep equality');
180
- });
181
-
182
- it('toFlushAndYield', () => {
183
- const Yield = ({id}) => {
184
- Scheduler.unstable_yieldValue(id);
185
- return id;
186
- };
187
-
188
- const renderer = ReactTestRenderer.create(
189
- <div>
190
- <Yield id="foo" />
191
- <Yield id="bar" />
192
- <Yield id="baz" />
193
- </div>,
194
- {
195
- unstable_isConcurrent: true,
196
- },
197
- );
198
-
199
- expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrowError(
200
- '// deep equality',
201
- );
202
-
203
- renderer.update(
204
- <div>
205
- <Yield id="foo" />
206
- <Yield id="bar" />
207
- <Yield id="baz" />
208
- </div>,
209
- );
210
-
211
- expect(() => expect(Scheduler).toFlushAndYield(['foo', 'baz'])).toThrow(
212
- '// deep equality',
213
- );
214
- });
215
-
216
- it('toFlushAndThrow', () => {
217
- const Yield = ({id}) => {
218
- Scheduler.unstable_yieldValue(id);
219
- return id;
220
- };
221
-
222
- function BadRender() {
223
- throw new Error('Oh no!');
224
- }
225
-
226
- function App() {
227
- return (
228
- <div>
229
- <Yield id="A" />
230
- <Yield id="B" />
231
- <BadRender />
232
- <Yield id="C" />
233
- <Yield id="D" />
234
- </div>
235
- );
236
- }
237
-
238
- const renderer = ReactTestRenderer.create(<App />, {
239
- unstable_isConcurrent: true,
240
- });
241
-
242
- expect(Scheduler).toFlushAndThrow('Oh no!');
243
- assertLog(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);
244
-
245
- renderer.update(<App />);
246
-
247
- expect(Scheduler).toFlushAndThrow('Oh no!');
248
- assertLog(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);
249
-
250
- renderer.update(<App />);
251
- expect(Scheduler).toFlushAndThrow('Oh no!');
252
- });
253
- });
254
-
255
- it('toHaveYielded', () => {
256
- const Yield = ({id}) => {
257
- Scheduler.unstable_yieldValue(id);
258
- return id;
259
- };
260
-
261
- function App() {
262
- return (
263
- <div>
264
- <Yield id="A" />
265
- <Yield id="B" />
266
- <Yield id="C" />
267
- </div>
268
- );
269
- }
270
-
271
- ReactTestRenderer.create(<App />);
272
- expect(() => expect(Scheduler).toHaveYielded(['A', 'B'])).toThrow(
273
- '// deep equality',
274
- );
275
- });
276
-
277
- it('flush methods throw if log is not empty', () => {
278
- ReactTestRenderer.create(<div />, {
279
- unstable_isConcurrent: true,
280
- });
281
- Scheduler.unstable_yieldValue('Something');
282
- expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrow(
283
- 'Log of yielded values is not empty.',
284
- );
285
- });
156
});
packages/react/src/__tests__/ReactProfiler-test.internal.js
+24
-28
@@ -202,7 +202,7 @@ describe(`onRender`, () => {
202
const callback = jest.fn();
203
204
const Yield = ({value}) => {
205
- Scheduler.unstable_yieldValue(value);
205
+ Scheduler.log(value);
206
return null;
207
};
208
@@ -233,7 +233,7 @@ describe(`onRender`, () => {
233
return {
234
...ActualScheduler,
235
unstable_now: function mockUnstableNow() {
236
- ActualScheduler.unstable_yieldValue('read current time');
236
+ ActualScheduler.log('read current time');
237
return ActualScheduler.unstable_now();
238
},
239
};
@@ -244,7 +244,7 @@ describe(`onRender`, () => {
244
loadModules();
245
246
// Clear yields in case the current time is read during initialization.
247
- Scheduler.unstable_clearYields();
247
+ Scheduler.unstable_clearLog();
248
249
ReactTestRenderer.create(
250
<div>
@@ -665,7 +665,7 @@ describe(`onRender`, () => {
665
}
666
}, [didMount, didMountAndUpdate]);
667
668
- Scheduler.unstable_yieldValue(`${didMount}:${didMountAndUpdate}`);
668
+ Scheduler.log(`${didMount}:${didMountAndUpdate}`);
669
670
return null;
671
}
@@ -698,7 +698,7 @@ describe(`onRender`, () => {
698
React.useLayoutEffect(() => {
699
setDidMount(true);
700
}, []);
701
- Scheduler.unstable_yieldValue(didMount);
701
+ Scheduler.log(didMount);
702
return didMount;
703
}
704
@@ -735,7 +735,7 @@ describe(`onRender`, () => {
735
736
const Yield = ({renderTime}) => {
737
Scheduler.unstable_advanceTime(renderTime);
738
- Scheduler.unstable_yieldValue('Yield:' + renderTime);
738
+ Scheduler.log('Yield:' + renderTime);
739
return null;
740
};
741
@@ -771,7 +771,7 @@ describe(`onRender`, () => {
771
772
const Yield = ({renderTime}) => {
773
Scheduler.unstable_advanceTime(renderTime);
774
- Scheduler.unstable_yieldValue('Yield:' + renderTime);
774
+ Scheduler.log('Yield:' + renderTime);
775
return null;
776
};
777
@@ -823,7 +823,7 @@ describe(`onRender`, () => {
823
824
const Yield = ({renderTime}) => {
825
Scheduler.unstable_advanceTime(renderTime);
826
- Scheduler.unstable_yieldValue('Yield:' + renderTime);
826
+ Scheduler.log('Yield:' + renderTime);
827
return null;
828
};
829
@@ -879,7 +879,7 @@ describe(`onRender`, () => {
879
880
const Yield = ({renderTime}) => {
881
Scheduler.unstable_advanceTime(renderTime);
882
- Scheduler.unstable_yieldValue('Yield:' + renderTime);
882
+ Scheduler.log('Yield:' + renderTime);
883
return null;
884
};
885
@@ -962,7 +962,7 @@ describe(`onRender`, () => {
962
963
const Yield = ({renderTime}) => {
964
Scheduler.unstable_advanceTime(renderTime);
965
- Scheduler.unstable_yieldValue('Yield:' + renderTime);
965
+ Scheduler.log('Yield:' + renderTime);
966
return null;
967
};
968
@@ -972,9 +972,7 @@ describe(`onRender`, () => {
972
render() {
973
first = this;
974
Scheduler.unstable_advanceTime(this.state.renderTime);
975
- Scheduler.unstable_yieldValue(
976
- 'FirstComponent:' + this.state.renderTime,
977
- );
975
+ Scheduler.log('FirstComponent:' + this.state.renderTime);
976
return <Yield renderTime={4} />;
977
}
978
}
@@ -984,9 +982,7 @@ describe(`onRender`, () => {
982
render() {
983
second = this;
984
Scheduler.unstable_advanceTime(this.state.renderTime);
987
- Scheduler.unstable_yieldValue(
988
- 'SecondComponent:' + this.state.renderTime,
989
- );
985
+ Scheduler.log('SecondComponent:' + this.state.renderTime);
986
return <Yield renderTime={7} />;
987
}
988
}
@@ -2375,7 +2371,7 @@ describe(`onNestedUpdateScheduled`, () => {
2371
React.useLayoutEffect(() => {
2372
setDidMount(true);
2373
}, []);
2378
- Scheduler.unstable_yieldValue(`Component:${didMount}`);
2374
+ Scheduler.log(`Component:${didMount}`);
2375
return didMount;
2376
}
2377
@@ -2404,7 +2400,7 @@ describe(`onNestedUpdateScheduled`, () => {
2400
setDidMount(true);
2401
});
2402
}, []);
2407
- Scheduler.unstable_yieldValue(`Component:${didMount}`);
2403
+ Scheduler.log(`Component:${didMount}`);
2404
return didMount;
2405
}
2406
@@ -2435,7 +2431,7 @@ describe(`onNestedUpdateScheduled`, () => {
2431
React.useLayoutEffect(() => {
2432
setDidMount(true);
2433
}, []);
2438
- Scheduler.unstable_yieldValue(`Component:${didMount}`);
2434
+ Scheduler.log(`Component:${didMount}`);
2435
return didMount;
2436
}
2437
const onNestedUpdateScheduledOne = jest.fn();
@@ -2476,7 +2472,7 @@ describe(`onNestedUpdateScheduled`, () => {
2472
function ComponentRootOne() {
2473
const [state, setState] = React.useState(false);
2474
setStateRef.current = setState;
2479
- Scheduler.unstable_yieldValue(`ComponentRootOne:${state}`);
2475
+ Scheduler.log(`ComponentRootOne:${state}`);
2476
return state;
2477
}
2478
@@ -2484,7 +2480,7 @@ describe(`onNestedUpdateScheduled`, () => {
2480
React.useLayoutEffect(() => {
2481
setStateRef.current(true);
2482
}, []);
2487
- Scheduler.unstable_yieldValue('ComponentRootTwo');
2483
+ Scheduler.log('ComponentRootTwo');
2484
return null;
2485
}
2486
@@ -2524,7 +2520,7 @@ describe(`onNestedUpdateScheduled`, () => {
2520
React.useEffect(() => {
2521
setDidMount(true);
2522
}, []);
2527
- Scheduler.unstable_yieldValue(`Component:${didMount}`);
2523
+ Scheduler.log(`Component:${didMount}`);
2524
return didMount;
2525
}
2526
@@ -2550,7 +2546,7 @@ describe(`onNestedUpdateScheduled`, () => {
2546
function Component() {
2547
const [state, setState] = React.useState(false);
2548
updateFnRef.current = () => setState(true);
2553
- Scheduler.unstable_yieldValue(`Component:${state}`);
2549
+ Scheduler.log(`Component:${state}`);
2550
return state;
2551
}
2552
@@ -2580,7 +2576,7 @@ describe(`onNestedUpdateScheduled`, () => {
2576
if (state === false) {
2577
setState(true);
2578
}
2583
- Scheduler.unstable_yieldValue(`Component:${state}`);
2579
+ Scheduler.log(`Component:${state}`);
2580
return state;
2581
}
2582
@@ -2611,7 +2607,7 @@ describe(`onNestedUpdateScheduled`, () => {
2607
setRefDetached(true);
2608
}
2609
}, []);
2614
- Scheduler.unstable_yieldValue(`Component:${refAttached}:${refDetached}`);
2610
+ Scheduler.log(`Component:${refAttached}:${refDetached}`);
2611
return mountChild ? <div ref={refSetter} /> : null;
2612
}
2613
@@ -2656,7 +2652,7 @@ describe(`onNestedUpdateScheduled`, () => {
2652
}
2653
render() {
2654
const {value} = this.state;
2659
- Scheduler.unstable_yieldValue(`Component:${value}`);
2655
+ Scheduler.log(`Component:${value}`);
2656
return value;
2657
}
2658
}
@@ -2694,7 +2690,7 @@ describe(`onNestedUpdateScheduled`, () => {
2690
render() {
2691
const {scheduleNestedUpdate} = this.props;
2692
const {nestedUpdateSheduled} = this.state;
2697
- Scheduler.unstable_yieldValue(
2693
+ Scheduler.log(
2694
`Component:${scheduleNestedUpdate}:${nestedUpdateSheduled}`,
2695
);
2696
return nestedUpdateSheduled;
@@ -2740,7 +2736,7 @@ describe(`onNestedUpdateScheduled`, () => {
2736
render() {
2737
const {value} = this.state;
2738
updateFnRef.current = () => this.setState({value: true});
2743
- Scheduler.unstable_yieldValue(`Component:${value}`);
2739
+ Scheduler.log(`Component:${value}`);
2740
return value;
2741
}
2742
}
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+1
-1
@@ -146,7 +146,7 @@ describe('ReactProfiler DevTools integration', () => {
146
147
it('regression test: #17159', async () => {
148
function Text({text}) {
149
- Scheduler.unstable_yieldValue(text);
149
+ Scheduler.log(text);
150
return text;
151
}
152
packages/react/src/__tests__/forwardRef-test.internal.js
+13
-13
@@ -32,7 +32,7 @@ describe('forwardRef', () => {
32
it('should work without a ref to be forwarded', async () => {
33
class Child extends React.Component {
34
render() {
35
- Scheduler.unstable_yieldValue(this.props.value);
35
+ Scheduler.log(this.props.value);
36
return null;
37
}
38
}
@@ -52,7 +52,7 @@ describe('forwardRef', () => {
52
it('should forward a ref for a single child', async () => {
53
class Child extends React.Component {
54
render() {
55
- Scheduler.unstable_yieldValue(this.props.value);
55
+ Scheduler.log(this.props.value);
56
return null;
57
}
58
}
@@ -75,7 +75,7 @@ describe('forwardRef', () => {
75
it('should forward a ref for multiple children', async () => {
76
class Child extends React.Component {
77
render() {
78
- Scheduler.unstable_yieldValue(this.props.value);
78
+ Scheduler.log(this.props.value);
79
return null;
80
}
81
}
@@ -107,7 +107,7 @@ describe('forwardRef', () => {
107
super(props);
108
}
109
render() {
110
- Scheduler.unstable_yieldValue(this.props.value);
110
+ Scheduler.log(this.props.value);
111
return null;
112
}
113
}
@@ -142,29 +142,29 @@ describe('forwardRef', () => {
142
class ErrorBoundary extends React.Component {
143
state = {error: null};
144
componentDidCatch(error) {
145
- Scheduler.unstable_yieldValue('ErrorBoundary.componentDidCatch');
145
+ Scheduler.log('ErrorBoundary.componentDidCatch');
146
this.setState({error});
147
}
148
render() {
149
if (this.state.error) {
150
- Scheduler.unstable_yieldValue('ErrorBoundary.render: catch');
150
+ Scheduler.log('ErrorBoundary.render: catch');
151
return null;
152
}
153
- Scheduler.unstable_yieldValue('ErrorBoundary.render: try');
153
+ Scheduler.log('ErrorBoundary.render: try');
154
return this.props.children;
155
}
156
}
157
158
class BadRender extends React.Component {
159
render() {
160
- Scheduler.unstable_yieldValue('BadRender throw');
160
+ Scheduler.log('BadRender throw');
161
throw new Error('oops!');
162
}
163
}
164
165
function Wrapper(props) {
166
const forwardedRef = props.forwardedRef;
167
- Scheduler.unstable_yieldValue('Wrapper');
167
+ Scheduler.log('Wrapper');
168
return <BadRender {...props} ref={forwardedRef} />;
169
}
170
@@ -201,24 +201,24 @@ describe('forwardRef', () => {
201
202
class Inner extends React.Component {
203
render() {
204
- Scheduler.unstable_yieldValue('Inner');
204
+ Scheduler.log('Inner');
205
inst = this;
206
return <div ref={this.props.forwardedRef} />;
207
}
208
}
209
210
function Middle(props) {
211
- Scheduler.unstable_yieldValue('Middle');
211
+ Scheduler.log('Middle');
212
return <Inner {...props} />;
213
}
214
215
const Forward = React.forwardRef((props, ref) => {
216
- Scheduler.unstable_yieldValue('Forward');
216
+ Scheduler.log('Forward');
217
return <Middle {...props} forwardedRef={ref} />;
218
});
219
220
function App() {
221
- Scheduler.unstable_yieldValue('App');
221
+ Scheduler.log('App');
222
return <Forward />;
223
}
224
packages/scheduler/src/__tests__/SchedulerMock-test.js
+98
-154
@@ -53,10 +53,10 @@ describe('Scheduler', () => {
53
});
54
55
it('flushes work incrementally', async () => {
56
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
57
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
58
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
59
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
56
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'));
57
+ scheduleCallback(NormalPriority, () => Scheduler.log('B'));
58
+ scheduleCallback(NormalPriority, () => Scheduler.log('C'));
59
+ scheduleCallback(NormalPriority, () => Scheduler.log('D'));
60
61
await waitFor(['A', 'B']);
62
await waitFor(['C']);
@@ -64,11 +64,11 @@ describe('Scheduler', () => {
64
});
65
66
it('cancels work', async () => {
67
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
67
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'));
68
const callbackHandleB = scheduleCallback(NormalPriority, () =>
69
- Scheduler.unstable_yieldValue('B'),
69
+ Scheduler.log('B'),
70
);
71
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
71
+ scheduleCallback(NormalPriority, () => Scheduler.log('C'));
72
73
cancelCallback(callbackHandleB);
74
@@ -80,18 +80,14 @@ describe('Scheduler', () => {
80
});
81
82
it('executes the highest priority callbacks first', async () => {
83
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
84
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
83
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'));
84
+ scheduleCallback(NormalPriority, () => Scheduler.log('B'));
85
86
// Yield before B is flushed
87
await waitFor(['A']);
88
89
- scheduleCallback(UserBlockingPriority, () =>
90
- Scheduler.unstable_yieldValue('C'),
91
- );
92
- scheduleCallback(UserBlockingPriority, () =>
93
- Scheduler.unstable_yieldValue('D'),
94
- );
89
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('C'));
90
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('D'));
91
92
// C and D should come first, because they are higher priority
93
await waitForAll(['C', 'D', 'B']);
@@ -100,15 +96,15 @@ describe('Scheduler', () => {
96
it('expires work', async () => {
97
scheduleCallback(NormalPriority, didTimeout => {
98
Scheduler.unstable_advanceTime(100);
103
- Scheduler.unstable_yieldValue(`A (did timeout: ${didTimeout})`);
99
+ Scheduler.log(`A (did timeout: ${didTimeout})`);
100
});
101
scheduleCallback(UserBlockingPriority, didTimeout => {
102
Scheduler.unstable_advanceTime(100);
107
- Scheduler.unstable_yieldValue(`B (did timeout: ${didTimeout})`);
103
+ Scheduler.log(`B (did timeout: ${didTimeout})`);
104
});
105
scheduleCallback(UserBlockingPriority, didTimeout => {
106
Scheduler.unstable_advanceTime(100);
111
- Scheduler.unstable_yieldValue(`C (did timeout: ${didTimeout})`);
107
+ Scheduler.log(`C (did timeout: ${didTimeout})`);
108
});
109
110
// Advance time, but not by enough to expire any work
@@ -118,11 +114,11 @@ describe('Scheduler', () => {
114
// Schedule a few more callbacks
115
scheduleCallback(NormalPriority, didTimeout => {
116
Scheduler.unstable_advanceTime(100);
121
- Scheduler.unstable_yieldValue(`D (did timeout: ${didTimeout})`);
117
+ Scheduler.log(`D (did timeout: ${didTimeout})`);
118
});
119
scheduleCallback(NormalPriority, didTimeout => {
120
Scheduler.unstable_advanceTime(100);
125
- Scheduler.unstable_yieldValue(`E (did timeout: ${didTimeout})`);
121
+ Scheduler.log(`E (did timeout: ${didTimeout})`);
122
});
123
124
// Advance by just a bit more to expire the user blocking callbacks
@@ -138,7 +134,7 @@ describe('Scheduler', () => {
134
});
135
136
it('has a default expiration of ~5 seconds', () => {
141
- scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
137
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'));
138
139
Scheduler.unstable_advanceTime(4999);
140
assertLog([]);
@@ -151,11 +147,11 @@ describe('Scheduler', () => {
147
it('continues working on same task after yielding', async () => {
148
scheduleCallback(NormalPriority, () => {
149
Scheduler.unstable_advanceTime(100);
154
- Scheduler.unstable_yieldValue('A');
150
+ Scheduler.log('A');
151
});
152
scheduleCallback(NormalPriority, () => {
153
Scheduler.unstable_advanceTime(100);
158
- Scheduler.unstable_yieldValue('B');
154
+ Scheduler.log('B');
155
});
156
157
let didYield = false;
@@ -168,7 +164,7 @@ describe('Scheduler', () => {
164
while (tasks.length > 0) {
165
const [label, ms] = tasks.shift();
166
Scheduler.unstable_advanceTime(ms);
171
- Scheduler.unstable_yieldValue(label);
167
+ Scheduler.log(label);
168
if (shouldYield()) {
169
didYield = true;
170
return C;
@@ -180,11 +176,11 @@ describe('Scheduler', () => {
176
177
scheduleCallback(NormalPriority, () => {
178
Scheduler.unstable_advanceTime(100);
183
- Scheduler.unstable_yieldValue('D');
179
+ Scheduler.log('D');
180
});
181
scheduleCallback(NormalPriority, () => {
182
Scheduler.unstable_advanceTime(100);
187
- Scheduler.unstable_yieldValue('E');
183
+ Scheduler.log('E');
184
});
185
186
// Flush, then yield while in the middle of C.
@@ -207,7 +203,7 @@ describe('Scheduler', () => {
203
while (tasks.length > 0) {
204
const [label, ms] = tasks.shift();
205
Scheduler.unstable_advanceTime(ms);
210
- Scheduler.unstable_yieldValue(label);
206
+ Scheduler.log(label);
207
if (shouldYield()) {
208
return work;
209
}
@@ -237,7 +233,7 @@ describe('Scheduler', () => {
233
while (tasks.length > 0) {
234
const [label, ms] = tasks.shift();
235
Scheduler.unstable_advanceTime(ms);
240
- Scheduler.unstable_yieldValue(label);
236
+ Scheduler.log(label);
237
if (tasks.length > 0 && shouldYield()) {
238
return work;
239
}
@@ -248,7 +244,7 @@ describe('Scheduler', () => {
244
245
scheduleCallback(UserBlockingPriority, () => {
246
Scheduler.unstable_advanceTime(100);
251
- Scheduler.unstable_yieldValue('High pri');
247
+ Scheduler.log('High pri');
248
});
249
250
await waitForAll(['High pri', 'B', 'C', 'D']);
@@ -269,13 +265,13 @@ describe('Scheduler', () => {
265
const task = tasks.shift();
266
const [label, ms] = task;
267
Scheduler.unstable_advanceTime(ms);
272
- Scheduler.unstable_yieldValue(label);
268
+ Scheduler.log(label);
269
if (label === 'B') {
270
// Schedule high pri work from inside another callback
275
- Scheduler.unstable_yieldValue('Schedule high pri');
271
+ Scheduler.log('Schedule high pri');
272
scheduleCallback(UserBlockingPriority, () => {
273
Scheduler.unstable_advanceTime(100);
278
- Scheduler.unstable_yieldValue('High pri');
274
+ Scheduler.log('High pri');
275
});
276
}
277
if (tasks.length > 0) {
@@ -301,9 +297,9 @@ describe('Scheduler', () => {
297
298
it('cancelling a continuation', async () => {
299
const task = scheduleCallback(NormalPriority, () => {
304
- Scheduler.unstable_yieldValue('Yield');
300
+ Scheduler.log('Yield');
301
return () => {
306
- Scheduler.unstable_yieldValue('Continuation');
302
+ Scheduler.log('Continuation');
303
};
304
});
305
@@ -313,18 +309,10 @@ describe('Scheduler', () => {
309
});
310
311
it('top-level immediate callbacks fire in a subsequent task', () => {
316
- scheduleCallback(ImmediatePriority, () =>
317
- Scheduler.unstable_yieldValue('A'),
318
- );
319
- scheduleCallback(ImmediatePriority, () =>
320
- Scheduler.unstable_yieldValue('B'),
321
- );
322
- scheduleCallback(ImmediatePriority, () =>
323
- Scheduler.unstable_yieldValue('C'),
324
- );
325
- scheduleCallback(ImmediatePriority, () =>
326
- Scheduler.unstable_yieldValue('D'),
327
- );
312
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('A'));
313
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('B'));
314
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('C'));
315
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('D'));
316
// Immediate callback hasn't fired, yet.
317
assertLog([]);
318
// They all flush immediately within the subsequent task.
@@ -333,19 +321,13 @@ describe('Scheduler', () => {
321
});
322
323
it('nested immediate callbacks are added to the queue of immediate callbacks', () => {
336
- scheduleCallback(ImmediatePriority, () =>
337
- Scheduler.unstable_yieldValue('A'),
338
- );
324
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('A'));
325
scheduleCallback(ImmediatePriority, () => {
340
- Scheduler.unstable_yieldValue('B');
326
+ Scheduler.log('B');
327
// This callback should go to the end of the queue
342
- scheduleCallback(ImmediatePriority, () =>
343
- Scheduler.unstable_yieldValue('C'),
344
- );
328
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('C'));
329
});
346
- scheduleCallback(ImmediatePriority, () =>
347
- Scheduler.unstable_yieldValue('D'),
348
- );
330
+ scheduleCallback(ImmediatePriority, () => Scheduler.log('D'));
331
assertLog([]);
332
// C should flush at the end
333
Scheduler.unstable_flushExpired();
@@ -360,7 +342,7 @@ describe('Scheduler', () => {
342
it('wrapped callbacks inherit the current priority', () => {
343
const wrappedCallback = runWithPriority(NormalPriority, () =>
344
wrapCallback(() => {
363
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
345
+ Scheduler.log(getCurrentPriorityLevel());
346
}),
347
);
348
@@ -368,7 +350,7 @@ describe('Scheduler', () => {
350
UserBlockingPriority,
351
() =>
352
wrapCallback(() => {
371
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
353
+ Scheduler.log(getCurrentPriorityLevel());
354
}),
355
);
356
@@ -385,11 +367,11 @@ describe('Scheduler', () => {
367
368
runWithPriority(NormalPriority, () => {
369
wrappedCallback = wrapCallback(() => {
388
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
370
+ Scheduler.log(getCurrentPriorityLevel());
371
});
372
wrappedUserBlockingCallback = runWithPriority(UserBlockingPriority, () =>
373
wrapCallback(() => {
392
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
374
+ Scheduler.log(getCurrentPriorityLevel());
375
}),
376
);
377
});
@@ -403,14 +385,14 @@ describe('Scheduler', () => {
385
386
it("immediate callbacks fire even if there's an error", () => {
387
scheduleCallback(ImmediatePriority, () => {
406
- Scheduler.unstable_yieldValue('A');
388
+ Scheduler.log('A');
389
throw new Error('Oops A');
390
});
391
scheduleCallback(ImmediatePriority, () => {
410
- Scheduler.unstable_yieldValue('B');
392
+ Scheduler.log('B');
393
});
394
scheduleCallback(ImmediatePriority, () => {
413
- Scheduler.unstable_yieldValue('C');
395
+ Scheduler.log('C');
396
throw new Error('Oops C');
397
});
398
@@ -436,16 +418,16 @@ describe('Scheduler', () => {
418
});
419
420
it('exposes the current priority level', () => {
439
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
421
+ Scheduler.log(getCurrentPriorityLevel());
422
runWithPriority(ImmediatePriority, () => {
441
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
423
+ Scheduler.log(getCurrentPriorityLevel());
424
runWithPriority(NormalPriority, () => {
443
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
425
+ Scheduler.log(getCurrentPriorityLevel());
426
runWithPriority(UserBlockingPriority, () => {
445
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
427
+ Scheduler.log(getCurrentPriorityLevel());
428
});
429
});
448
- Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
430
+ Scheduler.log(getCurrentPriorityLevel());
431
});
432
433
assertLog([
@@ -495,25 +477,19 @@ describe('Scheduler', () => {
477
}
478
479
scheduleCallback(ImmediatePriority, () =>
498
- Scheduler.unstable_yieldValue(
499
- 'Immediate: ' + inferPriorityFromCallstack(),
500
- ),
480
+ Scheduler.log('Immediate: ' + inferPriorityFromCallstack()),
481
);
482
scheduleCallback(UserBlockingPriority, () =>
503
- Scheduler.unstable_yieldValue(
504
- 'UserBlocking: ' + inferPriorityFromCallstack(),
505
- ),
483
+ Scheduler.log('UserBlocking: ' + inferPriorityFromCallstack()),
484
);
485
scheduleCallback(NormalPriority, () =>
508
- Scheduler.unstable_yieldValue(
509
- 'Normal: ' + inferPriorityFromCallstack(),
510
- ),
486
+ Scheduler.log('Normal: ' + inferPriorityFromCallstack()),
487
);
488
scheduleCallback(LowPriority, () =>
513
- Scheduler.unstable_yieldValue('Low: ' + inferPriorityFromCallstack()),
489
+ Scheduler.log('Low: ' + inferPriorityFromCallstack()),
490
);
491
scheduleCallback(IdlePriority, () =>
516
- Scheduler.unstable_yieldValue('Idle: ' + inferPriorityFromCallstack()),
492
+ Scheduler.log('Idle: ' + inferPriorityFromCallstack()),
493
);
494
495
await waitForAll([
@@ -528,13 +504,9 @@ describe('Scheduler', () => {
504
505
describe('delayed tasks', () => {
506
it('schedules a delayed task', async () => {
531
- scheduleCallback(
532
- NormalPriority,
533
- () => Scheduler.unstable_yieldValue('A'),
534
- {
535
- delay: 1000,
536
- },
537
- );
507
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
508
+ delay: 1000,
509
+ });
510
511
// Should flush nothing, because delay hasn't elapsed
512
await waitForAll([]);
@@ -552,37 +524,21 @@ describe('Scheduler', () => {
524
});
525
526
it('schedules multiple delayed tasks', async () => {
555
- scheduleCallback(
556
- NormalPriority,
557
- () => Scheduler.unstable_yieldValue('C'),
558
- {
559
- delay: 300,
560
- },
561
- );
527
+ scheduleCallback(NormalPriority, () => Scheduler.log('C'), {
528
+ delay: 300,
529
+ });
530
563
- scheduleCallback(
564
- NormalPriority,
565
- () => Scheduler.unstable_yieldValue('B'),
566
- {
567
- delay: 200,
568
- },
569
- );
531
+ scheduleCallback(NormalPriority, () => Scheduler.log('B'), {
532
+ delay: 200,
533
+ });
534
571
- scheduleCallback(
572
- NormalPriority,
573
- () => Scheduler.unstable_yieldValue('D'),
574
- {
575
- delay: 400,
576
- },
577
- );
535
+ scheduleCallback(NormalPriority, () => Scheduler.log('D'), {
536
+ delay: 400,
537
+ });
538
579
- scheduleCallback(
580
- NormalPriority,
581
- () => Scheduler.unstable_yieldValue('A'),
582
- {
583
- delay: 100,
584
- },
585
- );
539
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
540
+ delay: 100,
541
+ });
542
543
// Should flush nothing, because delay hasn't elapsed
544
await waitForAll([]);
@@ -601,32 +557,28 @@ describe('Scheduler', () => {
557
it('interleaves normal tasks and delayed tasks', async () => {
558
// Schedule some high priority callbacks with a delay. When their delay
559
// elapses, they will be the most important callback in the queue.
604
- scheduleCallback(
605
- UserBlockingPriority,
606
- () => Scheduler.unstable_yieldValue('Timer 2'),
607
- {delay: 300},
608
- );
609
- scheduleCallback(
610
- UserBlockingPriority,
611
- () => Scheduler.unstable_yieldValue('Timer 1'),
612
- {delay: 100},
613
- );
560
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 2'), {
561
+ delay: 300,
562
+ });
563
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 1'), {
564
+ delay: 100,
565
+ });
566
567
// Schedule some tasks at default priority.
568
scheduleCallback(NormalPriority, () => {
617
- Scheduler.unstable_yieldValue('A');
569
+ Scheduler.log('A');
570
Scheduler.unstable_advanceTime(100);
571
});
572
scheduleCallback(NormalPriority, () => {
621
- Scheduler.unstable_yieldValue('B');
573
+ Scheduler.log('B');
574
Scheduler.unstable_advanceTime(100);
575
});
576
scheduleCallback(NormalPriority, () => {
625
- Scheduler.unstable_yieldValue('C');
577
+ Scheduler.log('C');
578
Scheduler.unstable_advanceTime(100);
579
});
580
scheduleCallback(NormalPriority, () => {
629
- Scheduler.unstable_yieldValue('D');
581
+ Scheduler.log('D');
582
Scheduler.unstable_advanceTime(100);
583
});
584
@@ -638,16 +590,12 @@ describe('Scheduler', () => {
590
it('interleaves delayed tasks with time-sliced tasks', async () => {
591
// Schedule some high priority callbacks with a delay. When their delay
592
// elapses, they will be the most important callback in the queue.
641
- scheduleCallback(
642
- UserBlockingPriority,
643
- () => Scheduler.unstable_yieldValue('Timer 2'),
644
- {delay: 300},
645
- );
646
- scheduleCallback(
647
- UserBlockingPriority,
648
- () => Scheduler.unstable_yieldValue('Timer 1'),
649
- {delay: 100},
650
- );
593
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 2'), {
594
+ delay: 300,
595
+ });
596
+ scheduleCallback(UserBlockingPriority, () => Scheduler.log('Timer 1'), {
597
+ delay: 100,
598
+ });
599
600
// Schedule a time-sliced task at default priority.
601
const tasks = [
@@ -661,7 +609,7 @@ describe('Scheduler', () => {
609
const task = tasks.shift();
610
const [label, ms] = task;
611
Scheduler.unstable_advanceTime(ms);
664
- Scheduler.unstable_yieldValue(label);
612
+ Scheduler.log(label);
613
if (tasks.length > 0) {
614
return work;
615
}
@@ -678,19 +626,15 @@ describe('Scheduler', () => {
626
// Schedule several tasks with the same delay
627
const options = {delay: 100};
628
681
- scheduleCallback(
682
- NormalPriority,
683
- () => Scheduler.unstable_yieldValue('A'),
684
- options,
685
- );
629
+ scheduleCallback(NormalPriority, () => Scheduler.log('A'), options);
630
const taskB = scheduleCallback(
631
NormalPriority,
688
- () => Scheduler.unstable_yieldValue('B'),
632
+ () => Scheduler.log('B'),
633
options,
634
);
635
const taskC = scheduleCallback(
636
NormalPriority,
693
- () => Scheduler.unstable_yieldValue('C'),
637
+ () => Scheduler.log('C'),
638
options,
639
);
640
@@ -722,11 +666,11 @@ describe('Scheduler', () => {
666
667
it('toFlushUntilNextPaint stops if a continuation is returned', async () => {
668
scheduleCallback(NormalPriority, () => {
725
- Scheduler.unstable_yieldValue('Original Task');
726
- Scheduler.unstable_yieldValue('shouldYield: ' + shouldYield());
727
- Scheduler.unstable_yieldValue('Return a continuation');
669
+ Scheduler.log('Original Task');
670
+ Scheduler.log('shouldYield: ' + shouldYield());
671
+ Scheduler.log('Return a continuation');
672
return () => {
729
- Scheduler.unstable_yieldValue('Continuation Task');
673
+ Scheduler.log('Continuation Task');
674
};
675
});
676
@@ -749,11 +693,11 @@ describe('Scheduler', () => {
693
694
it("toFlushAndYield keeps flushing even if there's a continuation", async () => {
695
scheduleCallback(NormalPriority, () => {
752
- Scheduler.unstable_yieldValue('Original Task');
753
- Scheduler.unstable_yieldValue('shouldYield: ' + shouldYield());
754
- Scheduler.unstable_yieldValue('Return a continuation');
696
+ Scheduler.log('Original Task');
697
+ Scheduler.log('shouldYield: ' + shouldYield());
698
+ Scheduler.log('Return a continuation');
699
return () => {
756
- Scheduler.unstable_yieldValue('Continuation Task');
700
+ Scheduler.log('Continuation Task');
701
};
702
});
703
packages/scheduler/src/__tests__/SchedulerProfiling-test.js
+20
-22
@@ -270,19 +270,19 @@ describe('Scheduler', () => {
270
NormalPriority,
271
() => {
272
Scheduler.unstable_advanceTime(300);
273
- Scheduler.unstable_yieldValue('Yield 1');
273
+ Scheduler.log('Yield 1');
274
scheduleCallback(
275
UserBlockingPriority,
276
() => {
277
- Scheduler.unstable_yieldValue('Yield 2');
277
+ Scheduler.log('Yield 2');
278
Scheduler.unstable_advanceTime(300);
279
},
280
{label: 'Bar'},
281
);
282
Scheduler.unstable_advanceTime(100);
283
- Scheduler.unstable_yieldValue('Yield 3');
283
+ Scheduler.log('Yield 3');
284
return () => {
285
- Scheduler.unstable_yieldValue('Yield 4');
285
+ Scheduler.log('Yield 4');
286
Scheduler.unstable_advanceTime(300);
287
};
288
},
@@ -305,11 +305,11 @@ Task 1 [Normal] │ ████████░░░░░░░
305
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
306
307
const task = scheduleCallback(NormalPriority, () => {
308
- Scheduler.unstable_yieldValue('Yield 1');
308
+ Scheduler.log('Yield 1');
309
Scheduler.unstable_advanceTime(300);
310
- Scheduler.unstable_yieldValue('Yield 2');
310
+ Scheduler.log('Yield 2');
311
return () => {
312
- Scheduler.unstable_yieldValue('Continuation');
312
+ Scheduler.log('Continuation');
313
Scheduler.unstable_advanceTime(200);
314
};
315
});
@@ -354,20 +354,20 @@ Task 1 [Normal] │██████🡐 errored
354
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
355
356
const task1 = scheduleCallback(NormalPriority, () => {
357
- Scheduler.unstable_yieldValue('Yield 1');
357
+ Scheduler.log('Yield 1');
358
Scheduler.unstable_advanceTime(300);
359
- Scheduler.unstable_yieldValue('Yield 2');
359
+ Scheduler.log('Yield 2');
360
return () => {
361
- Scheduler.unstable_yieldValue('Continuation');
361
+ Scheduler.log('Continuation');
362
Scheduler.unstable_advanceTime(200);
363
};
364
});
365
const task2 = scheduleCallback(NormalPriority, () => {
366
- Scheduler.unstable_yieldValue('Yield 3');
366
+ Scheduler.log('Yield 3');
367
Scheduler.unstable_advanceTime(300);
368
- Scheduler.unstable_yieldValue('Yield 4');
368
+ Scheduler.log('Yield 4');
369
return () => {
370
- Scheduler.unstable_yieldValue('Continuation');
370
+ Scheduler.log('Continuation');
371
Scheduler.unstable_advanceTime(200);
372
};
373
});
@@ -397,7 +397,7 @@ Task 2 [Normal] │░░░░░░░░🡐 canceled
397
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
398
399
const task = scheduleCallback(NormalPriority, () => {
400
- Scheduler.unstable_yieldValue('A');
400
+ Scheduler.log('A');
401
Scheduler.unstable_advanceTime(1000);
402
});
403
await waitForAll(['A']);
@@ -416,7 +416,7 @@ Task 1 [Normal] │████████████████
416
scheduleCallback(
417
NormalPriority,
418
() => {
419
- Scheduler.unstable_yieldValue('A');
419
+ Scheduler.log('A');
420
Scheduler.unstable_advanceTime(1000);
421
},
422
{label: 'A'},
@@ -425,7 +425,7 @@ Task 1 [Normal] │████████████████
425
const task = scheduleCallback(
426
NormalPriority,
427
() => {
428
- Scheduler.unstable_yieldValue('B');
428
+ Scheduler.log('B');
429
Scheduler.unstable_advanceTime(1000);
430
},
431
{label: 'B'},
@@ -450,7 +450,7 @@ Task 2 [Normal] │ ░░░░░░░░🡐 canceled
450
NormalPriority,
451
() => {
452
Scheduler.unstable_advanceTime(1000);
453
- Scheduler.unstable_yieldValue('A');
453
+ Scheduler.log('A');
454
},
455
{
456
delay: 1000,
@@ -472,11 +472,9 @@ Task 1 [Normal] │ █████████
472
473
it('handles cancelling a delayed task', async () => {
474
Scheduler.unstable_Profiling.startLoggingProfilingEvents();
475
- const task = scheduleCallback(
476
- NormalPriority,
477
- () => Scheduler.unstable_yieldValue('A'),
478
- {delay: 1000},
479
- );
475
+ const task = scheduleCallback(NormalPriority, () => Scheduler.log('A'), {
476
+ delay: 1000,
477
+ });
478
cancelCallback(task);
479
await waitForAll([]);
480
expect(stopProfilingAndPrintFlamegraph()).toEqual(
packages/scheduler/src/forks/SchedulerMock.js
+4
-4
@@ -606,7 +606,7 @@ function unstable_flushAllWithoutAsserting(): boolean {
606
}
607
}
608
609
-function unstable_clearYields(): Array<mixed> {
609
+function unstable_clearLog(): Array<mixed> {
610
if (yieldedValues === null) {
611
return [];
612
}
@@ -632,7 +632,7 @@ function unstable_flushAll(): void {
632
}
633
}
634
635
-function unstable_yieldValue(value: mixed): void {
635
+function log(value: mixed): void {
636
// eslint-disable-next-line react-internal/no-production-logging
637
if (console.log.name === 'disabledLog' || disableYieldValue) {
638
// If console.log has been patched, we assume we're in render
@@ -687,11 +687,11 @@ export {
687
unstable_flushAllWithoutAsserting,
688
unstable_flushNumberOfYields,
689
unstable_flushExpired,
690
- unstable_clearYields,
690
+ unstable_clearLog,
691
unstable_flushUntilNextPaint,
692
unstable_hasPendingWork,
693
unstable_flushAll,
694
- unstable_yieldValue,
694
+ log,
695
unstable_advanceTime,
696
reset,
697
setDisableYieldValue as unstable_setDisableYieldValue,
packages/shared/forks/Scheduler.umd.js
+2
-2
@@ -34,7 +34,7 @@ const {
34
// on scheduler/unstable_mock, which we'll need inside act()
35
// and for internal testing
36
unstable_flushAllWithoutAsserting,
37
- unstable_yieldValue,
37
+ log,
38
unstable_setDisableYieldValue,
39
} = ReactInternals.Scheduler;
40
@@ -57,6 +57,6 @@ export {
57
unstable_IdlePriority,
58
unstable_forceFrameRate,
59
unstable_flushAllWithoutAsserting,
60
- unstable_yieldValue,
60
+ log,
61
unstable_setDisableYieldValue,
62
};
packages/use-subscription/src/__tests__/useSubscription-test.js
+10
-10
@@ -59,7 +59,7 @@ describe('useSubscription', () => {
59
60
it('supports basic subscription pattern', async () => {
61
function Child({value = 'default'}) {
62
- Scheduler.unstable_yieldValue(value);
62
+ Scheduler.log(value);
63
return null;
64
}
65
@@ -103,7 +103,7 @@ describe('useSubscription', () => {
103
104
it('should support observable types like RxJS ReplaySubject', async () => {
105
function Child({value = 'default'}) {
106
- Scheduler.unstable_yieldValue(value);
106
+ Scheduler.log(value);
107
return null;
108
}
109
@@ -153,7 +153,7 @@ describe('useSubscription', () => {
153
154
it('should unsubscribe from old sources and subscribe to new sources when memoized props change', async () => {
155
function Child({value = 'default'}) {
156
- Scheduler.unstable_yieldValue(value);
156
+ Scheduler.log(value);
157
return null;
158
}
159
@@ -214,7 +214,7 @@ describe('useSubscription', () => {
214
215
it('should unsubscribe from old sources and subscribe to new sources when useCallback functions change', async () => {
216
function Child({value = 'default'}) {
217
- Scheduler.unstable_yieldValue(value);
217
+ Scheduler.log(value);
218
return null;
219
}
220
@@ -274,12 +274,12 @@ describe('useSubscription', () => {
274
const log = [];
275
276
function Grandchild({value}) {
277
- Scheduler.unstable_yieldValue('Grandchild: ' + value);
277
+ Scheduler.log('Grandchild: ' + value);
278
return null;
279
}
280
281
function Child({value = 'default'}) {
282
- Scheduler.unstable_yieldValue('Child: ' + value);
282
+ Scheduler.log('Child: ' + value);
283
return <Grandchild value={value} />;
284
}
285
@@ -377,12 +377,12 @@ describe('useSubscription', () => {
377
const log = [];
378
379
function Grandchild({value}) {
380
- Scheduler.unstable_yieldValue('Grandchild: ' + value);
380
+ Scheduler.log('Grandchild: ' + value);
381
return null;
382
}
383
384
function Child({value = 'default'}) {
385
- Scheduler.unstable_yieldValue('Child: ' + value);
385
+ Scheduler.log('Child: ' + value);
386
return <Grandchild value={value} />;
387
}
388
@@ -481,7 +481,7 @@ describe('useSubscription', () => {
481
482
it('should guard against updates that happen after unmounting', () => {
483
function Child({value = 'default'}) {
484
- Scheduler.unstable_yieldValue(value);
484
+ Scheduler.log(value);
485
return null;
486
}
487
@@ -593,7 +593,7 @@ describe('useSubscription', () => {
593
594
const Subscriber = ({id}) => {
595
const value = useSubscription(subscription);
596
- Scheduler.unstable_yieldValue(`render:${id}:${value}`);
596
+ Scheduler.log(`render:${id}:${value}`);
597
return value;
598
};
599
packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js
+1
-1
@@ -77,7 +77,7 @@ describe('useSyncExternalStore (userspace shim, server rendering)', () => {
77
});
78
79
function Text({text}) {
80
- Scheduler.unstable_yieldValue(text);
80
+ Scheduler.log(text);
81
return text;
82
}
83
packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js
+9
-9
@@ -84,7 +84,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
84
});
85
86
function Text({text}) {
87
- Scheduler.unstable_yieldValue(text);
87
+ Scheduler.log(text);
88
return text;
89
}
90
@@ -288,7 +288,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
288
function App() {
289
const value = useSyncExternalStore(store.subscribe, store.getState);
290
useEffect(() => {
291
- Scheduler.unstable_yieldValue('Passive effect: ' + value);
291
+ Scheduler.log('Passive effect: ' + value);
292
}, [value]);
293
return <Text text={value} />;
294
}
@@ -337,7 +337,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
337
// that changed the getSnapshot in Child2. Child2's effects haven't
338
// fired yet, so it doesn't have access to the latest getSnapshot. So
339
// it can't use the getSnapshot to bail out.
340
- Scheduler.unstable_yieldValue('Update B in commit phase');
340
+ Scheduler.log('Update B in commit phase');
341
store.set({a: value.a, b: 2});
342
}
343
}, [step]);
@@ -397,7 +397,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
397
// that changed the getSnapshot in Child2. Child2's effects haven't
398
// fired yet, so it doesn't have access to the latest getSnapshot. So
399
// it can't use the getSnapshot to bail out.
400
- Scheduler.unstable_yieldValue('Update B in commit phase');
400
+ Scheduler.log('Update B in commit phase');
401
store.set({a: value.a, b: 2});
402
}
403
}, [step]);
@@ -449,7 +449,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
449
const value = useSyncExternalStore(store.subscribe, store.getState);
450
useLayoutEffect(() => {
451
if (value === 1) {
452
- Scheduler.unstable_yieldValue('Reset back to 0');
452
+ Scheduler.log('Reset back to 0');
453
store.set(0);
454
}
455
}, [value]);
@@ -629,12 +629,12 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
629
const store = createExternalStore({a: 0, b: 0});
630
631
function selector(state) {
632
- Scheduler.unstable_yieldValue('Selector');
632
+ Scheduler.log('Selector');
633
return state.a;
634
}
635
636
function App() {
637
- Scheduler.unstable_yieldValue('App');
637
+ Scheduler.log('App');
638
const a = useSyncExternalStoreWithSelector(
639
store.subscribe,
640
store.getState,
@@ -738,7 +738,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
738
() => 'server',
739
);
740
useEffect(() => {
741
- Scheduler.unstable_yieldValue('Passive effect: ' + text);
741
+ Scheduler.log('Passive effect: ' + text);
742
}, [text]);
743
return (
744
<div ref={ref}>
@@ -838,7 +838,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
838
839
function App({step}) {
840
const inlineSelector = state => {
841
- Scheduler.unstable_yieldValue('Inline selector');
841
+ Scheduler.log('Inline selector');
842
return [...state.items, 'C'];
843
};
844
const items = useSyncExternalStoreWithSelector(
packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js
+1
-1
@@ -54,7 +54,7 @@ describe('useSyncExternalStore (userspace shim, server rendering)', () => {
54
});
55
56
function Text({text}) {
57
- Scheduler.unstable_yieldValue(text);
57
+ Scheduler.log(text);
58
return text;
59
}
60
scripts/jest/matchers/reactTestMatchers.js
+7
-6
@@ -1,7 +1,8 @@
1
'use strict';
2
3
const JestReact = require('jest-react');
4
-const SchedulerMatchers = require('./schedulerTestMatchers');
4
+
5
+// TODO: Move to ReactInternalTestUtils
6
7
function captureAssertion(fn) {
8
// Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
@@ -20,12 +21,13 @@ function captureAssertion(fn) {
21
}
22
23
function assertYieldsWereCleared(Scheduler) {
23
- const actualYields = Scheduler.unstable_clearYields();
24
+ const actualYields = Scheduler.unstable_clearLog();
25
if (actualYields.length !== 0) {
25
- throw new Error(
26
- 'Log of yielded values is not empty. ' +
27
- 'Call expect(Scheduler).toHaveYielded(...) first.'
26
+ const error = Error(
27
+ 'The event log is not empty. Call assertLog(...) first.'
28
);
29
+ Error.captureStackTrace(error, assertYieldsWereCleared);
30
+ throw error;
31
}
32
}
33
@@ -41,6 +43,5 @@ function toMatchRenderedOutput(ReactNoop, expectedJSX) {
43
}
44
45
module.exports = {
44
- ...SchedulerMatchers,
46
toMatchRenderedOutput,
47
};
scripts/jest/matchers/schedulerTestMatchers.js
deleted
-96
@@ -1,96 +0,0 @@
1
-'use strict';
2
-
3
-function captureAssertion(fn) {
4
- // Trick to use a Jest matcher inside another Jest matcher. `fn` contains an
5
- // assertion; if it throws, we capture the error and return it, so the stack
6
- // trace presented to the user points to the original assertion in the
7
- // test file.
8
- try {
9
- fn();
10
- } catch (error) {
11
- return {
12
- pass: false,
13
- message: () => error.message,
14
- };
15
- }
16
- return {pass: true};
17
-}
18
-
19
-function assertYieldsWereCleared(Scheduler) {
20
- const actualYields = Scheduler.unstable_clearYields();
21
-
22
- if (actualYields.length !== 0) {
23
- const error = Error(
24
- 'Log of yielded values is not empty. ' +
25
- 'Call expect(Scheduler).toHaveYielded(...) first.'
26
- );
27
- Error.captureStackTrace(error, assertYieldsWereCleared);
28
- throw error;
29
- }
30
-}
31
-
32
-function toFlushAndYield(Scheduler, expectedYields) {
33
- assertYieldsWereCleared(Scheduler);
34
- Scheduler.unstable_flushAllWithoutAsserting();
35
- const actualYields = Scheduler.unstable_clearYields();
36
- return captureAssertion(() => {
37
- expect(actualYields).toEqual(expectedYields);
38
- });
39
-}
40
-
41
-function toFlushAndYieldThrough(Scheduler, expectedYields) {
42
- assertYieldsWereCleared(Scheduler);
43
- Scheduler.unstable_flushNumberOfYields(expectedYields.length);
44
- const actualYields = Scheduler.unstable_clearYields();
45
- return captureAssertion(() => {
46
- expect(actualYields).toEqual(expectedYields);
47
- });
48
-}
49
-
50
-function toFlushUntilNextPaint(Scheduler, expectedYields) {
51
- assertYieldsWereCleared(Scheduler);
52
- Scheduler.unstable_flushUntilNextPaint();
53
- const actualYields = Scheduler.unstable_clearYields();
54
- return captureAssertion(() => {
55
- expect(actualYields).toEqual(expectedYields);
56
- });
57
-}
58
-
59
-function toFlushWithoutYielding(Scheduler) {
60
- return toFlushAndYield(Scheduler, []);
61
-}
62
-
63
-function toFlushExpired(Scheduler, expectedYields) {
64
- assertYieldsWereCleared(Scheduler);
65
- Scheduler.unstable_flushExpired();
66
- const actualYields = Scheduler.unstable_clearYields();
67
- return captureAssertion(() => {
68
- expect(actualYields).toEqual(expectedYields);
69
- });
70
-}
71
-
72
-function toHaveYielded(Scheduler, expectedYields) {
73
- return captureAssertion(() => {
74
- const actualYields = Scheduler.unstable_clearYields();
75
- expect(actualYields).toEqual(expectedYields);
76
- });
77
-}
78
-
79
-function toFlushAndThrow(Scheduler, ...rest) {
80
- assertYieldsWereCleared(Scheduler);
81
- return captureAssertion(() => {
82
- expect(() => {
83
- Scheduler.unstable_flushAllWithoutAsserting();
84
- }).toThrow(...rest);
85
- });
86
-}
87
-
88
-module.exports = {
89
- toFlushAndYield,
90
- toFlushAndYieldThrough,
91
- toFlushUntilNextPaint,
92
- toFlushWithoutYielding,
93
- toFlushExpired,
94
- toHaveYielded,
95
- toFlushAndThrow,
96
-};
scripts/release/snapshot-test.snapshot
+40
-40
@@ -73,12 +73,12 @@ Index: build/node_modules/react/umd/react.development.js
73
*
74
@@ -16,9 +16,9 @@
75
}(this, (function () { 'use strict';
76
-
76
+
77
// TODO: this is special because it gets imported during build.
78
-
78
+
79
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
80
+var ReactVersion = '1.2.3';
81
-
81
+
82
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
83
// nor polyfill, then a plain number is used for performance.
84
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
@@ -132,12 +132,12 @@ Index: build/node_modules/react/cjs/react.development.js
132
*
133
@@ -19,9 +19,9 @@
134
var checkPropTypes = require('prop-types/checkPropTypes');
135
-
135
+
136
// TODO: this is special because it gets imported during build.
137
-
137
+
138
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
139
+var ReactVersion = '1.2.3';
140
-
140
+
141
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
142
// nor polyfill, then a plain number is used for performance.
143
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
@@ -154,12 +154,12 @@ Index: build/node_modules/react-art/umd/react-art.development.js
154
*
155
@@ -20,9 +20,9 @@
156
var _assign = ReactInternals.assign;
157
-
157
+
158
// TODO: this is special because it gets imported during build.
159
-
159
+
160
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
161
+var ReactVersion = '1.2.3';
162
-
162
+
163
/**
164
* Use invariant() to assert state which your program assumes to be true.
165
*
@@ -194,12 +194,12 @@ Index: build/node_modules/react-art/cjs/react-art.development.js
194
*
195
@@ -25,9 +25,9 @@
196
var FastNoSideEffects = require('art/modes/fast-noSideEffects');
197
-
197
+
198
// TODO: this is special because it gets imported during build.
199
-
199
+
200
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
201
+var ReactVersion = '1.2.3';
202
-
202
+
203
/**
204
* Use invariant() to assert state which your program assumes to be true.
205
*
@@ -246,14 +246,14 @@ Index: build/node_modules/react-dom/umd/react-dom-server.browser.development.js
246
*
247
@@ -61,9 +61,9 @@
248
// preserve the format and params in the www builds.
249
-
249
+
250
// TODO: this is special because it gets imported during build.
251
-
251
+
252
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
253
+var ReactVersion = '1.2.3';
254
-
254
+
255
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
256
-
256
+
257
var _assign = ReactInternals.assign;
258
Index: build/node_modules/react-dom/umd/react-dom.production.min.js
259
===================================================================
@@ -327,12 +327,12 @@ Index: build/node_modules/react-dom/umd/react-dom.development.js
327
*
328
@@ -19471,9 +19471,9 @@
329
}
330
-
330
+
331
// TODO: this is special because it gets imported during build.
332
-
332
+
333
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
334
+var ReactVersion = '1.2.3';
335
-
335
+
336
// TODO: This type is shared between the reconciler and ReactDOM, but will
337
// eventually be lifted out to the renderer.
338
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -407,12 +407,12 @@ Index: build/node_modules/react-dom/cjs/react-dom-server.browser.development.js
407
*
408
@@ -65,9 +65,9 @@
409
// preserve the format and params in the www builds.
410
-
410
+
411
// TODO: this is special because it gets imported during build.
412
-
412
+
413
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
414
+var ReactVersion = '1.2.3';
415
-
415
+
416
/**
417
* Similar to invariant but only logs a warning if the condition is not met.
418
* 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
467
*
468
@@ -21,9 +21,9 @@
469
var stream = require('stream');
470
-
470
+
471
// TODO: this is special because it gets imported during build.
472
-
472
+
473
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
474
+var ReactVersion = '1.2.3';
475
-
475
+
476
/**
477
* Use invariant() to assert state which your program assumes to be true.
478
*
@@ -511,12 +511,12 @@ Index: build/node_modules/react-dom/cjs/react-dom.development.js
511
*
512
@@ -19347,9 +19347,9 @@
513
}
514
-
514
+
515
// TODO: this is special because it gets imported during build.
516
-
516
+
517
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
518
+var ReactVersion = '1.2.3';
519
-
519
+
520
// TODO: This type is shared between the reconciler and ReactDOM, but will
521
// eventually be lifted out to the renderer.
522
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -694,14 +694,14 @@ Index: build/node_modules/react-test-renderer/umd/react-test-renderer.developmen
694
*
695
@@ -11622,9 +11622,9 @@
696
}
697
-
697
+
698
// TODO: this is special because it gets imported during build.
699
-
699
+
700
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
701
+var ReactVersion = '1.2.3';
702
-
702
+
703
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; }; }();
704
-
704
+
705
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
706
Index: build/node_modules/react-test-renderer/umd/react-test-renderer.production.min.js
707
===================================================================
@@ -717,8 +717,8 @@ Index: build/node_modules/react-test-renderer/umd/react-test-renderer.production
717
@@ -117,5 +117,5 @@
718
!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?
719
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,
720
- 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)},
721
- 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()");
720
+ 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)},
721
+ 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()");
722
-},bundleType:0,version:"16.6.1-canary-b3d1a81a9",rendererPackageName:"react-test-renderer"});var xd={default:wd},yd=xd&&wd||xd;return yd.default||yd});
723
+},bundleType:0,version:"1.2.3",rendererPackageName:"react-test-renderer"});var xd={default:wd},yd=xd&&wd||xd;return yd.default||yd});
724
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
756
*
757
@@ -11498,9 +11498,9 @@
758
}
759
-
759
+
760
// TODO: this is special because it gets imported during build.
761
-
761
+
762
-var ReactVersion = '16.6.1-canary-b3d1a81a9';
763
+var ReactVersion = '1.2.3';
764
-
764
+
765
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; }; }();
766
-
766
+
767
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
768
Index: build/node_modules/react-test-renderer/cjs/react-test-renderer.production.min.js
769
===================================================================
@@ -779,8 +779,8 @@ Index: build/node_modules/react-test-renderer/cjs/react-test-renderer.production
779
@@ -140,5 +140,5 @@
780
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=
781
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},
782
- 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");
783
- 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}
782
+ 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");
783
+ 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}
784
-(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;
785
+(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;
786
Index: build/node_modules/scheduler/cjs/scheduler.development.js