@samitouri / QOS-React-2 / commits / 4d307de458

Prefix mock Scheduler APIs with _unstable (#15999)

For now this is only meant to be consumed via `act`.

Andrew Clark committed Jun 26, 2019 at 12:16 UTC 4d307de458dfdf25e704cb2ca20b0578bba8998c
60 files changed +1120 -1005
packages/create-subscription/src/__tests__/createSubscription-test.internal.js
+11 -11
@@ -60,7 +60,7 @@ describe('createSubscription', () => {
60 ReactNoop.render(
61 <Subscription source={observable}>
62 {(value = 'default') => {
63 - Scheduler.yieldValue(value);
63 + Scheduler.unstable_yieldValue(value);
64 return null;
65 }}
66 </Subscription>,
@@ -97,7 +97,7 @@ describe('createSubscription', () => {
97 });
98
99 function render(value = 'default') {
100 - Scheduler.yieldValue(value);
100 + Scheduler.unstable_yieldValue(value);
101 return null;
102 }
103
@@ -126,9 +126,9 @@ describe('createSubscription', () => {
126
127 function render(hasLoaded) {
128 if (hasLoaded === undefined) {
129 - Scheduler.yieldValue('loading');
129 + Scheduler.unstable_yieldValue('loading');
130 } else {
131 - Scheduler.yieldValue(hasLoaded ? 'finished' : 'failed');
131 + Scheduler.unstable_yieldValue(hasLoaded ? 'finished' : 'failed');
132 }
133 return null;
134 }
@@ -169,7 +169,7 @@ describe('createSubscription', () => {
169 });
170
171 function render(value = 'default') {
172 - Scheduler.yieldValue(value);
172 + Scheduler.unstable_yieldValue(value);
173 return null;
174 }
175
@@ -203,7 +203,7 @@ describe('createSubscription', () => {
203 });
204
205 function render(hasLoaded) {
206 - Scheduler.yieldValue('rendered');
206 + Scheduler.unstable_yieldValue('rendered');
207 return null;
208 }
209
@@ -235,7 +235,7 @@ describe('createSubscription', () => {
235 });
236
237 function render(value = 'default') {
238 - Scheduler.yieldValue(value);
238 + Scheduler.unstable_yieldValue(value);
239 return null;
240 }
241
@@ -268,7 +268,7 @@ describe('createSubscription', () => {
268 const log = [];
269
270 function Child({value}) {
271 - Scheduler.yieldValue('Child: ' + value);
271 + Scheduler.unstable_yieldValue('Child: ' + value);
272 return null;
273 }
274
@@ -305,7 +305,7 @@ describe('createSubscription', () => {
305 return (
306 <Subscription source={this.state.observed}>
307 {(value = 'default') => {
308 - Scheduler.yieldValue('Subscriber: ' + value);
308 + Scheduler.unstable_yieldValue('Subscriber: ' + value);
309 return <Child value={value} />;
310 }}
311 </Subscription>
@@ -355,7 +355,7 @@ describe('createSubscription', () => {
355 const log = [];
356
357 function Child({value}) {
358 - Scheduler.yieldValue('Child: ' + value);
358 + Scheduler.unstable_yieldValue('Child: ' + value);
359 return null;
360 }
361
@@ -392,7 +392,7 @@ describe('createSubscription', () => {
392 return (
393 <Subscription source={this.state.observed}>
394 {(value = 'default') => {
395 - Scheduler.yieldValue('Subscriber: ' + value);
395 + Scheduler.unstable_yieldValue('Subscriber: ' + value);
396 return <Child value={value} />;
397 }}
398 </Subscription>
packages/react-art/src/__tests__/ReactART-test.js
+1 -1
@@ -359,7 +359,7 @@ describe('ReactART', () => {
359 const CurrentRendererContext = React.createContext(null);
360
361 function Yield(props) {
362 - Scheduler.yieldValue(props.value);
362 + Scheduler.unstable_yieldValue(props.value);
363 return null;
364 }
365
packages/react-cache/src/__tests__/ReactCache-test.internal.js
+10 -10
@@ -45,12 +45,12 @@ describe('ReactCache', () => {
45 listeners = [{resolve, reject}];
46 setTimeout(() => {
47 if (textResourceShouldFail) {
48 - Scheduler.yieldValue(`Promise rejected [${text}]`);
48 + Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
49 status = 'rejected';
50 value = new Error('Failed to load: ' + text);
51 listeners.forEach(listener => listener.reject(value));
52 } else {
53 - Scheduler.yieldValue(`Promise resolved [${text}]`);
53 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
54 status = 'resolved';
55 value = text;
56 listeners.forEach(listener => listener.resolve(value));
@@ -78,7 +78,7 @@ describe('ReactCache', () => {
78 });
79
80 function Text(props) {
81 - Scheduler.yieldValue(props.text);
81 + Scheduler.unstable_yieldValue(props.text);
82 return props.text;
83 }
84
@@ -86,13 +86,13 @@ describe('ReactCache', () => {
86 const text = props.text;
87 try {
88 TextResource.read([props.text, props.ms]);
89 - Scheduler.yieldValue(text);
89 + Scheduler.unstable_yieldValue(text);
90 return text;
91 } catch (promise) {
92 if (typeof promise.then === 'function') {
93 - Scheduler.yieldValue(`Suspend! [${text}]`);
93 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
94 } else {
95 - Scheduler.yieldValue(`Error! [${text}]`);
95 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
96 }
97 throw promise;
98 }
@@ -156,7 +156,7 @@ describe('ReactCache', () => {
156 });
157
158 function App() {
159 - Scheduler.yieldValue('App');
159 + Scheduler.unstable_yieldValue('App');
160 return BadTextResource.read(['Hi', 100]);
161 }
162
@@ -321,13 +321,13 @@ describe('ReactCache', () => {
321 const text = props.text;
322 try {
323 const actualText = BadTextResource.read([props.text, props.ms]);
324 - Scheduler.yieldValue(actualText);
324 + Scheduler.unstable_yieldValue(actualText);
325 return actualText;
326 } catch (promise) {
327 if (typeof promise.then === 'function') {
328 - Scheduler.yieldValue(`Suspend! [${text}]`);
328 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
329 } else {
330 - Scheduler.yieldValue(`Error! [${text}]`);
330 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
331 }
332 throw promise;
333 }
packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js
+1 -1
@@ -623,7 +623,7 @@ describe('ReactHooksInspectionIntegration', () => {
623
624 await LazyFoo;
625
626 - Scheduler.flushAll();
626 + Scheduler.unstable_flushAll();
627
628 let childFiber = renderer.root._currentFiber();
629 let tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js
+14 -14
@@ -85,7 +85,7 @@ describe('ReactDOMFiberAsync', () => {
85 }
86 const root = ReactDOM.unstable_createRoot(container);
87 root.render(<Counter />);
88 - Scheduler.flushAll();
88 + Scheduler.unstable_flushAll();
89 expect(asyncValueRef.current.textContent).toBe('');
90 expect(syncValueRef.current.textContent).toBe('');
91
@@ -97,7 +97,7 @@ describe('ReactDOMFiberAsync', () => {
97
98 // Should flush both updates now.
99 jest.runAllTimers();
100 - Scheduler.flushAll();
100 + Scheduler.unstable_flushAll();
101 expect(asyncValueRef.current.textContent).toBe('hello');
102 expect(syncValueRef.current.textContent).toBe('hello');
103 });
@@ -115,12 +115,12 @@ describe('ReactDOMFiberAsync', () => {
115 const root = ReactDOM.unstable_createRoot(container);
116 root.render(<div>Hi</div>);
117 expect(container.textContent).toEqual('');
118 - Scheduler.flushAll();
118 + Scheduler.unstable_flushAll();
119 expect(container.textContent).toEqual('Hi');
120
121 root.render(<div>Bye</div>);
122 expect(container.textContent).toEqual('Hi');
123 - Scheduler.flushAll();
123 + Scheduler.unstable_flushAll();
124 expect(container.textContent).toEqual('Bye');
125 });
126
@@ -137,12 +137,12 @@ describe('ReactDOMFiberAsync', () => {
137 const root = ReactDOM.unstable_createRoot(container);
138 root.render(<Component />);
139 expect(container.textContent).toEqual('');
140 - Scheduler.flushAll();
140 + Scheduler.unstable_flushAll();
141 expect(container.textContent).toEqual('0');
142
143 instance.setState({step: 1});
144 expect(container.textContent).toEqual('0');
145 - Scheduler.flushAll();
145 + Scheduler.unstable_flushAll();
146 expect(container.textContent).toEqual('1');
147 });
148
@@ -264,7 +264,7 @@ describe('ReactDOMFiberAsync', () => {
264
265 const root = ReactDOM.unstable_createRoot(container);
266 root.render(<Component />);
267 - Scheduler.flushAll();
267 + Scheduler.unstable_flushAll();
268
269 // Updates are async by default
270 instance.push('A');
@@ -287,7 +287,7 @@ describe('ReactDOMFiberAsync', () => {
287 expect(ops).toEqual(['BC']);
288
289 // Flush the async updates
290 - Scheduler.flushAll();
290 + Scheduler.unstable_flushAll();
291 expect(container.textContent).toEqual('ABCD');
292 expect(ops).toEqual(['BC', 'ABCD']);
293 });
@@ -305,13 +305,13 @@ describe('ReactDOMFiberAsync', () => {
305 }
306 const root = ReactDOM.unstable_createRoot(container);
307 root.render(<Counter />);
308 - Scheduler.flushAll();
308 + Scheduler.unstable_flushAll();
309 expect(container.textContent).toEqual('0');
310
311 // Test that a normal update is async
312 inst.increment();
313 expect(container.textContent).toEqual('0');
314 - Scheduler.flushAll();
314 + Scheduler.unstable_flushAll();
315 expect(container.textContent).toEqual('1');
316
317 let ops = [];
@@ -417,7 +417,7 @@ describe('ReactDOMFiberAsync', () => {
417 const root = ReactDOM.unstable_createRoot(container);
418 root.render(<Form />);
419 // Flush
420 - Scheduler.flushAll();
420 + Scheduler.unstable_flushAll();
421
422 let disableButton = disableButtonRef.current;
423 expect(disableButton.tagName).toBe('BUTTON');
@@ -484,7 +484,7 @@ describe('ReactDOMFiberAsync', () => {
484 const root = ReactDOM.unstable_createRoot(container);
485 root.render(<Form />);
486 // Flush
487 - Scheduler.flushAll();
487 + Scheduler.unstable_flushAll();
488
489 let disableButton = disableButtonRef.current;
490 expect(disableButton.tagName).toBe('BUTTON');
@@ -544,7 +544,7 @@ describe('ReactDOMFiberAsync', () => {
544 const root = ReactDOM.unstable_createRoot(container);
545 root.render(<Form />);
546 // Flush
547 - Scheduler.flushAll();
547 + Scheduler.unstable_flushAll();
548
549 let enableButton = enableButtonRef.current;
550 expect(enableButton.tagName).toBe('BUTTON');
@@ -576,7 +576,7 @@ describe('ReactDOMFiberAsync', () => {
576 const root = ReactDOM.unstable_createSyncRoot(container);
577
578 function Text(props) {
579 - Scheduler.yieldValue(props.text);
579 + Scheduler.unstable_yieldValue(props.text);
580 return props.text;
581 }
582
packages/react-dom/src/__tests__/ReactDOMHooks-test.js
+4 -4
@@ -60,7 +60,7 @@ describe('ReactDOMHooks', () => {
60 expect(container.textContent).toBe('1');
61 expect(container2.textContent).toBe('');
62 expect(container3.textContent).toBe('');
63 - Scheduler.flushAll();
63 + Scheduler.unstable_flushAll();
64 expect(container.textContent).toBe('1');
65 expect(container2.textContent).toBe('2');
66 expect(container3.textContent).toBe('3');
@@ -69,7 +69,7 @@ describe('ReactDOMHooks', () => {
69 expect(container.textContent).toBe('2');
70 expect(container2.textContent).toBe('2'); // Not flushed yet
71 expect(container3.textContent).toBe('3'); // Not flushed yet
72 - Scheduler.flushAll();
72 + Scheduler.unstable_flushAll();
73 expect(container.textContent).toBe('2');
74 expect(container2.textContent).toBe('4');
75 expect(container3.textContent).toBe('6');
@@ -137,14 +137,14 @@ describe('ReactDOMHooks', () => {
137 const root = ReactDOM.unstable_createRoot(container);
138 root.render(<Example inputRef={inputRef} labelRef={labelRef} />);
139
140 - Scheduler.flushAll();
140 + Scheduler.unstable_flushAll();
141
142 inputRef.current.value = 'abc';
143 inputRef.current.dispatchEvent(
144 new Event('input', {bubbles: true, cancelable: true}),
145 );
146
147 - Scheduler.flushAll();
147 + Scheduler.unstable_flushAll();
148
149 expect(labelRef.current.innerHTML).toBe('abc');
150 });
packages/react-dom/src/__tests__/ReactDOMRoot-test.js
+26 -26
@@ -29,17 +29,17 @@ describe('ReactDOMRoot', () => {
29 it('renders children', () => {
30 const root = ReactDOM.unstable_createRoot(container);
31 root.render(<div>Hi</div>);
32 - Scheduler.flushAll();
32 + Scheduler.unstable_flushAll();
33 expect(container.textContent).toEqual('Hi');
34 });
35
36 it('unmounts children', () => {
37 const root = ReactDOM.unstable_createRoot(container);
38 root.render(<div>Hi</div>);
39 - Scheduler.flushAll();
39 + Scheduler.unstable_flushAll();
40 expect(container.textContent).toEqual('Hi');
41 root.unmount();
42 - Scheduler.flushAll();
42 + Scheduler.unstable_flushAll();
43 expect(container.textContent).toEqual('');
44 });
45
@@ -51,7 +51,7 @@ describe('ReactDOMRoot', () => {
51 ops.push('inside callback: ' + container.textContent);
52 });
53 ops.push('before committing: ' + container.textContent);
54 - Scheduler.flushAll();
54 + Scheduler.unstable_flushAll();
55 ops.push('after committing: ' + container.textContent);
56 expect(ops).toEqual([
57 'before committing: ',
@@ -64,7 +64,7 @@ describe('ReactDOMRoot', () => {
64 it('resolves `work.then` callback synchronously if the work already committed', () => {
65 const root = ReactDOM.unstable_createRoot(container);
66 const work = root.render('Hi');
67 - Scheduler.flushAll();
67 + Scheduler.unstable_flushAll();
68 let ops = [];
69 work.then(() => {
70 ops.push('inside callback');
@@ -92,7 +92,7 @@ describe('ReactDOMRoot', () => {
92 <span />
93 </div>,
94 );
95 - Scheduler.flushAll();
95 + Scheduler.unstable_flushAll();
96
97 // Accepts `hydrate` option
98 const container2 = document.createElement('div');
@@ -103,7 +103,7 @@ describe('ReactDOMRoot', () => {
103 <span />
104 </div>,
105 );
106 - expect(() => Scheduler.flushAll()).toWarnDev('Extra attributes', {
106 + expect(() => Scheduler.unstable_flushAll()).toWarnDev('Extra attributes', {
107 withoutStack: true,
108 });
109 });
@@ -117,7 +117,7 @@ describe('ReactDOMRoot', () => {
117 <span>d</span>
118 </div>,
119 );
120 - Scheduler.flushAll();
120 + Scheduler.unstable_flushAll();
121 expect(container.textContent).toEqual('abcd');
122 root.render(
123 <div>
@@ -125,7 +125,7 @@ describe('ReactDOMRoot', () => {
125 <span>c</span>
126 </div>,
127 );
128 - Scheduler.flushAll();
128 + Scheduler.unstable_flushAll();
129 expect(container.textContent).toEqual('abdc');
130 });
131
@@ -157,7 +157,7 @@ describe('ReactDOMRoot', () => {
157 const batch = root.createBatch();
158 batch.render(<App />);
159
160 - Scheduler.flushAll();
160 + Scheduler.unstable_flushAll();
161
162 // Hasn't updated yet
163 expect(container.textContent).toEqual('');
@@ -186,7 +186,7 @@ describe('ReactDOMRoot', () => {
186 const batch = root.createBatch();
187 batch.render(<Foo>Hi</Foo>);
188 // Flush all async work.
189 - Scheduler.flushAll();
189 + Scheduler.unstable_flushAll();
190 // Root should complete without committing.
191 expect(ops).toEqual(['Foo']);
192 expect(container.textContent).toEqual('');
@@ -204,7 +204,7 @@ describe('ReactDOMRoot', () => {
204 const batch = root.createBatch();
205 batch.render('Foo');
206
207 - Scheduler.flushAll();
207 + Scheduler.unstable_flushAll();
208
209 // Hasn't updated yet
210 expect(container.textContent).toEqual('');
@@ -244,7 +244,7 @@ describe('ReactDOMRoot', () => {
244 const root = ReactDOM.unstable_createRoot(container);
245 root.render(1);
246
247 - Scheduler.advanceTime(2000);
247 + Scheduler.unstable_advanceTime(2000);
248 // This batch has a later expiration time than the earlier update.
249 const batch = root.createBatch();
250
@@ -252,7 +252,7 @@ describe('ReactDOMRoot', () => {
252 batch.commit();
253 expect(container.textContent).toEqual('');
254
255 - Scheduler.flushAll();
255 + Scheduler.unstable_flushAll();
256 expect(container.textContent).toEqual('1');
257 });
258
@@ -279,7 +279,7 @@ describe('ReactDOMRoot', () => {
279 batch1.render(1);
280
281 // This batch has a later expiration time
282 - Scheduler.advanceTime(2000);
282 + Scheduler.unstable_advanceTime(2000);
283 const batch2 = root.createBatch();
284 batch2.render(2);
285
@@ -298,7 +298,7 @@ describe('ReactDOMRoot', () => {
298 batch1.render(1);
299
300 // This batch has a later expiration time
301 - Scheduler.advanceTime(2000);
301 + Scheduler.unstable_advanceTime(2000);
302 const batch2 = root.createBatch();
303 batch2.render(2);
304
@@ -308,7 +308,7 @@ describe('ReactDOMRoot', () => {
308 expect(container.textContent).toEqual('2');
309
310 batch1.commit();
311 - Scheduler.flushAll();
311 + Scheduler.unstable_flushAll();
312 expect(container.textContent).toEqual('1');
313 });
314
@@ -334,7 +334,7 @@ describe('ReactDOMRoot', () => {
334 it('warns when rendering with legacy API into createRoot() container', () => {
335 const root = ReactDOM.unstable_createRoot(container);
336 root.render(<div>Hi</div>);
337 - Scheduler.flushAll();
337 + Scheduler.unstable_flushAll();
338 expect(container.textContent).toEqual('Hi');
339 expect(() => {
340 ReactDOM.render(<div>Bye</div>, container);
@@ -349,7 +349,7 @@ describe('ReactDOMRoot', () => {
349 ],
350 {withoutStack: true},
351 );
352 - Scheduler.flushAll();
352 + Scheduler.unstable_flushAll();
353 // This works now but we could disallow it:
354 expect(container.textContent).toEqual('Bye');
355 });
@@ -357,7 +357,7 @@ describe('ReactDOMRoot', () => {
357 it('warns when hydrating with legacy API into createRoot() container', () => {
358 const root = ReactDOM.unstable_createRoot(container);
359 root.render(<div>Hi</div>);
360 - Scheduler.flushAll();
360 + Scheduler.unstable_flushAll();
361 expect(container.textContent).toEqual('Hi');
362 expect(() => {
363 ReactDOM.hydrate(<div>Hi</div>, container);
@@ -377,7 +377,7 @@ describe('ReactDOMRoot', () => {
377 it('warns when unmounting with legacy API (no previous content)', () => {
378 const root = ReactDOM.unstable_createRoot(container);
379 root.render(<div>Hi</div>);
380 - Scheduler.flushAll();
380 + Scheduler.unstable_flushAll();
381 expect(container.textContent).toEqual('Hi');
382 let unmounted = false;
383 expect(() => {
@@ -393,10 +393,10 @@ describe('ReactDOMRoot', () => {
393 {withoutStack: true},
394 );
395 expect(unmounted).toBe(false);
396 - Scheduler.flushAll();
396 + Scheduler.unstable_flushAll();
397 expect(container.textContent).toEqual('Hi');
398 root.unmount();
399 - Scheduler.flushAll();
399 + Scheduler.unstable_flushAll();
400 expect(container.textContent).toEqual('');
401 });
402
@@ -406,17 +406,17 @@ describe('ReactDOMRoot', () => {
406 // The rest is the same as test above.
407 const root = ReactDOM.unstable_createRoot(container);
408 root.render(<div>Hi</div>);
409 - Scheduler.flushAll();
409 + Scheduler.unstable_flushAll();
410 expect(container.textContent).toEqual('Hi');
411 let unmounted = false;
412 expect(() => {
413 unmounted = ReactDOM.unmountComponentAtNode(container);
414 }).toWarnDev('Did you mean to call root.unmount()?', {withoutStack: true});
415 expect(unmounted).toBe(false);
416 - Scheduler.flushAll();
416 + Scheduler.unstable_flushAll();
417 expect(container.textContent).toEqual('Hi');
418 root.unmount();
419 - Scheduler.flushAll();
419 + Scheduler.unstable_flushAll();
420 expect(container.textContent).toEqual('');
421 });
422
packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js
+4 -4
@@ -18,7 +18,7 @@ let ReactTestUtils;
18 let forwardRef;
19 let memo;
20 let yieldedValues;
21 -let yieldValue;
21 +let unstable_yieldValue;
22 let clearYields;
23
24 function initModules() {
@@ -32,7 +32,7 @@ function initModules() {
32 memo = React.memo;
33
34 yieldedValues = [];
35 - yieldValue = value => {
35 + unstable_yieldValue = value => {
36 yieldedValues.push(value);
37 };
38 clearYields = () => {
@@ -92,7 +92,7 @@ describe('ReactDOMServerIntegration', () => {
92 });
93
94 function Text({text}) {
95 - yieldValue(text);
95 + unstable_yieldValue(text);
96 return <span>{text}</span>;
97 }
98
@@ -127,7 +127,7 @@ describe('ReactDOMServerIntegration', () => {
127 'comparator functions are not invoked on the server',
128 async render => {
129 const MemoCounter = React.memo(Counter, (oldProps, newProps) => {
130 - yieldValue(
130 + unstable_yieldValue(
131 `Old count: ${oldProps.count}, New count: ${newProps.count}`,
132 );
133 return oldProps.count === newProps.count;
packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+25 -25
@@ -74,7 +74,7 @@ describe('ReactDOMServerPartialHydration', () => {
74 suspend = true;
75 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
76 root.render(<App />);
77 - Scheduler.flushAll();
77 + Scheduler.unstable_flushAll();
78 jest.runAllTimers();
79
80 expect(ref.current).toBe(null);
@@ -83,7 +83,7 @@ describe('ReactDOMServerPartialHydration', () => {
83 suspend = false;
84 resolve();
85 await promise;
86 - Scheduler.flushAll();
86 + Scheduler.unstable_flushAll();
87 jest.runAllTimers();
88
89 // We should now have hydrated with a ref on the existing span.
@@ -242,7 +242,7 @@ describe('ReactDOMServerPartialHydration', () => {
242 suspend = true;
243 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
244 root.render(<App text="Hello" className="hello" />);
245 - Scheduler.flushAll();
245 + Scheduler.unstable_flushAll();
246 jest.runAllTimers();
247
248 expect(ref.current).toBe(null);
@@ -258,7 +258,7 @@ describe('ReactDOMServerPartialHydration', () => {
258
259 // Flushing both of these in the same batch won't be able to hydrate so we'll
260 // probably throw away the existing subtree.
261 - Scheduler.flushAll();
261 + Scheduler.unstable_flushAll();
262 jest.runAllTimers();
263
264 // Pick up the new span. In an ideal implementation this might be the same span
@@ -311,14 +311,14 @@ describe('ReactDOMServerPartialHydration', () => {
311 suspend = true;
312 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
313 root.render(<App text="Hello" className="hello" />);
314 - Scheduler.flushAll();
314 + Scheduler.unstable_flushAll();
315 jest.runAllTimers();
316
317 expect(ref.current).toBe(null);
318
319 // Render an update, but leave it still suspended.
320 root.render(<App text="Hi" className="hi" />);
321 - Scheduler.flushAll();
321 + Scheduler.unstable_flushAll();
322 jest.runAllTimers();
323
324 // Flushing now should delete the existing content and show the fallback.
@@ -332,7 +332,7 @@ describe('ReactDOMServerPartialHydration', () => {
332 resolve();
333 await promise;
334
335 - Scheduler.flushAll();
335 + Scheduler.unstable_flushAll();
336 jest.runAllTimers();
337
338 let span = container.getElementsByTagName('span')[0];
@@ -384,7 +384,7 @@ describe('ReactDOMServerPartialHydration', () => {
384 suspend = true;
385 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
386 root.render(<App text="Hello" className="hello" />);
387 - Scheduler.flushAll();
387 + Scheduler.unstable_flushAll();
388 jest.runAllTimers();
389
390 expect(ref.current).toBe(null);
@@ -393,7 +393,7 @@ describe('ReactDOMServerPartialHydration', () => {
393 root.render(<App text="Hi" className="hi" />);
394
395 // Flushing now should delete the existing content and show the fallback.
396 - Scheduler.flushAll();
396 + Scheduler.unstable_flushAll();
397 jest.runAllTimers();
398
399 expect(container.getElementsByTagName('span').length).toBe(0);
@@ -405,7 +405,7 @@ describe('ReactDOMServerPartialHydration', () => {
405 resolve();
406 await promise;
407
408 - Scheduler.flushAll();
408 + Scheduler.unstable_flushAll();
409 jest.runAllTimers();
410
411 let span = container.getElementsByTagName('span')[0];
@@ -456,7 +456,7 @@ describe('ReactDOMServerPartialHydration', () => {
456 suspend = true;
457 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
458 root.render(<App text="Hello" className="hello" />);
459 - Scheduler.flushAll();
459 + Scheduler.unstable_flushAll();
460 jest.runAllTimers();
461
462 expect(ref.current).toBe(null);
@@ -465,7 +465,7 @@ describe('ReactDOMServerPartialHydration', () => {
465 root.render(<App text="Hi" className="hi" />);
466
467 // Flushing now should delete the existing content and show the fallback.
468 - Scheduler.flushAll();
468 + Scheduler.unstable_flushAll();
469 jest.runAllTimers();
470
471 expect(container.getElementsByTagName('span').length).toBe(0);
@@ -477,7 +477,7 @@ describe('ReactDOMServerPartialHydration', () => {
477 resolve();
478 await promise;
479
480 - Scheduler.flushAll();
480 + Scheduler.unstable_flushAll();
481 jest.runAllTimers();
482
483 let span = container.getElementsByTagName('span')[0];
@@ -537,7 +537,7 @@ describe('ReactDOMServerPartialHydration', () => {
537 <App />
538 </Context.Provider>,
539 );
540 - Scheduler.flushAll();
540 + Scheduler.unstable_flushAll();
541 jest.runAllTimers();
542
543 expect(ref.current).toBe(null);
@@ -557,7 +557,7 @@ describe('ReactDOMServerPartialHydration', () => {
557
558 // Flushing both of these in the same batch won't be able to hydrate so we'll
559 // probably throw away the existing subtree.
560 - Scheduler.flushAll();
560 + Scheduler.unstable_flushAll();
561 jest.runAllTimers();
562
563 // Pick up the new span. In an ideal implementation this might be the same span
@@ -620,7 +620,7 @@ describe('ReactDOMServerPartialHydration', () => {
620 <App />
621 </Context.Provider>,
622 );
623 - Scheduler.flushAll();
623 + Scheduler.unstable_flushAll();
624 jest.runAllTimers();
625
626 expect(ref.current).toBe(null);
@@ -633,7 +633,7 @@ describe('ReactDOMServerPartialHydration', () => {
633 );
634
635 // Flushing now should delete the existing content and show the fallback.
636 - Scheduler.flushAll();
636 + Scheduler.unstable_flushAll();
637 jest.runAllTimers();
638
639 expect(container.getElementsByTagName('span').length).toBe(0);
@@ -645,7 +645,7 @@ describe('ReactDOMServerPartialHydration', () => {
645 resolve();
646 await promise;
647
648 - Scheduler.flushAll();
648 + Scheduler.unstable_flushAll();
649 jest.runAllTimers();
650
651 let span = container.getElementsByTagName('span')[0];
@@ -694,7 +694,7 @@ describe('ReactDOMServerPartialHydration', () => {
694 suspend = false;
695 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
696 root.render(<App />);
697 - Scheduler.flushAll();
697 + Scheduler.unstable_flushAll();
698 jest.runAllTimers();
699
700 expect(container.textContent).toBe('Hello');
@@ -750,7 +750,7 @@ describe('ReactDOMServerPartialHydration', () => {
750 suspend = false;
751 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
752 root.render(<App />);
753 - Scheduler.flushAll();
753 + Scheduler.unstable_flushAll();
754 // This will have exceeded the suspended time so we should timeout.
755 jest.advanceTimersByTime(500);
756 // The boundary should longer be suspended for the middle content
@@ -811,7 +811,7 @@ describe('ReactDOMServerPartialHydration', () => {
811 suspend = false;
812 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
813 root.render(<App />);
814 - Scheduler.flushAll();
814 + Scheduler.unstable_flushAll();
815 // This will have exceeded the suspended time so we should timeout.
816 jest.advanceTimersByTime(500);
817 // The boundary should longer be suspended for the middle content
@@ -887,7 +887,7 @@ describe('ReactDOMServerPartialHydration', () => {
887 suspend = false;
888 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
889 root.render(<App />);
890 - Scheduler.flushAll();
890 + Scheduler.unstable_flushAll();
891 jest.runAllTimers();
892
893 // We're still loading because we're waiting for the server to stream more content.
@@ -903,7 +903,7 @@ describe('ReactDOMServerPartialHydration', () => {
903 // But it is not yet hydrated.
904 expect(ref.current).toBe(null);
905
906 - Scheduler.flushAll();
906 + Scheduler.unstable_flushAll();
907 jest.runAllTimers();
908
909 // Now it's hydrated.
@@ -980,7 +980,7 @@ describe('ReactDOMServerPartialHydration', () => {
980 suspend = false;
981 let root = ReactDOM.unstable_createRoot(container, {hydrate: true});
982 root.render(<App />);
983 - Scheduler.flushAll();
983 + Scheduler.unstable_flushAll();
984 jest.runAllTimers();
985
986 // We're still loading because we're waiting for the server to stream more content.
@@ -994,7 +994,7 @@ describe('ReactDOMServerPartialHydration', () => {
994 expect(container.textContent).toBe('Loading...');
995 expect(ref.current).toBe(null);
996
997 - Scheduler.flushAll();
997 + Scheduler.unstable_flushAll();
998 jest.runAllTimers();
999
1000 // Hydrating should've generated an error and replaced the suspense boundary.
packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js
+3 -3
@@ -96,7 +96,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
96
97 await advanceTimers(500);
98
99 - Scheduler.flushAll();
99 + Scheduler.unstable_flushAll();
100
101 expect(window.getComputedStyle(divs[0].current).display).toEqual('block');
102 expect(window.getComputedStyle(divs[1].current).display).toEqual('block');
@@ -119,7 +119,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
119
120 await advanceTimers(500);
121
122 - Scheduler.flushAll();
122 + Scheduler.unstable_flushAll();
123
124 expect(container.textContent).toEqual('ABC');
125 });
@@ -168,7 +168,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
168
169 await advanceTimers(500);
170
171 - Scheduler.flushAll();
171 + Scheduler.unstable_flushAll();
172
173 expect(container.innerHTML).toEqual(
174 '<span style="display: inline;">Sibling</span><span style="">Async</span>',
packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
+1 -1
@@ -500,7 +500,7 @@ describe('ReactDOMServerHydration', () => {
500
501 jest.runAllTimers();
502 await Promise.resolve();
503 - Scheduler.flushAll();
503 + Scheduler.unstable_flushAll();
504 expect(element.textContent).toBe('Hello world');
505 });
506 });
packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js
+7 -7
@@ -71,7 +71,7 @@ function runActTests(label, render, unmount) {
71 it('can use act to flush effects', () => {
72 function App() {
73 React.useEffect(() => {
74 - Scheduler.yieldValue(100);
74 + Scheduler.unstable_yieldValue(100);
75 });
76 return null;
77 }
@@ -87,7 +87,7 @@ function runActTests(label, render, unmount) {
87 function App() {
88 let [ctr, setCtr] = React.useState(0);
89 React.useEffect(() => {
90 - Scheduler.yieldValue(ctr);
90 + Scheduler.unstable_yieldValue(ctr);
91 });
92 return (
93 <button id="button" onClick={() => setCtr(x => x + 1)}>
@@ -140,7 +140,7 @@ function runActTests(label, render, unmount) {
140 it('should flush effects only on exiting the outermost act', () => {
141 function App() {
142 React.useEffect(() => {
143 - Scheduler.yieldValue(0);
143 + Scheduler.unstable_yieldValue(0);
144 });
145 return null;
146 }
@@ -390,7 +390,7 @@ function runActTests(label, render, unmount) {
390 something();
391 }, []);
392 React.useEffect(() => {
393 - Scheduler.yieldValue(state);
393 + Scheduler.unstable_yieldValue(state);
394 });
395 return state;
396 }
@@ -415,7 +415,7 @@ function runActTests(label, render, unmount) {
415 }
416 React.useEffect(
417 () => {
418 - Scheduler.yieldValue(state);
418 + Scheduler.unstable_yieldValue(state);
419 ticker();
420 },
421 [Math.min(state, 4)],
@@ -564,7 +564,7 @@ function runActTests(label, render, unmount) {
564 it('should cleanup after errors - sync', () => {
565 function App() {
566 React.useEffect(() => {
567 - Scheduler.yieldValue('oh yes');
567 + Scheduler.unstable_yieldValue('oh yes');
568 });
569 return null;
570 }
@@ -590,7 +590,7 @@ function runActTests(label, render, unmount) {
590 function App() {
591 async function somethingAsync() {
592 await null;
593 - Scheduler.yieldValue('oh yes');
593 + Scheduler.unstable_yieldValue('oh yes');
594 }
595 React.useEffect(() => {
596 somethingAsync();
packages/react-dom/src/__tests__/ReactUpdates-test.js
+7 -7
@@ -1296,7 +1296,7 @@ describe('ReactUpdates', () => {
1296 const container = document.createElement('div');
1297
1298 function Baz() {
1299 - Scheduler.yieldValue('Baz');
1299 + Scheduler.unstable_yieldValue('Baz');
1300 return <p>baz</p>;
1301 }
1302
@@ -1304,14 +1304,14 @@ describe('ReactUpdates', () => {
1304 function Bar() {
1305 const [counter, _setCounter] = React.useState(0);
1306 setCounter = _setCounter;
1307 - Scheduler.yieldValue('Bar');
1307 + Scheduler.unstable_yieldValue('Bar');
1308 return <p>bar {counter}</p>;
1309 }
1310
1311 function Foo() {
1312 - Scheduler.yieldValue('Foo');
1312 + Scheduler.unstable_yieldValue('Foo');
1313 React.useEffect(() => {
1314 - Scheduler.yieldValue('Foo#effect');
1314 + Scheduler.unstable_yieldValue('Foo#effect');
1315 });
1316 return (
1317 <div>
@@ -1608,7 +1608,7 @@ describe('ReactUpdates', () => {
1608 const [step, setStep] = React.useState(0);
1609 React.useEffect(() => {
1610 setStep(x => x + 1);
1611 - Scheduler.yieldValue(step);
1611 + Scheduler.unstable_yieldValue(step);
1612 });
1613 return step;
1614 }
@@ -1653,7 +1653,7 @@ describe('ReactUpdates', () => {
1653 React.useEffect(() => {
1654 if (step < LIMIT) {
1655 setStep(x => x + 1);
1656 - Scheduler.yieldValue(step);
1656 + Scheduler.unstable_yieldValue(step);
1657 }
1658 });
1659 return step;
@@ -1690,7 +1690,7 @@ describe('ReactUpdates', () => {
1690 for (let i = 0; i < 1000; i++) {
1691 setStep(x => x + 1);
1692 }
1693 - Scheduler.yieldValue('Done');
1693 + Scheduler.unstable_yieldValue('Done');
1694 }, []);
1695 return step;
1696 }
packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.internal.js
+8 -8
@@ -521,7 +521,7 @@ describe('ChangeEventPlugin', () => {
521 expect(ops).toEqual([]);
522 expect(input).toBe(undefined);
523 // Flush callbacks.
524 - Scheduler.flushAll();
524 + Scheduler.unstable_flushAll();
525 expect(ops).toEqual(['render: initial']);
526 expect(input.value).toBe('initial');
527
@@ -571,7 +571,7 @@ describe('ChangeEventPlugin', () => {
571 expect(ops).toEqual([]);
572 expect(input).toBe(undefined);
573 // Flush callbacks.
574 - Scheduler.flushAll();
574 + Scheduler.unstable_flushAll();
575 expect(ops).toEqual(['render: false']);
576 expect(input.checked).toBe(false);
577
@@ -587,7 +587,7 @@ describe('ChangeEventPlugin', () => {
587
588 // Now let's make sure we're using the controlled value.
589 root.render(<ControlledInput reverse={true} />);
590 - Scheduler.flushAll();
590 + Scheduler.unstable_flushAll();
591
592 ops = [];
593
@@ -630,7 +630,7 @@ describe('ChangeEventPlugin', () => {
630 expect(ops).toEqual([]);
631 expect(textarea).toBe(undefined);
632 // Flush callbacks.
633 - Scheduler.flushAll();
633 + Scheduler.unstable_flushAll();
634 expect(ops).toEqual(['render: initial']);
635 expect(textarea.value).toBe('initial');
636
@@ -681,7 +681,7 @@ describe('ChangeEventPlugin', () => {
681 expect(ops).toEqual([]);
682 expect(input).toBe(undefined);
683 // Flush callbacks.
684 - Scheduler.flushAll();
684 + Scheduler.unstable_flushAll();
685 expect(ops).toEqual(['render: initial']);
686 expect(input.value).toBe('initial');
687
@@ -732,7 +732,7 @@ describe('ChangeEventPlugin', () => {
732 expect(ops).toEqual([]);
733 expect(input).toBe(undefined);
734 // Flush callbacks.
735 - Scheduler.flushAll();
735 + Scheduler.unstable_flushAll();
736 expect(ops).toEqual(['render: initial']);
737 expect(input.value).toBe('initial');
738
@@ -747,7 +747,7 @@ describe('ChangeEventPlugin', () => {
747 expect(input.value).toBe('initial');
748
749 // Flush callbacks.
750 - Scheduler.flushAll();
750 + Scheduler.unstable_flushAll();
751 // Now the click update has flushed.
752 expect(ops).toEqual(['render: ']);
753 expect(input.value).toBe('');
@@ -792,7 +792,7 @@ describe('ChangeEventPlugin', () => {
792 target.current.dispatchEvent(mouseOverEvent);
793
794 // 3s should be enough to expire the updates
795 - Scheduler.advanceTime(3000);
795 + Scheduler.unstable_advanceTime(3000);
796 expect(container.textContent).toEqual('hovered');
797 });
798 });
packages/react-dom/src/events/__tests__/SimpleEventPlugin-test.internal.js
+5 -5
@@ -275,7 +275,7 @@ describe('SimpleEventPlugin', function() {
275 expect(ops).toEqual([]);
276 expect(button).toBe(undefined);
277 // Flush async work
278 - Scheduler.flushAll();
278 + Scheduler.unstable_flushAll();
279 expect(ops).toEqual(['render button: enabled']);
280
281 ops = [];
@@ -315,7 +315,7 @@ describe('SimpleEventPlugin', function() {
315 click();
316 click();
317 click();
318 - Scheduler.flushAll();
318 + Scheduler.unstable_flushAll();
319 expect(ops).toEqual([]);
320 });
321
@@ -346,7 +346,7 @@ describe('SimpleEventPlugin', function() {
346 // Should not have flushed yet because it's async
347 expect(button).toBe(undefined);
348 // Flush async work
349 - Scheduler.flushAll();
349 + Scheduler.unstable_flushAll();
350 expect(button.textContent).toEqual('Count: 0');
351
352 function click() {
@@ -369,7 +369,7 @@ describe('SimpleEventPlugin', function() {
369 click();
370
371 // Flush the remaining work
372 - Scheduler.flushAll();
372 + Scheduler.unstable_flushAll();
373 // The counter should equal the total number of clicks
374 expect(button.textContent).toEqual('Count: 7');
375 });
@@ -385,7 +385,7 @@ describe('SimpleEventPlugin', function() {
385 const text = `High-pri count: ${
386 this.props.highPriCount
387 }, Low-pri count: ${this.state.lowPriCount}`;
388 - Scheduler.yieldValue(text);
388 + Scheduler.unstable_yieldValue(text);
389 return (
390 <button
391 ref={el => (button = el)}
packages/react-dom/src/test-utils/ReactTestUtilsAct.js
+1 -1
@@ -45,7 +45,7 @@ const {ReactCurrentActingRendererSigil} = ReactSharedInternals;
45
46 let hasWarnedAboutMissingMockScheduler = false;
47 const flushWork =
48 - Scheduler.unstable_flushWithoutYielding ||
48 + Scheduler.unstable_flushAllWithoutAsserting ||
49 function() {
50 if (warnAboutMissingMockScheduler === true) {
51 if (hasWarnedAboutMissingMockScheduler === false) {
packages/react-events/src/dom/__tests__/Hover-test.internal.js
+1 -1
@@ -301,7 +301,7 @@ describe('Hover event responder', () => {
301 target.current.dispatchEvent(createEvent('mouseover'));
302
303 // 3s should be enough to expire the updates
304 - Scheduler.advanceTime(3000);
304 + Scheduler.unstable_advanceTime(3000);
305 expect(newContainer.textContent).toEqual('hovered');
306 });
307 });
packages/react-events/src/dom/__tests__/Press-test.internal.js
+8 -8
@@ -2732,7 +2732,7 @@ describe('Event responder: Press', () => {
2732 const root = ReactDOM.unstable_createRoot(newContainer);
2733 document.body.appendChild(newContainer);
2734 root.render(<MyComponent />);
2735 - Scheduler.flushAll();
2735 + Scheduler.unstable_flushAll();
2736
2737 dispatchEventWithTimeStamp(ref.current, 'pointerdown', 100);
2738 dispatchEventWithTimeStamp(ref.current, 'pointerup', 100);
@@ -2743,7 +2743,7 @@ describe('Event responder: Press', () => {
2743 } else {
2744 expect(renderCounts).toBe(1);
2745 }
2746 - Scheduler.flushAll();
2746 + Scheduler.unstable_flushAll();
2747 if (__DEV__) {
2748 expect(renderCounts).toBe(4);
2749 } else {
@@ -2761,7 +2761,7 @@ describe('Event responder: Press', () => {
2761 expect(renderCounts).toBe(3);
2762 }
2763
2764 - Scheduler.flushAll();
2764 + Scheduler.unstable_flushAll();
2765 document.body.removeChild(newContainer);
2766 });
2767
@@ -2798,7 +2798,7 @@ describe('Event responder: Press', () => {
2798 const root = ReactDOM.unstable_createRoot(newContainer);
2799 document.body.appendChild(newContainer);
2800 root.render(<MyComponent />);
2801 - Scheduler.flushAll();
2801 + Scheduler.unstable_flushAll();
2802
2803 dispatchEventWithTimeStamp(ref.current, 'pointerdown', 100);
2804 dispatchEventWithTimeStamp(ref.current, 'pointerup', 100);
@@ -2809,7 +2809,7 @@ describe('Event responder: Press', () => {
2809 } else {
2810 expect(renderCounts).toBe(2);
2811 }
2812 - Scheduler.flushAll();
2812 + Scheduler.unstable_flushAll();
2813 if (__DEV__) {
2814 expect(renderCounts).toBe(6);
2815 } else {
@@ -2827,7 +2827,7 @@ describe('Event responder: Press', () => {
2827 expect(renderCounts).toBe(4);
2828 }
2829
2830 - Scheduler.flushAll();
2830 + Scheduler.unstable_flushAll();
2831 document.body.removeChild(newContainer);
2832 });
2833
@@ -2873,13 +2873,13 @@ describe('Event responder: Press', () => {
2873 const root = ReactDOM.unstable_createRoot(newContainer);
2874
2875 root.render(<MyComponent />);
2876 - Scheduler.flushAll();
2876 + Scheduler.unstable_flushAll();
2877 expect(newContainer.textContent).toEqual('Presses: 0, Clicks: 0');
2878
2879 dispatchEventWithTimeStamp(button.current, 'pointerdown', 100);
2880 dispatchEventWithTimeStamp(button.current, 'pointerup', 100);
2881 dispatchEventWithTimeStamp(button.current, 'click', 100);
2882 - Scheduler.flushAll();
2882 + Scheduler.unstable_flushAll();
2883 expect(newContainer.textContent).toEqual('Presses: 1, Clicks: 1');
2884
2885 expect(ops).toEqual(['Presses: 0, Clicks: 0']);
packages/react-noop-renderer/src/createReactNoop.js
+4 -4
@@ -662,7 +662,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
662
663 let hasWarnedAboutMissingMockScheduler = false;
664 const flushWork =
665 - Scheduler.unstable_flushWithoutYielding ||
665 + Scheduler.unstable_flushAllWithoutAsserting ||
666 function() {
667 if (warnAboutMissingMockScheduler === true) {
668 if (hasWarnedAboutMissingMockScheduler === false) {
@@ -1108,7 +1108,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
1108 hostUpdateCounter = 0;
1109 hostCloneCounter = 0;
1110 try {
1111 - Scheduler.flushAll();
1111 + Scheduler.unstable_flushAll();
1112 return useMutation
1113 ? {
1114 hostDiffCounter,
@@ -1125,7 +1125,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
1125 }
1126 },
1127
1128 - expire: Scheduler.advanceTime,
1128 + expire: Scheduler.unstable_advanceTime,
1129
1130 flushExpired(): Array<mixed> {
1131 return Scheduler.unstable_flushExpired();
@@ -1261,7 +1261,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
1261 _next: null,
1262 };
1263 root.firstBatch = batch;
1264 - Scheduler.unstable_flushWithoutYielding();
1264 + Scheduler.unstable_flushAllWithoutAsserting();
1265 const actual = Scheduler.unstable_clearYields();
1266 expect(actual).toEqual(expectedFlush);
1267 return (expectedCommit: Array<mixed>) => {
packages/react-reconciler/src/__tests__/ErrorBoundaryReconciliation-test.internal.js
+2 -2
@@ -58,7 +58,7 @@ describe('ErrorBoundaryReconciliation', () => {
58 </ErrorBoundary>,
59 {unstable_isConcurrent: isConcurrent},
60 );
61 - Scheduler.flushAll();
61 + Scheduler.unstable_flushAll();
62 expect(renderer).toMatchRenderedOutput(<span prop="BrokenRender" />);
63
64 expect(() => {
@@ -67,7 +67,7 @@ describe('ErrorBoundaryReconciliation', () => {
67 <BrokenRender fail={true} />
68 </ErrorBoundary>,
69 );
70 - Scheduler.flushAll();
70 + Scheduler.unstable_flushAll();
71 }).toWarnDev(isConcurrent ? ['invalid', 'invalid'] : ['invalid']);
72 const Fallback = fallbackTagName;
73 expect(renderer).toMatchRenderedOutput(<Fallback prop="ErrorBoundary" />);
packages/react-reconciler/src/__tests__/ReactBatchedMode-test.internal.js
+6 -6
@@ -21,7 +21,7 @@ describe('ReactBatchedMode', () => {
21 TextResource = ReactCache.unstable_createResource(([text, ms = 0]) => {
22 return new Promise((resolve, reject) =>
23 setTimeout(() => {
24 - Scheduler.yieldValue(`Promise resolved [${text}]`);
24 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
25 resolve(text);
26 }, ms),
27 );
@@ -29,7 +29,7 @@ describe('ReactBatchedMode', () => {
29 });
30
31 function Text(props) {
32 - Scheduler.yieldValue(props.text);
32 + Scheduler.unstable_yieldValue(props.text);
33 return props.text;
34 }
35
@@ -37,13 +37,13 @@ describe('ReactBatchedMode', () => {
37 const text = props.text;
38 try {
39 TextResource.read([props.text, props.ms]);
40 - Scheduler.yieldValue(text);
40 + Scheduler.unstable_yieldValue(text);
41 return props.text;
42 } catch (promise) {
43 if (typeof promise.then === 'function') {
44 - Scheduler.yieldValue(`Suspend! [${text}]`);
44 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
45 } else {
46 - Scheduler.yieldValue(`Error! [${text}]`);
46 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
47 }
48 throw promise;
49 }
@@ -73,7 +73,7 @@ describe('ReactBatchedMode', () => {
73
74 function App() {
75 useLayoutEffect(() => {
76 - Scheduler.yieldValue('Layout effect');
76 + Scheduler.unstable_yieldValue('Layout effect');
77 });
78 return <Text text="Hi" />;
79 }
packages/react-reconciler/src/__tests__/ReactExpiration-test.internal.js
+17 -17
@@ -51,13 +51,13 @@ describe('ReactExpiration', () => {
51 it('two updates of like priority in the same event always flush within the same batch', () => {
52 class Text extends React.Component {
53 componentDidMount() {
54 - Scheduler.yieldValue(`${this.props.text} [commit]`);
54 + Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
55 }
56 componentDidUpdate() {
57 - Scheduler.yieldValue(`${this.props.text} [commit]`);
57 + Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
58 }
59 render() {
60 - Scheduler.yieldValue(`${this.props.text} [render]`);
60 + Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
61 return <span prop={this.props.text} />;
62 }
63 }
@@ -72,7 +72,7 @@ describe('ReactExpiration', () => {
72 // Schedule an update.
73 ReactNoop.render(<Text text="A" />);
74 // Advance the timer.
75 - Scheduler.advanceTime(2000);
75 + Scheduler.unstable_advanceTime(2000);
76 // Partially flush the the first update, then interrupt it.
77 expect(Scheduler).toFlushAndYieldThrough(['A [render]']);
78 interrupt();
@@ -100,7 +100,7 @@ describe('ReactExpiration', () => {
100 // Now do the same thing again, except this time don't flush any work in
101 // between the two updates.
102 ReactNoop.render(<Text text="A" />);
103 - Scheduler.advanceTime(2000);
103 + Scheduler.unstable_advanceTime(2000);
104 expect(Scheduler).toHaveYielded([]);
105 expect(ReactNoop.getChildren()).toEqual([span('B')]);
106 // Schedule another update.
@@ -116,13 +116,13 @@ describe('ReactExpiration', () => {
116 () => {
117 class Text extends React.Component {
118 componentDidMount() {
119 - Scheduler.yieldValue(`${this.props.text} [commit]`);
119 + Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
120 }
121 componentDidUpdate() {
122 - Scheduler.yieldValue(`${this.props.text} [commit]`);
122 + Scheduler.unstable_yieldValue(`${this.props.text} [commit]`);
123 }
124 render() {
125 - Scheduler.yieldValue(`${this.props.text} [render]`);
125 + Scheduler.unstable_yieldValue(`${this.props.text} [render]`);
126 return <span prop={this.props.text} />;
127 }
128 }
@@ -137,7 +137,7 @@ describe('ReactExpiration', () => {
137 // Schedule an update.
138 ReactNoop.render(<Text text="A" />);
139 // Advance the timer.
140 - Scheduler.advanceTime(2000);
140 + Scheduler.unstable_advanceTime(2000);
141 // Partially flush the the first update, then interrupt it.
142 expect(Scheduler).toFlushAndYieldThrough(['A [render]']);
143 interrupt();
@@ -165,7 +165,7 @@ describe('ReactExpiration', () => {
165 // Now do the same thing again, except this time don't flush any work in
166 // between the two updates.
167 ReactNoop.render(<Text text="A" />);
168 - Scheduler.advanceTime(2000);
168 + Scheduler.unstable_advanceTime(2000);
169 expect(Scheduler).toHaveYielded([]);
170 expect(ReactNoop.getChildren()).toEqual([span('B')]);
171
@@ -188,17 +188,17 @@ describe('ReactExpiration', () => {
188 state = {text: store.text};
189 componentDidMount() {
190 subscribers.push(this);
191 - Scheduler.yieldValue(
191 + Scheduler.unstable_yieldValue(
192 `${this.state.text} [${this.props.label}] [commit]`,
193 );
194 }
195 componentDidUpdate() {
196 - Scheduler.yieldValue(
196 + Scheduler.unstable_yieldValue(
197 `${this.state.text} [${this.props.label}] [commit]`,
198 );
199 }
200 render() {
201 - Scheduler.yieldValue(
201 + Scheduler.unstable_yieldValue(
202 `${this.state.text} [${this.props.label}] [render]`,
203 );
204 return <span prop={this.state.text} />;
@@ -255,7 +255,7 @@ describe('ReactExpiration', () => {
255 // Before importing the renderer, advance the current time by a number
256 // larger than the maximum allowed for bitwise operations.
257 const maxSigned31BitInt = 1073741823;
258 - Scheduler.advanceTime(maxSigned31BitInt * 100);
258 + Scheduler.unstable_advanceTime(maxSigned31BitInt * 100);
259
260 // Now import the renderer. On module initialization, it will read the
261 // current time.
@@ -268,7 +268,7 @@ describe('ReactExpiration', () => {
268 expect(ReactNoop).toMatchRenderedOutput(null);
269
270 // Advance the time some more to expire the update.
271 - Scheduler.advanceTime(10000);
271 + Scheduler.unstable_advanceTime(10000);
272 expect(Scheduler).toFlushExpired([]);
273 expect(ReactNoop).toMatchRenderedOutput('Hi');
274 });
@@ -279,7 +279,7 @@ describe('ReactExpiration', () => {
279 // default to 0, and most tests don't advance time.
280
281 // Before scheduling an update, advance the current time.
282 - Scheduler.advanceTime(10000);
282 + Scheduler.unstable_advanceTime(10000);
283
284 ReactNoop.render('Hi');
285 expect(Scheduler).toFlushExpired([]);
@@ -287,7 +287,7 @@ describe('ReactExpiration', () => {
287
288 // Advancing by ~5 seconds should be sufficient to expire the update. (I
289 // used a slightly larger number to allow for possible rounding.)
290 - Scheduler.advanceTime(6000);
290 + Scheduler.unstable_advanceTime(6000);
291
292 ReactNoop.render('Hi');
293 expect(Scheduler).toFlushExpired([]);
packages/react-reconciler/src/__tests__/ReactFiberEvents-test-internal.js
+2 -2
@@ -799,12 +799,12 @@ describe('ReactFiberEvents', () => {
799 };
800
801 function Async() {
802 - Scheduler.yieldValue('Suspend!');
802 + Scheduler.unstable_yieldValue('Suspend!');
803 throw thenable;
804 }
805
806 function Text(props) {
807 - Scheduler.yieldValue(props.text);
807 + Scheduler.unstable_yieldValue(props.text);
808 return props.text;
809 }
810
packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
+31 -25
@@ -60,7 +60,7 @@ describe('ReactHooks', () => {
60 const {useState, useLayoutEffect} = React;
61
62 function Child({text}) {
63 - Scheduler.yieldValue('Child: ' + text);
63 + Scheduler.unstable_yieldValue('Child: ' + text);
64 return text;
65 }
66
@@ -73,9 +73,9 @@ describe('ReactHooks', () => {
73 setCounter2 = _setCounter2;
74
75 const text = `${counter1}, ${counter2}`;
76 - Scheduler.yieldValue(`Parent: ${text}`);
76 + Scheduler.unstable_yieldValue(`Parent: ${text}`);
77 useLayoutEffect(() => {
78 - Scheduler.yieldValue(`Effect: ${text}`);
78 + Scheduler.unstable_yieldValue(`Effect: ${text}`);
79 });
80 return <Child text={text} />;
81 }
@@ -169,7 +169,7 @@ describe('ReactHooks', () => {
169 const {useState, memo} = React;
170
171 function Child({text}) {
172 - Scheduler.yieldValue('Child: ' + text);
172 + Scheduler.unstable_yieldValue('Child: ' + text);
173 return text;
174 }
175
@@ -182,7 +182,7 @@ describe('ReactHooks', () => {
182 setCounter2 = _setCounter2;
183
184 const text = `${counter1}, ${counter2} (${theme})`;
185 - Scheduler.yieldValue(`Parent: ${text}`);
185 + Scheduler.unstable_yieldValue(`Parent: ${text}`);
186 return <Child text={text} />;
187 }
188
@@ -254,7 +254,7 @@ describe('ReactHooks', () => {
254 const [counter, _setCounter] = useState(0);
255 setCounter = _setCounter;
256
257 - Scheduler.yieldValue(`Count: ${counter}`);
257 + Scheduler.unstable_yieldValue(`Count: ${counter}`);
258 return counter;
259 }
260
@@ -288,7 +288,7 @@ describe('ReactHooks', () => {
288 const [counter, _dispatch] = useReducer((s, a) => a, 0);
289 dispatch = _dispatch;
290
291 - Scheduler.yieldValue(`Count: ${counter}`);
291 + Scheduler.unstable_yieldValue(`Count: ${counter}`);
292 return counter;
293 }
294
@@ -322,7 +322,7 @@ describe('ReactHooks', () => {
322 let setTheme;
323 function ThemeProvider({children}) {
324 const [theme, _setTheme] = useState('light');
325 - Scheduler.yieldValue('Theme: ' + theme);
325 + Scheduler.unstable_yieldValue('Theme: ' + theme);
326 setTheme = _setTheme;
327 return (
328 <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>
@@ -330,7 +330,7 @@ describe('ReactHooks', () => {
330 }
331
332 function Child({text}) {
333 - Scheduler.yieldValue('Child: ' + text);
333 + Scheduler.unstable_yieldValue('Child: ' + text);
334 return text;
335 }
336
@@ -342,9 +342,9 @@ describe('ReactHooks', () => {
342 const theme = useContext(ThemeContext);
343
344 const text = `${counter} (${theme})`;
345 - Scheduler.yieldValue(`Parent: ${text}`);
345 + Scheduler.unstable_yieldValue(`Parent: ${text}`);
346 useLayoutEffect(() => {
347 - Scheduler.yieldValue(`Effect: ${text}`);
347 + Scheduler.unstable_yieldValue(`Effect: ${text}`);
348 });
349 return <Child text={text} />;
350 }
@@ -405,7 +405,7 @@ describe('ReactHooks', () => {
405 const {useState, useLayoutEffect} = React;
406
407 function Child({text}) {
408 - Scheduler.yieldValue('Child: ' + text);
408 + Scheduler.unstable_yieldValue('Child: ' + text);
409 return text;
410 }
411
@@ -413,9 +413,9 @@ describe('ReactHooks', () => {
413 function Parent() {
414 const [counter, _setCounter] = useState(0);
415 setCounter = _setCounter;
416 - Scheduler.yieldValue('Parent: ' + counter);
416 + Scheduler.unstable_yieldValue('Parent: ' + counter);
417 useLayoutEffect(() => {
418 - Scheduler.yieldValue('Effect: ' + counter);
418 + Scheduler.unstable_yieldValue('Effect: ' + counter);
419 });
420 return <Child text={counter} />;
421 }
@@ -483,7 +483,7 @@ describe('ReactHooks', () => {
483 const {useState} = React;
484
485 function Child({text}) {
486 - Scheduler.yieldValue('Child: ' + text);
486 + Scheduler.unstable_yieldValue('Child: ' + text);
487 return text;
488 }
489
@@ -491,7 +491,7 @@ describe('ReactHooks', () => {
491 function Parent() {
492 const [counter, _setCounter] = useState(0);
493 setCounter = _setCounter;
494 - Scheduler.yieldValue('Parent: ' + counter);
494 + Scheduler.unstable_yieldValue('Parent: ' + counter);
495 return <Child text={counter} />;
496 }
497
@@ -502,7 +502,9 @@ describe('ReactHooks', () => {
502
503 const update = value => {
504 setCounter(previous => {
505 - Scheduler.yieldValue(`Compute state (${previous} -> ${value})`);
505 + Scheduler.unstable_yieldValue(
506 + `Compute state (${previous} -> ${value})`,
507 + );
508 return value;
509 });
510 };
@@ -541,7 +543,7 @@ describe('ReactHooks', () => {
543 const {useState} = React;
544
545 function Child({text}) {
544 - Scheduler.yieldValue('Child: ' + text);
546 + Scheduler.unstable_yieldValue('Child: ' + text);
547 return text;
548 }
549
@@ -549,7 +551,7 @@ describe('ReactHooks', () => {
551 function Parent() {
552 const [counter, _setCounter] = useState(1);
553 setCounter = _setCounter;
552 - Scheduler.yieldValue('Parent: ' + counter);
554 + Scheduler.unstable_yieldValue('Parent: ' + counter);
555 return <Child text={counter} />;
556 }
557
@@ -561,7 +563,9 @@ describe('ReactHooks', () => {
563 const update = compute => {
564 setCounter(previous => {
565 const value = compute(previous);
564 - Scheduler.yieldValue(`Compute state (${previous} -> ${value})`);
566 + Scheduler.unstable_yieldValue(
567 + `Compute state (${previous} -> ${value})`,
568 + );
569 return value;
570 });
571 };
@@ -599,7 +603,9 @@ describe('ReactHooks', () => {
603 const {useLayoutEffect} = React;
604 function App(props) {
605 useLayoutEffect(() => {
602 - Scheduler.yieldValue('Did commit: ' + props.dependencies.join(', '));
606 + Scheduler.unstable_yieldValue(
607 + 'Did commit: ' + props.dependencies.join(', '),
608 + );
609 }, props.dependencies);
610 return props.dependencies;
611 }
@@ -620,7 +626,7 @@ describe('ReactHooks', () => {
626 const {useMemo} = React;
627 function App({text, hasDeps}) {
628 const resolvedText = useMemo(() => {
623 - Scheduler.yieldValue('Compute');
629 + Scheduler.unstable_yieldValue('Compute');
630 return text.toUpperCase();
631 }, hasDeps ? null : [text]);
632 return resolvedText;
@@ -1836,7 +1842,7 @@ describe('ReactHooks', () => {
1842 );
1843 expect(root).toMatchRenderedOutput('loading');
1844 await Promise.resolve();
1839 - Scheduler.flushAll();
1845 + Scheduler.unstable_flushAll();
1846 expect(root).toMatchRenderedOutput('hello');
1847 });
1848
@@ -1868,7 +1874,7 @@ describe('ReactHooks', () => {
1874 );
1875 expect(root).toMatchRenderedOutput('loading');
1876 await Promise.resolve();
1871 - Scheduler.flushAll();
1877 + Scheduler.unstable_flushAll();
1878 expect(root).toMatchRenderedOutput('hello');
1879 });
1880
@@ -1900,7 +1906,7 @@ describe('ReactHooks', () => {
1906 );
1907 expect(root).toMatchRenderedOutput('loading');
1908 await Promise.resolve();
1903 - Scheduler.flushAll();
1909 + Scheduler.unstable_flushAll();
1910 expect(root).toMatchRenderedOutput('hello');
1911 });
1912
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js
+121 -113
@@ -58,7 +58,7 @@ describe('ReactHooksWithNoopRenderer', () => {
58 }
59
60 function Text(props) {
61 - Scheduler.yieldValue(props.text);
61 + Scheduler.unstable_yieldValue(props.text);
62 return <span prop={props.text} />;
63 }
64
@@ -197,7 +197,7 @@ describe('ReactHooksWithNoopRenderer', () => {
197 it('lazy state initializer', () => {
198 function Counter(props, ref) {
199 const [count, updateCount] = useState(() => {
200 - Scheduler.yieldValue('getInitialState');
200 + Scheduler.unstable_yieldValue('getInitialState');
201 return props.initialState;
202 });
203 useImperativeHandle(ref, () => ({updateCount}));
@@ -346,7 +346,7 @@ describe('ReactHooksWithNoopRenderer', () => {
346 if (count < 3) {
347 setCount(count + 1);
348 }
349 - Scheduler.yieldValue('Render: ' + count);
349 + Scheduler.unstable_yieldValue('Render: ' + count);
350 return <Text text={count} />;
351 }
352
@@ -369,7 +369,7 @@ describe('ReactHooksWithNoopRenderer', () => {
369 setCount(c => c + 1);
370 setCount(c => c + 1);
371 }
372 - Scheduler.yieldValue('Render: ' + count);
372 + Scheduler.unstable_yieldValue('Render: ' + count);
373 return <Text text={count} />;
374 }
375
@@ -390,7 +390,7 @@ describe('ReactHooksWithNoopRenderer', () => {
390 function Counter({row: newRow}) {
391 let [count, setCount] = useState(0);
392 setCount(count + 1);
393 - Scheduler.yieldValue('Render: ' + count);
393 + Scheduler.unstable_yieldValue('Render: ' + count);
394 return <Text text={count} />;
395 }
396 ReactNoop.render(<Counter />);
@@ -409,7 +409,7 @@ describe('ReactHooksWithNoopRenderer', () => {
409 if (count < 3) {
410 dispatch('increment');
411 }
412 - Scheduler.yieldValue('Render: ' + count);
412 + Scheduler.unstable_yieldValue('Render: ' + count);
413 return <Text text={count} />;
414 }
415
@@ -458,7 +458,7 @@ describe('ReactHooksWithNoopRenderer', () => {
458 setReducer(() => reducerA);
459 }
460 }
461 - Scheduler.yieldValue('Render: ' + count);
461 + Scheduler.unstable_yieldValue('Render: ' + count);
462 return <Text text={count} />;
463 }
464 Counter = forwardRef(Counter);
@@ -550,7 +550,7 @@ describe('ReactHooksWithNoopRenderer', () => {
550
551 function Counter(props, ref) {
552 const [count, dispatch] = useReducer(reducer, props, p => {
553 - Scheduler.yieldValue('Init');
553 + Scheduler.unstable_yieldValue('Init');
554 return p.initialCount;
555 });
556 useImperativeHandle(ref, () => ({dispatch}));
@@ -618,13 +618,13 @@ describe('ReactHooksWithNoopRenderer', () => {
618 it('simple mount and update', () => {
619 function Counter(props) {
620 useEffect(() => {
621 - Scheduler.yieldValue(`Passive effect [${props.count}]`);
621 + Scheduler.unstable_yieldValue(`Passive effect [${props.count}]`);
622 });
623 return <Text text={'Count: ' + props.count} />;
624 }
625 act(() => {
626 ReactNoop.render(<Counter count={0} />, () =>
627 - Scheduler.yieldValue('Sync effect'),
627 + Scheduler.unstable_yieldValue('Sync effect'),
628 );
629 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
630 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -634,7 +634,7 @@ describe('ReactHooksWithNoopRenderer', () => {
634
635 act(() => {
636 ReactNoop.render(<Counter count={1} />, () =>
637 - Scheduler.yieldValue('Sync effect'),
637 + Scheduler.unstable_yieldValue('Sync effect'),
638 );
639 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
640 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -646,13 +646,13 @@ describe('ReactHooksWithNoopRenderer', () => {
646 it('flushes passive effects even with sibling deletions', () => {
647 function LayoutEffect(props) {
648 useLayoutEffect(() => {
649 - Scheduler.yieldValue(`Layout effect`);
649 + Scheduler.unstable_yieldValue(`Layout effect`);
650 });
651 return <Text text="Layout" />;
652 }
653 function PassiveEffect(props) {
654 useEffect(() => {
655 - Scheduler.yieldValue(`Passive effect`);
655 + Scheduler.unstable_yieldValue(`Passive effect`);
656 }, []);
657 return <Text text="Passive" />;
658 }
@@ -681,7 +681,7 @@ describe('ReactHooksWithNoopRenderer', () => {
681 it('flushes passive effects even if siblings schedule an update', () => {
682 function PassiveEffect(props) {
683 useEffect(() => {
684 - Scheduler.yieldValue('Passive effect');
684 + Scheduler.unstable_yieldValue('Passive effect');
685 });
686 return <Text text="Passive" />;
687 }
@@ -692,7 +692,7 @@ describe('ReactHooksWithNoopRenderer', () => {
692 if (count === 0) {
693 setCount(1);
694 }
695 - Scheduler.yieldValue('Layout effect ' + count);
695 + Scheduler.unstable_yieldValue('Layout effect ' + count);
696 });
697 return <Text text="Layout" />;
698 }
@@ -719,13 +719,13 @@ describe('ReactHooksWithNoopRenderer', () => {
719 it('flushes passive effects even if siblings schedule a new root', () => {
720 function PassiveEffect(props) {
721 useEffect(() => {
722 - Scheduler.yieldValue('Passive effect');
722 + Scheduler.unstable_yieldValue('Passive effect');
723 }, []);
724 return <Text text="Passive" />;
725 }
726 function LayoutEffect(props) {
727 useLayoutEffect(() => {
728 - Scheduler.yieldValue('Layout effect');
728 + Scheduler.unstable_yieldValue('Layout effect');
729 // Scheduling work shouldn't interfere with the queued passive effect
730 ReactNoop.renderToRootWithID(<Text text="New Root" />, 'root2');
731 });
@@ -761,7 +761,7 @@ describe('ReactHooksWithNoopRenderer', () => {
761
762 function Counter(props) {
763 useEffect(() => {
764 - Scheduler.yieldValue(
764 + Scheduler.unstable_yieldValue(
765 `Committed state when effect was fired: ${getCommittedText()}`,
766 );
767 });
@@ -769,13 +769,13 @@ describe('ReactHooksWithNoopRenderer', () => {
769 }
770 act(() => {
771 ReactNoop.render(<Counter count={0} />, () =>
772 - Scheduler.yieldValue('Sync effect'),
772 + Scheduler.unstable_yieldValue('Sync effect'),
773 );
774 expect(Scheduler).toFlushAndYieldThrough([0, 'Sync effect']);
775 expect(ReactNoop.getChildren()).toEqual([span(0)]);
776 // Before the effects have a chance to flush, schedule another update
777 ReactNoop.render(<Counter count={1} />, () =>
778 - Scheduler.yieldValue('Sync effect'),
778 + Scheduler.unstable_yieldValue('Sync effect'),
779 );
780 expect(Scheduler).toFlushAndYieldThrough([
781 // The previous effect flushes before the reconciliation
@@ -797,7 +797,7 @@ describe('ReactHooksWithNoopRenderer', () => {
797 const [count, updateCount] = useState('(empty)');
798 useEffect(
799 () => {
800 - Scheduler.yieldValue(`Schedule update [${props.count}]`);
800 + Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
801 updateCount(props.count);
802 },
803 [props.count],
@@ -806,7 +806,7 @@ describe('ReactHooksWithNoopRenderer', () => {
806 }
807 act(() => {
808 ReactNoop.render(<Counter count={0} />, () =>
809 - Scheduler.yieldValue('Sync effect'),
809 + Scheduler.unstable_yieldValue('Sync effect'),
810 );
811 expect(Scheduler).toFlushAndYieldThrough([
812 'Count: (empty)',
@@ -820,7 +820,7 @@ describe('ReactHooksWithNoopRenderer', () => {
820
821 act(() => {
822 ReactNoop.render(<Counter count={1} />, () =>
823 - Scheduler.yieldValue('Sync effect'),
823 + Scheduler.unstable_yieldValue('Sync effect'),
824 );
825 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
826 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -835,7 +835,7 @@ describe('ReactHooksWithNoopRenderer', () => {
835 const [count, updateCount] = useState('(empty)');
836 useEffect(
837 () => {
838 - Scheduler.yieldValue(`Schedule update [${props.count}]`);
838 + Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
839 updateCount(props.count);
840 },
841 [props.count],
@@ -844,7 +844,7 @@ describe('ReactHooksWithNoopRenderer', () => {
844 }
845 act(() => {
846 ReactNoop.render(<Counter count={0} />, () =>
847 - Scheduler.yieldValue('Sync effect'),
847 + Scheduler.unstable_yieldValue('Sync effect'),
848 );
849 expect(Scheduler).toFlushAndYieldThrough([
850 'Count: (empty)',
@@ -854,7 +854,7 @@ describe('ReactHooksWithNoopRenderer', () => {
854
855 // Rendering again should flush the previous commit's effects
856 ReactNoop.render(<Counter count={1} />, () =>
857 - Scheduler.yieldValue('Sync effect'),
857 + Scheduler.unstable_yieldValue('Sync effect'),
858 );
859 expect(Scheduler).toFlushAndYieldThrough([
860 'Schedule update [0]',
@@ -877,7 +877,7 @@ describe('ReactHooksWithNoopRenderer', () => {
877 const [count, updateCount] = useState(0);
878 _updateCount = updateCount;
879 useEffect(() => {
880 - Scheduler.yieldValue(`Will set count to 1`);
880 + Scheduler.unstable_yieldValue(`Will set count to 1`);
881 updateCount(1);
882 }, []);
883 return <Text text={'Count: ' + count} />;
@@ -887,7 +887,7 @@ describe('ReactHooksWithNoopRenderer', () => {
887 // it's a lot harder to simulate this condition inside an act scope
888 expect(() => {
889 ReactNoop.render(<Counter count={0} />, () =>
890 - Scheduler.yieldValue('Sync effect'),
890 + Scheduler.unstable_yieldValue('Sync effect'),
891 );
892 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
893 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -933,7 +933,7 @@ describe('ReactHooksWithNoopRenderer', () => {
933 expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
934 tracingEvent,
935 ]);
936 - Scheduler.yieldValue(`Will set count to 1`);
936 + Scheduler.unstable_yieldValue(`Will set count to 1`);
937 updateCount(1);
938 }, []);
939 return <Text text={'Count: ' + count} />;
@@ -948,7 +948,7 @@ describe('ReactHooksWithNoopRenderer', () => {
948 tracingEvent.timestamp,
949 () => {
950 ReactNoop.render(<Counter count={0} />, () =>
951 - Scheduler.yieldValue('Sync effect'),
951 + Scheduler.unstable_yieldValue('Sync effect'),
952 );
953 },
954 );
@@ -1022,7 +1022,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1022 const [count, updateCount] = useState('(empty)');
1023 useEffect(
1024 () => {
1025 - Scheduler.yieldValue(`Schedule update [${props.count}]`);
1025 + Scheduler.unstable_yieldValue(`Schedule update [${props.count}]`);
1026 ReactNoop.flushSync(() => {
1027 updateCount(props.count);
1028 });
@@ -1033,7 +1033,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1033 }
1034 act(() => {
1035 ReactNoop.render(<Counter count={0} />, () =>
1036 - Scheduler.yieldValue('Sync effect'),
1036 + Scheduler.unstable_yieldValue('Sync effect'),
1037 );
1038 expect(Scheduler).toFlushAndYieldThrough([
1039 'Count: (empty)',
@@ -1049,16 +1049,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1049 it('unmounts previous effect', () => {
1050 function Counter(props) {
1051 useEffect(() => {
1052 - Scheduler.yieldValue(`Did create [${props.count}]`);
1052 + Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1053 return () => {
1054 - Scheduler.yieldValue(`Did destroy [${props.count}]`);
1054 + Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1055 };
1056 });
1057 return <Text text={'Count: ' + props.count} />;
1058 }
1059 act(() => {
1060 ReactNoop.render(<Counter count={0} />, () =>
1061 - Scheduler.yieldValue('Sync effect'),
1061 + Scheduler.unstable_yieldValue('Sync effect'),
1062 );
1063 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1064 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1068,7 +1068,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1068
1069 act(() => {
1070 ReactNoop.render(<Counter count={1} />, () =>
1071 - Scheduler.yieldValue('Sync effect'),
1071 + Scheduler.unstable_yieldValue('Sync effect'),
1072 );
1073 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1074 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1080,16 +1080,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1080 it('unmounts on deletion', () => {
1081 function Counter(props) {
1082 useEffect(() => {
1083 - Scheduler.yieldValue(`Did create [${props.count}]`);
1083 + Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1084 return () => {
1085 - Scheduler.yieldValue(`Did destroy [${props.count}]`);
1085 + Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1086 };
1087 });
1088 return <Text text={'Count: ' + props.count} />;
1089 }
1090 act(() => {
1091 ReactNoop.render(<Counter count={0} />, () =>
1092 - Scheduler.yieldValue('Sync effect'),
1092 + Scheduler.unstable_yieldValue('Sync effect'),
1093 );
1094 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1095 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1105,16 +1105,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1105 it('unmounts on deletion after skipped effect', () => {
1106 function Counter(props) {
1107 useEffect(() => {
1108 - Scheduler.yieldValue(`Did create [${props.count}]`);
1108 + Scheduler.unstable_yieldValue(`Did create [${props.count}]`);
1109 return () => {
1110 - Scheduler.yieldValue(`Did destroy [${props.count}]`);
1110 + Scheduler.unstable_yieldValue(`Did destroy [${props.count}]`);
1111 };
1112 }, []);
1113 return <Text text={'Count: ' + props.count} />;
1114 }
1115 act(() => {
1116 ReactNoop.render(<Counter count={0} />, () =>
1117 - Scheduler.yieldValue('Sync effect'),
1117 + Scheduler.unstable_yieldValue('Sync effect'),
1118 );
1119 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1120 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1124,7 +1124,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1124
1125 act(() => {
1126 ReactNoop.render(<Counter count={1} />, () =>
1127 - Scheduler.yieldValue('Sync effect'),
1127 + Scheduler.unstable_yieldValue('Sync effect'),
1128 );
1129 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1130 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1139,9 +1139,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1139
1140 it('always fires effects if no dependencies are provided', () => {
1141 function effect() {
1142 - Scheduler.yieldValue(`Did create`);
1142 + Scheduler.unstable_yieldValue(`Did create`);
1143 return () => {
1144 - Scheduler.yieldValue(`Did destroy`);
1144 + Scheduler.unstable_yieldValue(`Did destroy`);
1145 };
1146 }
1147 function Counter(props) {
@@ -1150,7 +1150,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1150 }
1151 act(() => {
1152 ReactNoop.render(<Counter count={0} />, () =>
1153 - Scheduler.yieldValue('Sync effect'),
1153 + Scheduler.unstable_yieldValue('Sync effect'),
1154 );
1155 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1156 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1160,7 +1160,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1160
1161 act(() => {
1162 ReactNoop.render(<Counter count={1} />, () =>
1163 - Scheduler.yieldValue('Sync effect'),
1163 + Scheduler.unstable_yieldValue('Sync effect'),
1164 );
1165 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1166 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1178,9 +1178,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1178 const text = `${props.label}: ${props.count}`;
1179 useEffect(
1180 () => {
1181 - Scheduler.yieldValue(`Did create [${text}]`);
1181 + Scheduler.unstable_yieldValue(`Did create [${text}]`);
1182 return () => {
1183 - Scheduler.yieldValue(`Did destroy [${text}]`);
1183 + Scheduler.unstable_yieldValue(`Did destroy [${text}]`);
1184 };
1185 },
1186 [props.label, props.count],
@@ -1189,7 +1189,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1189 }
1190 act(() => {
1191 ReactNoop.render(<Counter label="Count" count={0} />, () =>
1192 - Scheduler.yieldValue('Sync effect'),
1192 + Scheduler.unstable_yieldValue('Sync effect'),
1193 );
1194 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1195 });
@@ -1199,7 +1199,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1199
1200 act(() => {
1201 ReactNoop.render(<Counter label="Count" count={1} />, () =>
1202 - Scheduler.yieldValue('Sync effect'),
1202 + Scheduler.unstable_yieldValue('Sync effect'),
1203 );
1204 // Count changed
1205 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
@@ -1213,7 +1213,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1213
1214 act(() => {
1215 ReactNoop.render(<Counter label="Count" count={1} />, () =>
1216 - Scheduler.yieldValue('Sync effect'),
1216 + Scheduler.unstable_yieldValue('Sync effect'),
1217 );
1218 // Nothing changed, so no effect should have fired
1219 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
@@ -1224,7 +1224,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1224
1225 act(() => {
1226 ReactNoop.render(<Counter label="Total" count={1} />, () =>
1227 - Scheduler.yieldValue('Sync effect'),
1227 + Scheduler.unstable_yieldValue('Sync effect'),
1228 );
1229 // Label changed
1230 expect(Scheduler).toFlushAndYieldThrough(['Total: 1', 'Sync effect']);
@@ -1240,16 +1240,16 @@ describe('ReactHooksWithNoopRenderer', () => {
1240 it('multiple effects', () => {
1241 function Counter(props) {
1242 useEffect(() => {
1243 - Scheduler.yieldValue(`Did commit 1 [${props.count}]`);
1243 + Scheduler.unstable_yieldValue(`Did commit 1 [${props.count}]`);
1244 });
1245 useEffect(() => {
1246 - Scheduler.yieldValue(`Did commit 2 [${props.count}]`);
1246 + Scheduler.unstable_yieldValue(`Did commit 2 [${props.count}]`);
1247 });
1248 return <Text text={'Count: ' + props.count} />;
1249 }
1250 act(() => {
1251 ReactNoop.render(<Counter count={0} />, () =>
1252 - Scheduler.yieldValue('Sync effect'),
1252 + Scheduler.unstable_yieldValue('Sync effect'),
1253 );
1254 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1255 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1259,7 +1259,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1259
1260 act(() => {
1261 ReactNoop.render(<Counter count={1} />, () =>
1262 - Scheduler.yieldValue('Sync effect'),
1262 + Scheduler.unstable_yieldValue('Sync effect'),
1263 );
1264 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1265 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1270,22 +1270,22 @@ describe('ReactHooksWithNoopRenderer', () => {
1270 it('unmounts all previous effects before creating any new ones', () => {
1271 function Counter(props) {
1272 useEffect(() => {
1273 - Scheduler.yieldValue(`Mount A [${props.count}]`);
1273 + Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
1274 return () => {
1275 - Scheduler.yieldValue(`Unmount A [${props.count}]`);
1275 + Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
1276 };
1277 });
1278 useEffect(() => {
1279 - Scheduler.yieldValue(`Mount B [${props.count}]`);
1279 + Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
1280 return () => {
1281 - Scheduler.yieldValue(`Unmount B [${props.count}]`);
1281 + Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
1282 };
1283 });
1284 return <Text text={'Count: ' + props.count} />;
1285 }
1286 act(() => {
1287 ReactNoop.render(<Counter count={0} />, () =>
1288 - Scheduler.yieldValue('Sync effect'),
1288 + Scheduler.unstable_yieldValue('Sync effect'),
1289 );
1290 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1291 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1295,7 +1295,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1295
1296 act(() => {
1297 ReactNoop.render(<Counter count={1} />, () =>
1298 - Scheduler.yieldValue('Sync effect'),
1298 + Scheduler.unstable_yieldValue('Sync effect'),
1299 );
1300 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1301 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1311,25 +1311,25 @@ describe('ReactHooksWithNoopRenderer', () => {
1311 it('handles errors on mount', () => {
1312 function Counter(props) {
1313 useEffect(() => {
1314 - Scheduler.yieldValue(`Mount A [${props.count}]`);
1314 + Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
1315 return () => {
1316 - Scheduler.yieldValue(`Unmount A [${props.count}]`);
1316 + Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
1317 };
1318 });
1319 useEffect(() => {
1320 - Scheduler.yieldValue('Oops!');
1320 + Scheduler.unstable_yieldValue('Oops!');
1321 throw new Error('Oops!');
1322 // eslint-disable-next-line no-unreachable
1323 - Scheduler.yieldValue(`Mount B [${props.count}]`);
1323 + Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
1324 return () => {
1325 - Scheduler.yieldValue(`Unmount B [${props.count}]`);
1325 + Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
1326 };
1327 });
1328 return <Text text={'Count: ' + props.count} />;
1329 }
1330 act(() => {
1331 ReactNoop.render(<Counter count={0} />, () =>
1332 - Scheduler.yieldValue('Sync effect'),
1332 + Scheduler.unstable_yieldValue('Sync effect'),
1333 );
1334 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1335 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1349,26 +1349,26 @@ describe('ReactHooksWithNoopRenderer', () => {
1349 it('handles errors on update', () => {
1350 function Counter(props) {
1351 useEffect(() => {
1352 - Scheduler.yieldValue(`Mount A [${props.count}]`);
1352 + Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
1353 return () => {
1354 - Scheduler.yieldValue(`Unmount A [${props.count}]`);
1354 + Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
1355 };
1356 });
1357 useEffect(() => {
1358 if (props.count === 1) {
1359 - Scheduler.yieldValue('Oops!');
1359 + Scheduler.unstable_yieldValue('Oops!');
1360 throw new Error('Oops!');
1361 }
1362 - Scheduler.yieldValue(`Mount B [${props.count}]`);
1362 + Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
1363 return () => {
1364 - Scheduler.yieldValue(`Unmount B [${props.count}]`);
1364 + Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
1365 };
1366 });
1367 return <Text text={'Count: ' + props.count} />;
1368 }
1369 act(() => {
1370 ReactNoop.render(<Counter count={0} />, () =>
1371 - Scheduler.yieldValue('Sync effect'),
1371 + Scheduler.unstable_yieldValue('Sync effect'),
1372 );
1373 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1374 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1379,7 +1379,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1379 act(() => {
1380 // This update will trigger an errror
1381 ReactNoop.render(<Counter count={1} />, () =>
1382 - Scheduler.yieldValue('Sync effect'),
1382 + Scheduler.unstable_yieldValue('Sync effect'),
1383 );
1384 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1385 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1400,25 +1400,25 @@ describe('ReactHooksWithNoopRenderer', () => {
1400 it('handles errors on unmount', () => {
1401 function Counter(props) {
1402 useEffect(() => {
1403 - Scheduler.yieldValue(`Mount A [${props.count}]`);
1403 + Scheduler.unstable_yieldValue(`Mount A [${props.count}]`);
1404 return () => {
1405 - Scheduler.yieldValue('Oops!');
1405 + Scheduler.unstable_yieldValue('Oops!');
1406 throw new Error('Oops!');
1407 // eslint-disable-next-line no-unreachable
1408 - Scheduler.yieldValue(`Unmount A [${props.count}]`);
1408 + Scheduler.unstable_yieldValue(`Unmount A [${props.count}]`);
1409 };
1410 });
1411 useEffect(() => {
1412 - Scheduler.yieldValue(`Mount B [${props.count}]`);
1412 + Scheduler.unstable_yieldValue(`Mount B [${props.count}]`);
1413 return () => {
1414 - Scheduler.yieldValue(`Unmount B [${props.count}]`);
1414 + Scheduler.unstable_yieldValue(`Unmount B [${props.count}]`);
1415 };
1416 });
1417 return <Text text={'Count: ' + props.count} />;
1418 }
1419 act(() => {
1420 ReactNoop.render(<Counter count={0} />, () =>
1421 - Scheduler.yieldValue('Sync effect'),
1421 + Scheduler.unstable_yieldValue('Sync effect'),
1422 );
1423 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1424 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1429,7 +1429,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1429 act(() => {
1430 // This update will trigger an errror
1431 ReactNoop.render(<Counter count={1} />, () =>
1432 - Scheduler.yieldValue('Sync effect'),
1432 + Scheduler.unstable_yieldValue('Sync effect'),
1433 );
1434 expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1435 expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1446,15 +1446,15 @@ describe('ReactHooksWithNoopRenderer', () => {
1446 it('works with memo', () => {
1447 function Counter({count}) {
1448 useLayoutEffect(() => {
1449 - Scheduler.yieldValue('Mount: ' + count);
1450 - return () => Scheduler.yieldValue('Unmount: ' + count);
1449 + Scheduler.unstable_yieldValue('Mount: ' + count);
1450 + return () => Scheduler.unstable_yieldValue('Unmount: ' + count);
1451 });
1452 return <Text text={'Count: ' + count} />;
1453 }
1454 Counter = memo(Counter);
1455
1456 ReactNoop.render(<Counter count={0} />, () =>
1457 - Scheduler.yieldValue('Sync effect'),
1457 + Scheduler.unstable_yieldValue('Sync effect'),
1458 );
1459 expect(Scheduler).toFlushAndYieldThrough([
1460 'Count: 0',
@@ -1464,7 +1464,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1464 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1465
1466 ReactNoop.render(<Counter count={1} />, () =>
1467 - Scheduler.yieldValue('Sync effect'),
1467 + Scheduler.unstable_yieldValue('Sync effect'),
1468 );
1469 expect(Scheduler).toFlushAndYieldThrough([
1470 'Count: 1',
@@ -1485,7 +1485,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1485 function getCommittedText() {
1486 const yields = Scheduler.unstable_clearYields();
1487 const children = ReactNoop.getChildren();
1488 - Scheduler.yieldValue(yields);
1488 + Scheduler.unstable_yieldValue(yields);
1489 if (children === null) {
1490 return null;
1491 }
@@ -1494,13 +1494,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1494
1495 function Counter(props) {
1496 useLayoutEffect(() => {
1497 - Scheduler.yieldValue(`Current: ${getCommittedText()}`);
1497 + Scheduler.unstable_yieldValue(`Current: ${getCommittedText()}`);
1498 });
1499 return <Text text={props.count} />;
1500 }
1501
1502 ReactNoop.render(<Counter count={0} />, () =>
1503 - Scheduler.yieldValue('Sync effect'),
1503 + Scheduler.unstable_yieldValue('Sync effect'),
1504 );
1505 expect(Scheduler).toFlushAndYieldThrough([
1506 [0],
@@ -1510,7 +1510,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1510 expect(ReactNoop.getChildren()).toEqual([span(0)]);
1511
1512 ReactNoop.render(<Counter count={1} />, () =>
1513 - Scheduler.yieldValue('Sync effect'),
1513 + Scheduler.unstable_yieldValue('Sync effect'),
1514 );
1515 expect(Scheduler).toFlushAndYieldThrough([
1516 [1],
@@ -1529,15 +1529,23 @@ describe('ReactHooksWithNoopRenderer', () => {
1529 // intentionally omits a mutation effect.
1530 committedText = props.count + '';
1531
1532 - Scheduler.yieldValue(`Mount layout [current: ${committedText}]`);
1532 + Scheduler.unstable_yieldValue(
1533 + `Mount layout [current: ${committedText}]`,
1534 + );
1535 return () => {
1534 - Scheduler.yieldValue(`Unmount layout [current: ${committedText}]`);
1536 + Scheduler.unstable_yieldValue(
1537 + `Unmount layout [current: ${committedText}]`,
1538 + );
1539 };
1540 });
1541 useEffect(() => {
1538 - Scheduler.yieldValue(`Mount normal [current: ${committedText}]`);
1542 + Scheduler.unstable_yieldValue(
1543 + `Mount normal [current: ${committedText}]`,
1544 + );
1545 return () => {
1540 - Scheduler.yieldValue(`Unmount normal [current: ${committedText}]`);
1546 + Scheduler.unstable_yieldValue(
1547 + `Unmount normal [current: ${committedText}]`,
1548 + );
1549 };
1550 });
1551 return null;
@@ -1545,7 +1553,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1553
1554 act(() => {
1555 ReactNoop.render(<Counter count={0} />, () =>
1548 - Scheduler.yieldValue('Sync effect'),
1556 + Scheduler.unstable_yieldValue('Sync effect'),
1557 );
1558 expect(Scheduler).toFlushAndYieldThrough([
1559 'Mount layout [current: 0]',
@@ -1553,7 +1561,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1561 ]);
1562 expect(committedText).toEqual('0');
1563 ReactNoop.render(<Counter count={1} />, () =>
1556 - Scheduler.yieldValue('Sync effect'),
1564 + Scheduler.unstable_yieldValue('Sync effect'),
1565 );
1566 expect(Scheduler).toFlushAndYieldThrough([
1567 'Mount normal [current: 0]',
@@ -1642,7 +1650,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1650 const text = props.text;
1651 const capitalizedText = useMemo(
1652 () => {
1645 - Scheduler.yieldValue(`Capitalize '${text}'`);
1653 + Scheduler.unstable_yieldValue(`Capitalize '${text}'`);
1654 return text.toUpperCase();
1655 },
1656 [text],
@@ -1674,12 +1682,12 @@ describe('ReactHooksWithNoopRenderer', () => {
1682 }
1683
1684 function computeA() {
1677 - Scheduler.yieldValue('compute A');
1685 + Scheduler.unstable_yieldValue('compute A');
1686 return 'A';
1687 }
1688
1689 function computeB() {
1682 - Scheduler.yieldValue('compute B');
1690 + Scheduler.unstable_yieldValue('compute B');
1691 return 'B';
1692 }
1693
@@ -1709,7 +1717,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1717 }
1718
1719 function compute(val) {
1712 - Scheduler.yieldValue('compute ' + val);
1720 + Scheduler.unstable_yieldValue('compute ' + val);
1721 return val;
1722 }
1723
@@ -1749,7 +1757,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1757 function App() {
1758 ping = useDebouncedCallback(
1759 value => {
1752 - Scheduler.yieldValue('ping: ' + value);
1760 + Scheduler.unstable_yieldValue('ping: ' + value);
1761 },
1762 100,
1763 [],
@@ -2020,17 +2028,17 @@ describe('ReactHooksWithNoopRenderer', () => {
2028 it('unmount effects', () => {
2029 function App(props) {
2030 useEffect(() => {
2023 - Scheduler.yieldValue('Mount A');
2031 + Scheduler.unstable_yieldValue('Mount A');
2032 return () => {
2025 - Scheduler.yieldValue('Unmount A');
2033 + Scheduler.unstable_yieldValue('Unmount A');
2034 };
2035 }, []);
2036
2037 if (props.showMore) {
2038 useEffect(() => {
2031 - Scheduler.yieldValue('Mount B');
2039 + Scheduler.unstable_yieldValue('Mount B');
2040 return () => {
2033 - Scheduler.yieldValue('Unmount B');
2041 + Scheduler.unstable_yieldValue('Unmount B');
2042 };
2043 }, []);
2044 }
@@ -2040,7 +2048,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2048
2049 act(() => {
2050 ReactNoop.render(<App showMore={false} />, () =>
2043 - Scheduler.yieldValue('Sync effect'),
2051 + Scheduler.unstable_yieldValue('Sync effect'),
2052 );
2053 expect(Scheduler).toFlushAndYieldThrough(['Sync effect']);
2054 });
@@ -2091,17 +2099,17 @@ describe('ReactHooksWithNoopRenderer', () => {
2099 // This reducer closes over a value from props. If the reducer is not
2100 // properly updated, the eager reducer will compare to an old value
2101 // and bail out incorrectly.
2094 - Scheduler.yieldValue('Reducer: ' + count);
2102 + Scheduler.unstable_yieldValue('Reducer: ' + count);
2103 return count;
2104 }, -1);
2105 useEffect(
2106 () => {
2099 - Scheduler.yieldValue('Effect: ' + count);
2107 + Scheduler.unstable_yieldValue('Effect: ' + count);
2108 dispatch();
2109 },
2110 [count],
2111 );
2104 - Scheduler.yieldValue('Render: ' + state);
2112 + Scheduler.unstable_yieldValue('Render: ' + state);
2113 return count;
2114 }
2115
@@ -2143,7 +2151,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2151 setStep(step + 1);
2152 }
2153
2146 - Scheduler.yieldValue(`Step: ${step}, Shadow: ${shadow}`);
2154 + Scheduler.unstable_yieldValue(`Step: ${step}, Shadow: ${shadow}`);
2155 return shadow;
2156 }
2157
@@ -2184,7 +2192,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2192 const [count, updateCount] = useState(0);
2193 _updateCount = updateCount;
2194 useEffect(() => {
2187 - Scheduler.yieldValue(`Will set count to 1`);
2195 + Scheduler.unstable_yieldValue(`Will set count to 1`);
2196 updateCount(1);
2197 }, []);
2198 return <Text text={'Count: ' + count} />;
@@ -2192,7 +2200,7 @@ describe('ReactHooksWithNoopRenderer', () => {
2200
2201 act(() => {
2202 ReactNoop.render(<Counter count={0} />, () =>
2195 - Scheduler.yieldValue('Sync effect'),
2203 + Scheduler.unstable_yieldValue('Sync effect'),
2204 );
2205 expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
2206 expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
packages/react-reconciler/src/__tests__/ReactIncremental-test.internal.js
+41 -31
@@ -42,7 +42,7 @@ describe('ReactIncremental', () => {
42
43 it('should render a simple component, in steps if needed', () => {
44 function Bar() {
45 - Scheduler.yieldValue('Bar');
45 + Scheduler.unstable_yieldValue('Bar');
46 return (
47 <span>
48 <div>Hello World</div>
@@ -51,11 +51,11 @@ describe('ReactIncremental', () => {
51 }
52
53 function Foo() {
54 - Scheduler.yieldValue('Foo');
54 + Scheduler.unstable_yieldValue('Foo');
55 return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
56 }
57
58 - ReactNoop.render(<Foo />, () => Scheduler.yieldValue('callback'));
58 + ReactNoop.render(<Foo />, () => Scheduler.unstable_yieldValue('callback'));
59 // Do one step of work.
60 expect(ReactNoop.flushNextYield()).toEqual(['Foo']);
61
@@ -132,12 +132,12 @@ describe('ReactIncremental', () => {
132
133 it('can cancel partially rendered work and restart', () => {
134 function Bar(props) {
135 - Scheduler.yieldValue('Bar');
135 + Scheduler.unstable_yieldValue('Bar');
136 return <div>{props.children}</div>;
137 }
138
139 function Foo(props) {
140 - Scheduler.yieldValue('Foo');
140 + Scheduler.unstable_yieldValue('Foo');
141 return (
142 <div>
143 <Bar>{props.text}</Bar>
@@ -192,10 +192,10 @@ describe('ReactIncremental', () => {
192
193 inst.setState(
194 () => {
195 - Scheduler.yieldValue('setState1');
195 + Scheduler.unstable_yieldValue('setState1');
196 return {text: 'bar'};
197 },
198 - () => Scheduler.yieldValue('callback1'),
198 + () => Scheduler.unstable_yieldValue('callback1'),
199 );
200
201 // Flush part of the work
@@ -205,10 +205,10 @@ describe('ReactIncremental', () => {
205 ReactNoop.flushSync(() => ReactNoop.render(<Foo />));
206 inst.setState(
207 () => {
208 - Scheduler.yieldValue('setState2');
208 + Scheduler.unstable_yieldValue('setState2');
209 return {text2: 'baz'};
210 },
211 - () => Scheduler.yieldValue('callback2'),
211 + () => Scheduler.unstable_yieldValue('callback2'),
212 );
213
214 // Flush the rest of the work which now includes the low priority
@@ -223,17 +223,17 @@ describe('ReactIncremental', () => {
223
224 it('can deprioritize unfinished work and resume it later', () => {
225 function Bar(props) {
226 - Scheduler.yieldValue('Bar');
226 + Scheduler.unstable_yieldValue('Bar');
227 return <div>{props.children}</div>;
228 }
229
230 function Middle(props) {
231 - Scheduler.yieldValue('Middle');
231 + Scheduler.unstable_yieldValue('Middle');
232 return <span>{props.children}</span>;
233 }
234
235 function Foo(props) {
236 - Scheduler.yieldValue('Foo');
236 + Scheduler.unstable_yieldValue('Foo');
237 return (
238 <div>
239 <Bar>{props.text}</Bar>
@@ -1086,7 +1086,7 @@ describe('ReactIncremental', () => {
1086 class Foo extends React.PureComponent {
1087 render() {
1088 const msg = `A: ${a}, B: ${this.props.b}`;
1089 - Scheduler.yieldValue(msg);
1089 + Scheduler.unstable_yieldValue(msg);
1090 return msg;
1091 }
1092 }
@@ -1456,18 +1456,18 @@ describe('ReactIncremental', () => {
1456 class Parent extends React.Component {
1457 state = {parentRenders: 0};
1458 static getDerivedStateFromProps(props, prevState) {
1459 - Scheduler.yieldValue('getDerivedStateFromProps');
1459 + Scheduler.unstable_yieldValue('getDerivedStateFromProps');
1460 return prevState.parentRenders + 1;
1461 }
1462 render() {
1463 - Scheduler.yieldValue('Parent');
1463 + Scheduler.unstable_yieldValue('Parent');
1464 return <Child parentRenders={this.state.parentRenders} ref={child} />;
1465 }
1466 }
1467
1468 class Child extends React.Component {
1469 render() {
1470 - Scheduler.yieldValue('Child');
1470 + Scheduler.unstable_yieldValue('Child');
1471 return this.props.parentRenders;
1472 }
1473 }
@@ -1819,7 +1819,7 @@ describe('ReactIncremental', () => {
1819 };
1820 }
1821 render() {
1822 - Scheduler.yieldValue('Intl ' + JSON.stringify(this.context));
1822 + Scheduler.unstable_yieldValue('Intl ' + JSON.stringify(this.context));
1823 return this.props.children;
1824 }
1825 }
@@ -1834,7 +1834,7 @@ describe('ReactIncremental', () => {
1834 };
1835 }
1836 render() {
1837 - Scheduler.yieldValue('Router ' + JSON.stringify(this.context));
1837 + Scheduler.unstable_yieldValue('Router ' + JSON.stringify(this.context));
1838 return this.props.children;
1839 }
1840 }
@@ -1844,7 +1844,9 @@ describe('ReactIncremental', () => {
1844 locale: PropTypes.string,
1845 };
1846 render() {
1847 - Scheduler.yieldValue('ShowLocale ' + JSON.stringify(this.context));
1847 + Scheduler.unstable_yieldValue(
1848 + 'ShowLocale ' + JSON.stringify(this.context),
1849 + );
1850 return this.context.locale;
1851 }
1852 }
@@ -1854,13 +1856,15 @@ describe('ReactIncremental', () => {
1856 route: PropTypes.string,
1857 };
1858 render() {
1857 - Scheduler.yieldValue('ShowRoute ' + JSON.stringify(this.context));
1859 + Scheduler.unstable_yieldValue(
1860 + 'ShowRoute ' + JSON.stringify(this.context),
1861 + );
1862 return this.context.route;
1863 }
1864 }
1865
1866 function ShowBoth(props, context) {
1863 - Scheduler.yieldValue('ShowBoth ' + JSON.stringify(context));
1867 + Scheduler.unstable_yieldValue('ShowBoth ' + JSON.stringify(context));
1868 return `${context.route} in ${context.locale}`;
1869 }
1870 ShowBoth.contextTypes = {
@@ -1870,14 +1874,18 @@ describe('ReactIncremental', () => {
1874
1875 class ShowNeither extends React.Component {
1876 render() {
1873 - Scheduler.yieldValue('ShowNeither ' + JSON.stringify(this.context));
1877 + Scheduler.unstable_yieldValue(
1878 + 'ShowNeither ' + JSON.stringify(this.context),
1879 + );
1880 return null;
1881 }
1882 }
1883
1884 class Indirection extends React.Component {
1885 render() {
1880 - Scheduler.yieldValue('Indirection ' + JSON.stringify(this.context));
1886 + Scheduler.unstable_yieldValue(
1887 + 'Indirection ' + JSON.stringify(this.context),
1888 + );
1889 return [
1890 <ShowLocale key="a" />,
1891 <ShowRoute key="b" />,
@@ -2056,7 +2064,7 @@ describe('ReactIncremental', () => {
2064 };
2065 }
2066 render() {
2059 - Scheduler.yieldValue('Intl ' + JSON.stringify(this.context));
2067 + Scheduler.unstable_yieldValue('Intl ' + JSON.stringify(this.context));
2068 return this.props.children;
2069 }
2070 }
@@ -2066,7 +2074,9 @@ describe('ReactIncremental', () => {
2074 locale: PropTypes.string,
2075 };
2076 render() {
2069 - Scheduler.yieldValue('ShowLocale ' + JSON.stringify(this.context));
2077 + Scheduler.unstable_yieldValue(
2078 + 'ShowLocale ' + JSON.stringify(this.context),
2079 + );
2080 return this.context.locale;
2081 }
2082 }
@@ -2817,12 +2827,12 @@ describe('ReactIncremental', () => {
2827
2828 it('does not interrupt for update at same priority', () => {
2829 function Parent(props) {
2820 - Scheduler.yieldValue('Parent: ' + props.step);
2830 + Scheduler.unstable_yieldValue('Parent: ' + props.step);
2831 return <Child step={props.step} />;
2832 }
2833
2834 function Child(props) {
2825 - Scheduler.yieldValue('Child: ' + props.step);
2835 + Scheduler.unstable_yieldValue('Child: ' + props.step);
2836 return null;
2837 }
2838
@@ -2837,12 +2847,12 @@ describe('ReactIncremental', () => {
2847
2848 it('does not interrupt for update at lower priority', () => {
2849 function Parent(props) {
2840 - Scheduler.yieldValue('Parent: ' + props.step);
2850 + Scheduler.unstable_yieldValue('Parent: ' + props.step);
2851 return <Child step={props.step} />;
2852 }
2853
2854 function Child(props) {
2845 - Scheduler.yieldValue('Child: ' + props.step);
2855 + Scheduler.unstable_yieldValue('Child: ' + props.step);
2856 return null;
2857 }
2858
@@ -2858,12 +2868,12 @@ describe('ReactIncremental', () => {
2868
2869 it('does interrupt for update at higher priority', () => {
2870 function Parent(props) {
2861 - Scheduler.yieldValue('Parent: ' + props.step);
2871 + Scheduler.unstable_yieldValue('Parent: ' + props.step);
2872 return <Child step={props.step} />;
2873 }
2874
2875 function Child(props) {
2866 - Scheduler.yieldValue('Child: ' + props.step);
2876 + Scheduler.unstable_yieldValue('Child: ' + props.step);
2877 return null;
2878 }
2879
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+50 -50
@@ -45,31 +45,31 @@ describe('ReactIncrementalErrorHandling', () => {
45 class ErrorBoundary extends React.Component {
46 state = {error: null};
47 static getDerivedStateFromError(error) {
48 - Scheduler.yieldValue('getDerivedStateFromError');
48 + Scheduler.unstable_yieldValue('getDerivedStateFromError');
49 return {error};
50 }
51 render() {
52 if (this.state.error) {
53 - Scheduler.yieldValue('ErrorBoundary (catch)');
53 + Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
54 return <ErrorMessage error={this.state.error} />;
55 }
56 - Scheduler.yieldValue('ErrorBoundary (try)');
56 + Scheduler.unstable_yieldValue('ErrorBoundary (try)');
57 return this.props.children;
58 }
59 }
60
61 function ErrorMessage(props) {
62 - Scheduler.yieldValue('ErrorMessage');
62 + Scheduler.unstable_yieldValue('ErrorMessage');
63 return <span prop={`Caught an error: ${props.error.message}`} />;
64 }
65
66 function Indirection(props) {
67 - Scheduler.yieldValue('Indirection');
67 + Scheduler.unstable_yieldValue('Indirection');
68 return props.children || null;
69 }
70
71 function BadRender() {
72 - Scheduler.yieldValue('throw');
72 + Scheduler.unstable_yieldValue('throw');
73 throw new Error('oops!');
74 }
75
@@ -139,31 +139,31 @@ describe('ReactIncrementalErrorHandling', () => {
139 class ErrorBoundary extends React.Component {
140 state = {error: null};
141 componentDidCatch(error) {
142 - Scheduler.yieldValue('componentDidCatch');
142 + Scheduler.unstable_yieldValue('componentDidCatch');
143 this.setState({error});
144 }
145 render() {
146 if (this.state.error) {
147 - Scheduler.yieldValue('ErrorBoundary (catch)');
147 + Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
148 return <ErrorMessage error={this.state.error} />;
149 }
150 - Scheduler.yieldValue('ErrorBoundary (try)');
150 + Scheduler.unstable_yieldValue('ErrorBoundary (try)');
151 return this.props.children;
152 }
153 }
154
155 function ErrorMessage(props) {
156 - Scheduler.yieldValue('ErrorMessage');
156 + Scheduler.unstable_yieldValue('ErrorMessage');
157 return <span prop={`Caught an error: ${props.error.message}`} />;
158 }
159
160 function Indirection(props) {
161 - Scheduler.yieldValue('Indirection');
161 + Scheduler.unstable_yieldValue('Indirection');
162 return props.children || null;
163 }
164
165 function BadRender() {
166 - Scheduler.yieldValue('throw');
166 + Scheduler.unstable_yieldValue('throw');
167 throw new Error('oops!');
168 }
169
@@ -218,15 +218,15 @@ describe('ReactIncrementalErrorHandling', () => {
218 it("retries at a lower priority if there's additional pending work", () => {
219 function App(props) {
220 if (props.isBroken) {
221 - Scheduler.yieldValue('error');
221 + Scheduler.unstable_yieldValue('error');
222 throw new Error('Oops!');
223 }
224 - Scheduler.yieldValue('success');
224 + Scheduler.unstable_yieldValue('success');
225 return <span prop="Everything is fine." />;
226 }
227
228 function onCommit() {
229 - Scheduler.yieldValue('commit');
229 + Scheduler.unstable_yieldValue('commit');
230 }
231
232 function interrupt() {
@@ -236,7 +236,7 @@ describe('ReactIncrementalErrorHandling', () => {
236 }
237
238 ReactNoop.render(<App isBroken={true} />, onCommit);
239 - Scheduler.advanceTime(1000);
239 + Scheduler.unstable_advanceTime(1000);
240 expect(Scheduler).toFlushAndYieldThrough(['error']);
241 interrupt();
242
@@ -260,11 +260,11 @@ describe('ReactIncrementalErrorHandling', () => {
260 class Parent extends React.Component {
261 state = {hideChild: false};
262 componentDidUpdate() {
263 - Scheduler.yieldValue('commit: ' + this.state.hideChild);
263 + Scheduler.unstable_yieldValue('commit: ' + this.state.hideChild);
264 }
265 render() {
266 if (this.state.hideChild) {
267 - Scheduler.yieldValue('(empty)');
267 + Scheduler.unstable_yieldValue('(empty)');
268 return <span prop="(empty)" />;
269 }
270 return <Child isBroken={this.props.childIsBroken} />;
@@ -273,10 +273,10 @@ describe('ReactIncrementalErrorHandling', () => {
273
274 function Child(props) {
275 if (props.isBroken) {
276 - Scheduler.yieldValue('Error!');
276 + Scheduler.unstable_yieldValue('Error!');
277 throw new Error('Error!');
278 }
279 - Scheduler.yieldValue('Child');
279 + Scheduler.unstable_yieldValue('Child');
280 return <span prop="Child" />;
281 }
282
@@ -308,17 +308,17 @@ describe('ReactIncrementalErrorHandling', () => {
308
309 it('retries one more time before handling error', () => {
310 function BadRender() {
311 - Scheduler.yieldValue('BadRender');
311 + Scheduler.unstable_yieldValue('BadRender');
312 throw new Error('oops');
313 }
314
315 function Sibling() {
316 - Scheduler.yieldValue('Sibling');
316 + Scheduler.unstable_yieldValue('Sibling');
317 return <span prop="Sibling" />;
318 }
319
320 function Parent() {
321 - Scheduler.yieldValue('Parent');
321 + Scheduler.unstable_yieldValue('Parent');
322 return (
323 <React.Fragment>
324 <BadRender />
@@ -327,7 +327,7 @@ describe('ReactIncrementalErrorHandling', () => {
327 );
328 }
329
330 - ReactNoop.render(<Parent />, () => Scheduler.yieldValue('commit'));
330 + ReactNoop.render(<Parent />, () => Scheduler.unstable_yieldValue('commit'));
331
332 // Render the bad component asynchronously
333 expect(Scheduler).toFlushAndYieldThrough(['Parent', 'BadRender']);
@@ -357,7 +357,7 @@ describe('ReactIncrementalErrorHandling', () => {
357 throw new Error(`Error ${++id}`);
358 }
359 render() {
360 - Scheduler.yieldValue('BadMount');
360 + Scheduler.unstable_yieldValue('BadMount');
361 return null;
362 }
363 }
@@ -365,14 +365,14 @@ describe('ReactIncrementalErrorHandling', () => {
365 class ErrorBoundary extends React.Component {
366 state = {errorCount: 0};
367 componentDidCatch(error) {
368 - Scheduler.yieldValue(`componentDidCatch: ${error.message}`);
368 + Scheduler.unstable_yieldValue(`componentDidCatch: ${error.message}`);
369 this.setState(state => ({errorCount: state.errorCount + 1}));
370 }
371 render() {
372 if (this.state.errorCount > 0) {
373 return <span prop={`Number of errors: ${this.state.errorCount}`} />;
374 }
375 - Scheduler.yieldValue('ErrorBoundary');
375 + Scheduler.unstable_yieldValue('ErrorBoundary');
376 return this.props.children;
377 }
378 }
@@ -430,23 +430,23 @@ describe('ReactIncrementalErrorHandling', () => {
430 class ErrorBoundary extends React.Component {
431 state = {error: null};
432 componentDidCatch(error) {
433 - Scheduler.yieldValue('ErrorBoundary componentDidCatch');
433 + Scheduler.unstable_yieldValue('ErrorBoundary componentDidCatch');
434 this.setState({error});
435 }
436 render() {
437 if (this.state.error) {
438 - Scheduler.yieldValue('ErrorBoundary render error');
438 + Scheduler.unstable_yieldValue('ErrorBoundary render error');
439 return (
440 <span prop={`Caught an error: ${this.state.error.message}.`} />
441 );
442 }
443 - Scheduler.yieldValue('ErrorBoundary render success');
443 + Scheduler.unstable_yieldValue('ErrorBoundary render success');
444 return this.props.children;
445 }
446 }
447
448 function BrokenRender(props) {
449 - Scheduler.yieldValue('BrokenRender');
449 + Scheduler.unstable_yieldValue('BrokenRender');
450 throw new Error('Hello');
451 }
452
@@ -603,17 +603,17 @@ describe('ReactIncrementalErrorHandling', () => {
603 it('propagates an error from a noop error boundary during partial deferred mounting', () => {
604 class RethrowErrorBoundary extends React.Component {
605 componentDidCatch(error) {
606 - Scheduler.yieldValue('RethrowErrorBoundary componentDidCatch');
606 + Scheduler.unstable_yieldValue('RethrowErrorBoundary componentDidCatch');
607 throw error;
608 }
609 render() {
610 - Scheduler.yieldValue('RethrowErrorBoundary render');
610 + Scheduler.unstable_yieldValue('RethrowErrorBoundary render');
611 return this.props.children;
612 }
613 }
614
615 function BrokenRender() {
616 - Scheduler.yieldValue('BrokenRender');
616 + Scheduler.unstable_yieldValue('BrokenRender');
617 throw new Error('Hello');
618 }
619
@@ -758,7 +758,7 @@ describe('ReactIncrementalErrorHandling', () => {
758 });
759 });
760 }).toThrow('Hello');
761 - Scheduler.flushAll();
761 + Scheduler.unstable_flushAll();
762 expect(ReactNoop.getChildren()).toEqual([span('a:3')]);
763 });
764
@@ -862,7 +862,7 @@ describe('ReactIncrementalErrorHandling', () => {
862 it('should not attempt to recover an unmounting error boundary', () => {
863 class Parent extends React.Component {
864 componentWillUnmount() {
865 - Scheduler.yieldValue('Parent componentWillUnmount');
865 + Scheduler.unstable_yieldValue('Parent componentWillUnmount');
866 }
867 render() {
868 return <Boundary />;
@@ -871,7 +871,7 @@ describe('ReactIncrementalErrorHandling', () => {
871
872 class Boundary extends React.Component {
873 componentDidCatch(e) {
874 - Scheduler.yieldValue(`Caught error: ${e.message}`);
874 + Scheduler.unstable_yieldValue(`Caught error: ${e.message}`);
875 }
876 render() {
877 return <ThrowsOnUnmount />;
@@ -880,7 +880,7 @@ describe('ReactIncrementalErrorHandling', () => {
880
881 class ThrowsOnUnmount extends React.Component {
882 componentWillUnmount() {
883 - Scheduler.yieldValue('ThrowsOnUnmount componentWillUnmount');
883 + Scheduler.unstable_yieldValue('ThrowsOnUnmount componentWillUnmount');
884 throw new Error('unmount error');
885 }
886 render() {
@@ -1423,31 +1423,31 @@ describe('ReactIncrementalErrorHandling', () => {
1423 class ErrorBoundary extends React.Component {
1424 state = {error: null};
1425 componentDidCatch(error) {
1426 - Scheduler.yieldValue('componentDidCatch');
1426 + Scheduler.unstable_yieldValue('componentDidCatch');
1427 this.setState({error});
1428 }
1429 render() {
1430 if (this.state.error) {
1431 - Scheduler.yieldValue('ErrorBoundary (catch)');
1431 + Scheduler.unstable_yieldValue('ErrorBoundary (catch)');
1432 return <ErrorMessage error={this.state.error} />;
1433 }
1434 - Scheduler.yieldValue('ErrorBoundary (try)');
1434 + Scheduler.unstable_yieldValue('ErrorBoundary (try)');
1435 return this.props.children;
1436 }
1437 }
1438
1439 function ErrorMessage(props) {
1440 - Scheduler.yieldValue('ErrorMessage');
1440 + Scheduler.unstable_yieldValue('ErrorMessage');
1441 return <span prop={`Caught an error: ${props.error.message}`} />;
1442 }
1443
1444 function BadRenderSibling(props) {
1445 - Scheduler.yieldValue('BadRenderSibling');
1445 + Scheduler.unstable_yieldValue('BadRenderSibling');
1446 return null;
1447 }
1448
1449 function BadRender() {
1450 - Scheduler.yieldValue('throw');
1450 + Scheduler.unstable_yieldValue('throw');
1451 throw new Error('oops!');
1452 }
1453
@@ -1485,25 +1485,25 @@ describe('ReactIncrementalErrorHandling', () => {
1485 // where we checked for the existence of didUpdate instead of didMount, and
1486 // didMount was not defined.
1487 function BadRender() {
1488 - Scheduler.yieldValue('throw');
1488 + Scheduler.unstable_yieldValue('throw');
1489 throw new Error('oops!');
1490 }
1491
1492 class Parent extends React.Component {
1493 state = {error: null, other: false};
1494 componentDidCatch(error) {
1495 - Scheduler.yieldValue('did catch');
1495 + Scheduler.unstable_yieldValue('did catch');
1496 this.setState({error});
1497 }
1498 componentDidUpdate() {
1499 - Scheduler.yieldValue('did update');
1499 + Scheduler.unstable_yieldValue('did update');
1500 }
1501 render() {
1502 if (this.state.error) {
1503 - Scheduler.yieldValue('render error message');
1503 + Scheduler.unstable_yieldValue('render error message');
1504 return <span prop={`Caught an error: ${this.state.error.message}`} />;
1505 }
1506 - Scheduler.yieldValue('render');
1506 + Scheduler.unstable_yieldValue('render');
1507 return <BadRender />;
1508 }
1509 }
@@ -1529,7 +1529,7 @@ describe('ReactIncrementalErrorHandling', () => {
1529 }
1530 render() {
1531 if (this.state.errorInfo) {
1532 - Scheduler.yieldValue('render error message');
1532 + Scheduler.unstable_yieldValue('render error message');
1533 return (
1534 <span
1535 prop={`Caught an error:${normalizeCodeLocInfo(
packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js
+4 -2
@@ -167,10 +167,12 @@ describe('ReactIncrementalErrorLogging', () => {
167 this.setState({step: 1});
168 }
169 componentWillUnmount() {
170 - Scheduler.yieldValue('componentWillUnmount: ' + this.state.step);
170 + Scheduler.unstable_yieldValue(
171 + 'componentWillUnmount: ' + this.state.step,
172 + );
173 }
174 render() {
173 - Scheduler.yieldValue('render: ' + this.state.step);
175 + Scheduler.unstable_yieldValue('render: ' + this.state.step);
176 if (this.state.step > 0) {
177 throw new Error('oops');
178 }
packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js
+4 -4
@@ -397,21 +397,21 @@ describe('ReactDebugFiberPerf', () => {
397 it('measures deferred work in chunks', () => {
398 class A extends React.Component {
399 render() {
400 - Scheduler.yieldValue('A');
400 + Scheduler.unstable_yieldValue('A');
401 return <div>{this.props.children}</div>;
402 }
403 }
404
405 class B extends React.Component {
406 render() {
407 - Scheduler.yieldValue('B');
407 + Scheduler.unstable_yieldValue('B');
408 return <div>{this.props.children}</div>;
409 }
410 }
411
412 class C extends React.Component {
413 render() {
414 - Scheduler.yieldValue('C');
414 + Scheduler.unstable_yieldValue('C');
415 return <div>{this.props.children}</div>;
416 }
417 }
@@ -652,7 +652,7 @@ describe('ReactDebugFiberPerf', () => {
652
653 it('warns if an in-progress update is interrupted', () => {
654 function Foo() {
655 - Scheduler.yieldValue('Foo');
655 + Scheduler.unstable_yieldValue('Foo');
656 return <span />;
657 }
658
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.internal.js
+33 -12
@@ -47,10 +47,14 @@ describe('ReactIncrementalReflection', () => {
47 }
48 UNSAFE_componentWillMount() {
49 instances.push(this);
50 - Scheduler.yieldValue('componentWillMount: ' + this._isMounted());
50 + Scheduler.unstable_yieldValue(
51 + 'componentWillMount: ' + this._isMounted(),
52 + );
53 }
54 componentDidMount() {
53 - Scheduler.yieldValue('componentDidMount: ' + this._isMounted());
55 + Scheduler.unstable_yieldValue(
56 + 'componentDidMount: ' + this._isMounted(),
57 + );
58 }
59 render() {
60 return <span />;
@@ -91,16 +95,18 @@ describe('ReactIncrementalReflection', () => {
95 instances.push(this);
96 }
97 componentWillUnmount() {
94 - Scheduler.yieldValue('componentWillUnmount: ' + this._isMounted());
98 + Scheduler.unstable_yieldValue(
99 + 'componentWillUnmount: ' + this._isMounted(),
100 + );
101 }
102 render() {
97 - Scheduler.yieldValue('Component');
103 + Scheduler.unstable_yieldValue('Component');
104 return <span />;
105 }
106 }
107
108 function Other() {
103 - Scheduler.yieldValue('Other');
109 + Scheduler.unstable_yieldValue('Other');
110 return <span />;
111 }
112
@@ -149,22 +155,37 @@ describe('ReactIncrementalReflection', () => {
155 class Component extends React.Component {
156 UNSAFE_componentWillMount() {
157 classInstance = this;
152 - Scheduler.yieldValue(['componentWillMount', findInstance(this)]);
158 + Scheduler.unstable_yieldValue([
159 + 'componentWillMount',
160 + findInstance(this),
161 + ]);
162 }
163 componentDidMount() {
155 - Scheduler.yieldValue(['componentDidMount', findInstance(this)]);
164 + Scheduler.unstable_yieldValue([
165 + 'componentDidMount',
166 + findInstance(this),
167 + ]);
168 }
169 UNSAFE_componentWillUpdate() {
158 - Scheduler.yieldValue(['componentWillUpdate', findInstance(this)]);
170 + Scheduler.unstable_yieldValue([
171 + 'componentWillUpdate',
172 + findInstance(this),
173 + ]);
174 }
175 componentDidUpdate() {
161 - Scheduler.yieldValue(['componentDidUpdate', findInstance(this)]);
176 + Scheduler.unstable_yieldValue([
177 + 'componentDidUpdate',
178 + findInstance(this),
179 + ]);
180 }
181 componentWillUnmount() {
164 - Scheduler.yieldValue(['componentWillUnmount', findInstance(this)]);
182 + Scheduler.unstable_yieldValue([
183 + 'componentWillUnmount',
184 + findInstance(this),
185 + ]);
186 }
187 render() {
167 - Scheduler.yieldValue('render');
188 + Scheduler.unstable_yieldValue('render');
189 return this.props.step < 2 ? (
190 <span ref={ref => (this.span = ref)} />
191 ) : this.props.step === 2 ? (
@@ -177,7 +198,7 @@ describe('ReactIncrementalReflection', () => {
198
199 function Sibling() {
200 // Sibling is used to assert that we've rendered past the first component.
180 - Scheduler.yieldValue('render sibling');
201 + Scheduler.unstable_yieldValue('render sibling');
202 return <span />;
203 }
204
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.internal.js
+16 -14
@@ -92,7 +92,7 @@ describe('ReactIncrementalScheduling', () => {
92 function Text({text}) {
93 useEffect(
94 () => {
95 - Scheduler.yieldValue(text);
95 + Scheduler.unstable_yieldValue(text);
96 },
97 [text],
98 );
@@ -144,24 +144,24 @@ describe('ReactIncrementalScheduling', () => {
144 state = {tick: 0};
145
146 componentDidMount() {
147 - Scheduler.yieldValue(
147 + Scheduler.unstable_yieldValue(
148 'componentDidMount (before setState): ' + this.state.tick,
149 );
150 this.setState({tick: 1});
151 // We're in a batch. Update hasn't flushed yet.
152 - Scheduler.yieldValue(
152 + Scheduler.unstable_yieldValue(
153 'componentDidMount (after setState): ' + this.state.tick,
154 );
155 }
156
157 componentDidUpdate() {
158 - Scheduler.yieldValue('componentDidUpdate: ' + this.state.tick);
158 + Scheduler.unstable_yieldValue('componentDidUpdate: ' + this.state.tick);
159 if (this.state.tick === 2) {
160 - Scheduler.yieldValue(
160 + Scheduler.unstable_yieldValue(
161 'componentDidUpdate (before setState): ' + this.state.tick,
162 );
163 this.setState({tick: 3});
164 - Scheduler.yieldValue(
164 + Scheduler.unstable_yieldValue(
165 'componentDidUpdate (after setState): ' + this.state.tick,
166 );
167 // We're in a batch. Update hasn't flushed yet.
@@ -169,7 +169,7 @@ describe('ReactIncrementalScheduling', () => {
169 }
170
171 render() {
172 - Scheduler.yieldValue('render: ' + this.state.tick);
172 + Scheduler.unstable_yieldValue('render: ' + this.state.tick);
173 instance = this;
174 return <span prop={this.state.tick} />;
175 }
@@ -209,11 +209,11 @@ describe('ReactIncrementalScheduling', () => {
209
210 componentDidMount() {
211 ReactNoop.deferredUpdates(() => {
212 - Scheduler.yieldValue(
212 + Scheduler.unstable_yieldValue(
213 'componentDidMount (before setState): ' + this.state.tick,
214 );
215 this.setState({tick: 1});
216 - Scheduler.yieldValue(
216 + Scheduler.unstable_yieldValue(
217 'componentDidMount (after setState): ' + this.state.tick,
218 );
219 });
@@ -221,13 +221,15 @@ describe('ReactIncrementalScheduling', () => {
221
222 componentDidUpdate() {
223 ReactNoop.deferredUpdates(() => {
224 - Scheduler.yieldValue('componentDidUpdate: ' + this.state.tick);
224 + Scheduler.unstable_yieldValue(
225 + 'componentDidUpdate: ' + this.state.tick,
226 + );
227 if (this.state.tick === 2) {
226 - Scheduler.yieldValue(
228 + Scheduler.unstable_yieldValue(
229 'componentDidUpdate (before setState): ' + this.state.tick,
230 );
231 this.setState({tick: 3});
230 - Scheduler.yieldValue(
232 + Scheduler.unstable_yieldValue(
233 'componentDidUpdate (after setState): ' + this.state.tick,
234 );
235 }
@@ -235,7 +237,7 @@ describe('ReactIncrementalScheduling', () => {
237 }
238
239 render() {
238 - Scheduler.yieldValue('render: ' + this.state.tick);
240 + Scheduler.unstable_yieldValue('render: ' + this.state.tick);
241 instance = this;
242 return <span prop={this.state.tick} />;
243 }
@@ -285,7 +287,7 @@ describe('ReactIncrementalScheduling', () => {
287 });
288 }
289 render() {
288 - Scheduler.yieldValue('Foo');
290 + Scheduler.unstable_yieldValue('Foo');
291 return <span prop={this.state.step} />;
292 }
293 }
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.internal.js
+16 -14
@@ -375,12 +375,12 @@ describe('ReactIncrementalSideEffects', () => {
375
376 it('does not update child nodes if a flush is aborted', () => {
377 function Bar(props) {
378 - Scheduler.yieldValue('Bar');
378 + Scheduler.unstable_yieldValue('Bar');
379 return <span prop={props.text} />;
380 }
381
382 function Foo(props) {
383 - Scheduler.yieldValue('Foo');
383 + Scheduler.unstable_yieldValue('Foo');
384 return (
385 <div>
386 <div>
@@ -409,12 +409,12 @@ describe('ReactIncrementalSideEffects', () => {
409
410 it('preserves a previously rendered node when deprioritized', () => {
411 function Middle(props) {
412 - Scheduler.yieldValue('Middle');
412 + Scheduler.unstable_yieldValue('Middle');
413 return <span prop={props.children} />;
414 }
415
416 function Foo(props) {
417 - Scheduler.yieldValue('Foo');
417 + Scheduler.unstable_yieldValue('Foo');
418 return (
419 <div>
420 <div hidden={true}>
@@ -435,7 +435,9 @@ describe('ReactIncrementalSideEffects', () => {
435 </div>,
436 );
437
438 - ReactNoop.render(<Foo text="bar" />, () => Scheduler.yieldValue('commit'));
438 + ReactNoop.render(<Foo text="bar" />, () =>
439 + Scheduler.unstable_yieldValue('commit'),
440 + );
441 expect(Scheduler).toFlushAndYieldThrough(['Foo', 'commit']);
442 expect(ReactNoop.getChildrenAsJSX()).toEqual(
443 <div>
@@ -457,7 +459,7 @@ describe('ReactIncrementalSideEffects', () => {
459
460 it('can reuse side-effects after being preempted', () => {
461 function Bar(props) {
460 - Scheduler.yieldValue('Bar');
462 + Scheduler.unstable_yieldValue('Bar');
463 return <span prop={props.children} />;
464 }
465
@@ -469,7 +471,7 @@ describe('ReactIncrementalSideEffects', () => {
471 );
472
473 function Foo(props) {
472 - Scheduler.yieldValue('Foo');
474 + Scheduler.unstable_yieldValue('Foo');
475 return (
476 <div hidden={true}>
477 {props.step === 0 ? (
@@ -500,7 +502,7 @@ describe('ReactIncrementalSideEffects', () => {
502 // Make a quick update which will schedule low priority work to
503 // update the middle content.
504 ReactNoop.render(<Foo text="bar" step={1} />, () =>
503 - Scheduler.yieldValue('commit'),
505 + Scheduler.unstable_yieldValue('commit'),
506 );
507 expect(Scheduler).toFlushAndYieldThrough(['Foo', 'commit', 'Bar']);
508
@@ -540,7 +542,7 @@ describe('ReactIncrementalSideEffects', () => {
542 return this.props.children !== nextProps.children;
543 }
544 render() {
543 - Scheduler.yieldValue('Bar');
545 + Scheduler.unstable_yieldValue('Bar');
546 return <span prop={this.props.children} />;
547 }
548 }
@@ -550,7 +552,7 @@ describe('ReactIncrementalSideEffects', () => {
552 return this.props.step !== nextProps.step;
553 }
554 render() {
553 - Scheduler.yieldValue('Content');
555 + Scheduler.unstable_yieldValue('Content');
556 return (
557 <div>
558 <Bar>{this.props.step === 0 ? 'Hi' : 'Hello'}</Bar>
@@ -561,7 +563,7 @@ describe('ReactIncrementalSideEffects', () => {
563 }
564
565 function Foo(props) {
564 - Scheduler.yieldValue('Foo');
566 + Scheduler.unstable_yieldValue('Foo');
567 return (
568 <div hidden={true}>
569 <Content step={props.step} text={props.text} />
@@ -619,7 +621,7 @@ describe('ReactIncrementalSideEffects', () => {
621
622 it('can update a completed tree before it has a chance to commit', () => {
623 function Foo(props) {
622 - Scheduler.yieldValue('Foo');
624 + Scheduler.unstable_yieldValue('Foo');
625 return <span prop={props.step} />;
626 }
627 ReactNoop.render(<Foo step={1} />);
@@ -901,12 +903,12 @@ describe('ReactIncrementalSideEffects', () => {
903 this.setState({active: true});
904 }
905 render() {
904 - Scheduler.yieldValue('Bar');
906 + Scheduler.unstable_yieldValue('Bar');
907 return <span prop={this.state.active ? 'X' : this.props.idx} />;
908 }
909 }
910 function Foo(props) {
909 - Scheduler.yieldValue('Foo');
911 + Scheduler.unstable_yieldValue('Foo');
912 return (
913 <div>
914 <span prop={props.tick} />
packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js
+4 -4
@@ -216,7 +216,7 @@ describe('ReactIncrementalTriangle', () => {
216 }
217 render() {
218 if (yieldAfterEachRender) {
219 - Scheduler.yieldValue(this);
219 + Scheduler.unstable_yieldValue(this);
220 }
221 const {counter, remainingDepth} = this.props;
222 return (
@@ -308,7 +308,7 @@ describe('ReactIncrementalTriangle', () => {
308 } else {
309 ReactNoop.render(<App remainingDepth={MAX_DEPTH} key={keyCounter++} />);
310 }
311 - Scheduler.unstable_flushWithoutYielding();
311 + Scheduler.unstable_flushAllWithoutAsserting();
312 assertConsistentTree();
313 return appInstance;
314 }
@@ -390,7 +390,7 @@ describe('ReactIncrementalTriangle', () => {
390 Scheduler.unstable_flushNumberOfYields(action.unitsOfWork);
391 break;
392 case FLUSH_ALL:
393 - Scheduler.unstable_flushWithoutYielding();
393 + Scheduler.unstable_flushAllWithoutAsserting();
394 break;
395 case STEP:
396 ReactNoop.deferredUpdates(() => {
@@ -432,7 +432,7 @@ describe('ReactIncrementalTriangle', () => {
432 assertConsistentTree(activeLeafIndices);
433 }
434 // Flush remaining work
435 - Scheduler.unstable_flushWithoutYielding();
435 + Scheduler.unstable_flushAllWithoutAsserting();
436 assertConsistentTree(activeLeafIndices, expectedCounterAtEnd);
437 }
438
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.internal.js
+25 -25
@@ -34,7 +34,7 @@ describe('ReactIncrementalUpdates', () => {
34 class Foo extends React.Component {
35 state = {};
36 componentDidMount() {
37 - Scheduler.yieldValue('commit');
37 + Scheduler.unstable_yieldValue('commit');
38 ReactNoop.deferredUpdates(() => {
39 // Has low priority
40 this.setState({b: 'b'});
@@ -150,7 +150,7 @@ describe('ReactIncrementalUpdates', () => {
150
151 function createUpdate(letter) {
152 return () => {
153 - Scheduler.yieldValue(letter);
153 + Scheduler.unstable_yieldValue(letter);
154 return {
155 [letter]: letter,
156 };
@@ -221,7 +221,7 @@ describe('ReactIncrementalUpdates', () => {
221
222 function createUpdate(letter) {
223 return () => {
224 - Scheduler.yieldValue(letter);
224 + Scheduler.unstable_yieldValue(letter);
225 return {
226 [letter]: letter,
227 };
@@ -461,9 +461,9 @@ describe('ReactIncrementalUpdates', () => {
461 const {useEffect} = React;
462
463 function App({label}) {
464 - Scheduler.yieldValue('Render: ' + label);
464 + Scheduler.unstable_yieldValue('Render: ' + label);
465 useEffect(() => {
466 - Scheduler.yieldValue('Commit: ' + label);
466 + Scheduler.unstable_yieldValue('Commit: ' + label);
467 });
468 return label;
469 }
@@ -478,22 +478,22 @@ describe('ReactIncrementalUpdates', () => {
478 // updates in separate batches are all flushed in the same callback
479 ReactNoop.act(() => {
480 ReactNoop.render(<App label="" />);
481 - Scheduler.advanceTime(1000);
481 + Scheduler.unstable_advanceTime(1000);
482 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
483 interrupt();
484
485 ReactNoop.render(<App label="he" />);
486 - Scheduler.advanceTime(1000);
486 + Scheduler.unstable_advanceTime(1000);
487 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
488 interrupt();
489
490 ReactNoop.render(<App label="hell" />);
491 - Scheduler.advanceTime(1000);
491 + Scheduler.unstable_advanceTime(1000);
492 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
493 interrupt();
494
495 ReactNoop.render(<App label="hello" />);
496 - Scheduler.advanceTime(1000);
496 + Scheduler.unstable_advanceTime(1000);
497 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
498 interrupt();
499
@@ -519,27 +519,27 @@ describe('ReactIncrementalUpdates', () => {
519 // Now do the same thing over again, but this time, expire all the updates
520 // instead of flushing them normally.
521 ReactNoop.render(<App label="" />);
522 - Scheduler.advanceTime(1000);
522 + Scheduler.unstable_advanceTime(1000);
523 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
524 interrupt();
525
526 ReactNoop.render(<App label="go" />);
527 - Scheduler.advanceTime(1000);
527 + Scheduler.unstable_advanceTime(1000);
528 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
529 interrupt();
530
531 ReactNoop.render(<App label="good" />);
532 - Scheduler.advanceTime(1000);
532 + Scheduler.unstable_advanceTime(1000);
533 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
534 interrupt();
535
536 ReactNoop.render(<App label="goodbye" />);
537 - Scheduler.advanceTime(1000);
537 + Scheduler.unstable_advanceTime(1000);
538 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
539 interrupt();
540
541 // All the updates should render and commit in a single batch.
542 - Scheduler.advanceTime(10000);
542 + Scheduler.unstable_advanceTime(10000);
543 expect(Scheduler).toHaveYielded(['Render: goodbye']);
544 // Passive effect
545 expect(Scheduler).toFlushAndYield(['Commit: goodbye']);
@@ -551,9 +551,9 @@ describe('ReactIncrementalUpdates', () => {
551 const {useEffect} = React;
552
553 function App({label}) {
554 - Scheduler.yieldValue('Render: ' + label);
554 + Scheduler.unstable_yieldValue('Render: ' + label);
555 useEffect(() => {
556 - Scheduler.yieldValue('Commit: ' + label);
556 + Scheduler.unstable_yieldValue('Commit: ' + label);
557 });
558 return label;
559 }
@@ -568,25 +568,25 @@ describe('ReactIncrementalUpdates', () => {
568 // updates in separate batches are all flushed in the same callback
569 ReactNoop.renderToRootWithID(<App label="" />, 'a');
570 ReactNoop.renderToRootWithID(<App label="" />, 'b');
571 - Scheduler.advanceTime(1000);
571 + Scheduler.unstable_advanceTime(1000);
572 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
573 interrupt();
574
575 ReactNoop.renderToRootWithID(<App label="he" />, 'a');
576 ReactNoop.renderToRootWithID(<App label="he" />, 'b');
577 - Scheduler.advanceTime(1000);
577 + Scheduler.unstable_advanceTime(1000);
578 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
579 interrupt();
580
581 ReactNoop.renderToRootWithID(<App label="hell" />, 'a');
582 ReactNoop.renderToRootWithID(<App label="hell" />, 'b');
583 - Scheduler.advanceTime(1000);
583 + Scheduler.unstable_advanceTime(1000);
584 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
585 interrupt();
586
587 ReactNoop.renderToRootWithID(<App label="hello" />, 'a');
588 ReactNoop.renderToRootWithID(<App label="hello" />, 'b');
589 - Scheduler.advanceTime(1000);
589 + Scheduler.unstable_advanceTime(1000);
590 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
591 interrupt();
592
@@ -621,30 +621,30 @@ describe('ReactIncrementalUpdates', () => {
621 // instead of flushing them normally.
622 ReactNoop.renderToRootWithID(<App label="" />, 'a');
623 ReactNoop.renderToRootWithID(<App label="" />, 'b');
624 - Scheduler.advanceTime(1000);
624 + Scheduler.unstable_advanceTime(1000);
625 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
626 interrupt();
627
628 ReactNoop.renderToRootWithID(<App label="go" />, 'a');
629 ReactNoop.renderToRootWithID(<App label="go" />, 'b');
630 - Scheduler.advanceTime(1000);
630 + Scheduler.unstable_advanceTime(1000);
631 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
632 interrupt();
633
634 ReactNoop.renderToRootWithID(<App label="good" />, 'a');
635 ReactNoop.renderToRootWithID(<App label="good" />, 'b');
636 - Scheduler.advanceTime(1000);
636 + Scheduler.unstable_advanceTime(1000);
637 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
638 interrupt();
639
640 ReactNoop.renderToRootWithID(<App label="goodbye" />, 'a');
641 ReactNoop.renderToRootWithID(<App label="goodbye" />, 'b');
642 - Scheduler.advanceTime(1000);
642 + Scheduler.unstable_advanceTime(1000);
643 expect(Scheduler).toFlushAndYieldThrough(['Render: ']);
644 interrupt();
645
646 // All the updates should render and commit in a single batch.
647 - Scheduler.advanceTime(10000);
647 + Scheduler.unstable_advanceTime(10000);
648 expect(Scheduler).toHaveYielded([
649 'Render: goodbye',
650 'Commit: goodbye',
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
+24 -18
@@ -21,7 +21,7 @@ describe('ReactLazy', () => {
21 });
22
23 function Text(props) {
24 - Scheduler.yieldValue(props.text);
24 + Scheduler.unstable_yieldValue(props.text);
25 return props.text;
26 }
27
@@ -205,10 +205,10 @@ describe('ReactLazy', () => {
205 it('mount and reorder', async () => {
206 class Child extends React.Component {
207 componentDidMount() {
208 - Scheduler.yieldValue('Did mount: ' + this.props.label);
208 + Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
209 }
210 componentDidUpdate() {
211 - Scheduler.yieldValue('Did update: ' + this.props.label);
211 + Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
212 }
213 render() {
214 return <Text text={this.props.label} />;
@@ -299,7 +299,7 @@ describe('ReactLazy', () => {
299
300 it('resolves defaultProps without breaking memoization', async () => {
301 function LazyImpl(props) {
302 - Scheduler.yieldValue('Lazy');
302 + Scheduler.unstable_yieldValue('Lazy');
303 return (
304 <React.Fragment>
305 <Text text={props.siblingText} />
@@ -349,38 +349,42 @@ describe('ReactLazy', () => {
349 state = {};
350
351 static getDerivedStateFromProps(props) {
352 - Scheduler.yieldValue(`getDerivedStateFromProps: ${props.text}`);
352 + Scheduler.unstable_yieldValue(
353 + `getDerivedStateFromProps: ${props.text}`,
354 + );
355 return null;
356 }
357
358 constructor(props) {
359 super(props);
358 - Scheduler.yieldValue(`constructor: ${this.props.text}`);
360 + Scheduler.unstable_yieldValue(`constructor: ${this.props.text}`);
361 }
362
363 componentDidMount() {
362 - Scheduler.yieldValue(`componentDidMount: ${this.props.text}`);
364 + Scheduler.unstable_yieldValue(`componentDidMount: ${this.props.text}`);
365 }
366
367 componentDidUpdate(prevProps) {
366 - Scheduler.yieldValue(
368 + Scheduler.unstable_yieldValue(
369 `componentDidUpdate: ${prevProps.text} -> ${this.props.text}`,
370 );
371 }
372
373 componentWillUnmount() {
372 - Scheduler.yieldValue(`componentWillUnmount: ${this.props.text}`);
374 + Scheduler.unstable_yieldValue(
375 + `componentWillUnmount: ${this.props.text}`,
376 + );
377 }
378
379 shouldComponentUpdate(nextProps) {
376 - Scheduler.yieldValue(
380 + Scheduler.unstable_yieldValue(
381 `shouldComponentUpdate: ${this.props.text} -> ${nextProps.text}`,
382 );
383 return true;
384 }
385
386 getSnapshotBeforeUpdate(prevProps) {
383 - Scheduler.yieldValue(
387 + Scheduler.unstable_yieldValue(
388 `getSnapshotBeforeUpdate: ${prevProps.text} -> ${this.props.text}`,
389 );
390 return null;
@@ -449,17 +453,19 @@ describe('ReactLazy', () => {
453 state = {};
454
455 UNSAFE_componentWillMount() {
452 - Scheduler.yieldValue(`UNSAFE_componentWillMount: ${this.props.text}`);
456 + Scheduler.unstable_yieldValue(
457 + `UNSAFE_componentWillMount: ${this.props.text}`,
458 + );
459 }
460
461 UNSAFE_componentWillUpdate(nextProps) {
456 - Scheduler.yieldValue(
462 + Scheduler.unstable_yieldValue(
463 `UNSAFE_componentWillUpdate: ${this.props.text} -> ${nextProps.text}`,
464 );
465 }
466
467 UNSAFE_componentWillReceiveProps(nextProps) {
462 - Scheduler.yieldValue(
468 + Scheduler.unstable_yieldValue(
469 `UNSAFE_componentWillReceiveProps: ${this.props.text} -> ${
470 nextProps.text
471 }`,
@@ -512,7 +518,7 @@ describe('ReactLazy', () => {
518
519 it('resolves defaultProps on the outer wrapper but warns', async () => {
520 function T(props) {
515 - Scheduler.yieldValue(props.inner + ' ' + props.outer);
521 + Scheduler.unstable_yieldValue(props.inner + ' ' + props.outer);
522 return props.inner + ' ' + props.outer;
523 }
524 T.defaultProps = {inner: 'Hi'};
@@ -655,7 +661,7 @@ describe('ReactLazy', () => {
661 await Promise.resolve();
662 expect(() => {
663 expect(Scheduler);
658 - Scheduler.flushAll();
664 + Scheduler.unstable_flushAll();
665 }).toWarnDev([
666 'Invalid prop `inner` of type `string` supplied to `Add`, expected `number`.',
667 ]);
@@ -862,7 +868,7 @@ describe('ReactLazy', () => {
868
869 it('includes lazy-loaded component in warning stack', async () => {
870 const LazyFoo = lazy(() => {
865 - Scheduler.yieldValue('Started loading');
871 + Scheduler.unstable_yieldValue('Started loading');
872 const Foo = props => <div>{[<Text text="A" />, <Text text="B" />]}</div>;
873 return fakeImport(Foo);
874 });
@@ -905,7 +911,7 @@ describe('ReactLazy', () => {
911 }
912 return fakeImport(
913 React.forwardRef((props, ref) => {
908 - Scheduler.yieldValue('forwardRef');
914 + Scheduler.unstable_yieldValue('forwardRef');
915 return <Bar ref={ref} />;
916 }),
917 );
packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js
+2 -2
@@ -36,7 +36,7 @@ describe('memo', () => {
36 }
37
38 function Text(props) {
39 - Scheduler.yieldValue(props.text);
39 + Scheduler.unstable_yieldValue(props.text);
40 return <span prop={props.text} />;
41 }
42
@@ -184,7 +184,7 @@ describe('memo', () => {
184 return <Text text={count} />;
185 }
186 Counter = memo(Counter, (oldProps, newProps) => {
187 - Scheduler.yieldValue(
187 + Scheduler.unstable_yieldValue(
188 `Old count: ${oldProps.count}, New count: ${newProps.count}`,
189 );
190 return oldProps.count === newProps.count;
packages/react-reconciler/src/__tests__/ReactNewContext-test.internal.js
+44 -44
@@ -30,7 +30,7 @@ describe('ReactNewContext', () => {
30 });
31
32 function Text(props) {
33 - Scheduler.yieldValue(props.text);
33 + Scheduler.unstable_yieldValue(props.text);
34 return <span prop={props.text} />;
35 }
36
@@ -160,7 +160,7 @@ describe('ReactNewContext', () => {
160 const ContextConsumer = getConsumer(Context);
161
162 function Provider(props) {
163 - Scheduler.yieldValue('Provider');
163 + Scheduler.unstable_yieldValue('Provider');
164 return (
165 <Context.Provider value={props.value}>
166 {props.children}
@@ -169,11 +169,11 @@ describe('ReactNewContext', () => {
169 }
170
171 function Consumer(props) {
172 - Scheduler.yieldValue('Consumer');
172 + Scheduler.unstable_yieldValue('Consumer');
173 return (
174 <ContextConsumer>
175 {value => {
176 - Scheduler.yieldValue('Consumer render prop');
176 + Scheduler.unstable_yieldValue('Consumer render prop');
177 return <span prop={'Result: ' + value} />;
178 }}
179 </ContextConsumer>
@@ -185,13 +185,13 @@ describe('ReactNewContext', () => {
185 return false;
186 }
187 render() {
188 - Scheduler.yieldValue('Indirection');
188 + Scheduler.unstable_yieldValue('Indirection');
189 return this.props.children;
190 }
191 }
192
193 function App(props) {
194 - Scheduler.yieldValue('App');
194 + Scheduler.unstable_yieldValue('App');
195 return (
196 <Provider value={props.value}>
197 <Indirection>
@@ -229,7 +229,7 @@ describe('ReactNewContext', () => {
229 const ContextConsumer = getConsumer(Context);
230
231 function Provider(props) {
232 - Scheduler.yieldValue('Provider');
232 + Scheduler.unstable_yieldValue('Provider');
233 return (
234 <Context.Provider value={props.value}>
235 {props.children}
@@ -238,11 +238,11 @@ describe('ReactNewContext', () => {
238 }
239
240 function Consumer(props) {
241 - Scheduler.yieldValue('Consumer');
241 + Scheduler.unstable_yieldValue('Consumer');
242 return (
243 <ContextConsumer>
244 {value => {
245 - Scheduler.yieldValue('Consumer render prop');
245 + Scheduler.unstable_yieldValue('Consumer render prop');
246 return <span prop={'Result: ' + value} />;
247 }}
248 </ContextConsumer>
@@ -254,13 +254,13 @@ describe('ReactNewContext', () => {
254 return false;
255 }
256 render() {
257 - Scheduler.yieldValue('Indirection');
257 + Scheduler.unstable_yieldValue('Indirection');
258 return this.props.children;
259 }
260 }
261
262 function App(props) {
263 - Scheduler.yieldValue('App');
263 + Scheduler.unstable_yieldValue('App');
264 return (
265 <Provider value={props.value}>
266 <Indirection>
@@ -463,7 +463,7 @@ describe('ReactNewContext', () => {
463 const ContextConsumer = getConsumer(Context);
464
465 function Provider(props) {
466 - Scheduler.yieldValue('Provider');
466 + Scheduler.unstable_yieldValue('Provider');
467 return (
468 <Context.Provider value={props.value}>
469 {props.children}
@@ -472,11 +472,11 @@ describe('ReactNewContext', () => {
472 }
473
474 function Consumer(props) {
475 - Scheduler.yieldValue('Consumer');
475 + Scheduler.unstable_yieldValue('Consumer');
476 return (
477 <ContextConsumer>
478 {value => {
479 - Scheduler.yieldValue('Consumer render prop');
479 + Scheduler.unstable_yieldValue('Consumer render prop');
480 return <span prop={'Result: ' + value} />;
481 }}
482 </ContextConsumer>
@@ -488,13 +488,13 @@ describe('ReactNewContext', () => {
488 return false;
489 }
490 render() {
491 - Scheduler.yieldValue('Indirection');
491 + Scheduler.unstable_yieldValue('Indirection');
492 return this.props.children;
493 }
494 }
495
496 function App(props) {
497 - Scheduler.yieldValue('App');
497 + Scheduler.unstable_yieldValue('App');
498 return (
499 <Provider value={props.value}>
500 <Indirection>
@@ -605,7 +605,7 @@ describe('ReactNewContext', () => {
605 return (
606 <Consumer unstable_observedBits={0b01}>
607 {value => {
608 - Scheduler.yieldValue('Foo');
608 + Scheduler.unstable_yieldValue('Foo');
609 return <span prop={'Foo: ' + value.foo} />;
610 }}
611 </Consumer>
@@ -616,7 +616,7 @@ describe('ReactNewContext', () => {
616 return (
617 <Consumer unstable_observedBits={0b10}>
618 {value => {
619 - Scheduler.yieldValue('Bar');
619 + Scheduler.unstable_yieldValue('Bar');
620 return <span prop={'Bar: ' + value.bar} />;
621 }}
622 </Consumer>
@@ -704,7 +704,7 @@ describe('ReactNewContext', () => {
704 return (
705 <Consumer unstable_observedBits={0b01}>
706 {value => {
707 - Scheduler.yieldValue('Foo');
707 + Scheduler.unstable_yieldValue('Foo');
708 return (
709 <React.Fragment>
710 <span prop={'Foo: ' + value.foo} />
@@ -720,7 +720,7 @@ describe('ReactNewContext', () => {
720 return (
721 <Consumer unstable_observedBits={0b10}>
722 {value => {
723 - Scheduler.yieldValue('Bar');
723 + Scheduler.unstable_yieldValue('Bar');
724 return (
725 <React.Fragment>
726 <span prop={'Bar: ' + value.bar} />
@@ -808,7 +808,7 @@ describe('ReactNewContext', () => {
808 class Child extends React.Component {
809 state = {step: 0};
810 render() {
811 - Scheduler.yieldValue('Child');
811 + Scheduler.unstable_yieldValue('Child');
812 return (
813 <span
814 prop={`Context: ${this.props.context}, Step: ${
@@ -824,7 +824,7 @@ describe('ReactNewContext', () => {
824 <Context.Provider value={props.value}>
825 <Consumer>
826 {value => {
827 - Scheduler.yieldValue('Consumer render prop');
827 + Scheduler.unstable_yieldValue('Consumer render prop');
828 return <Child ref={inst => (child = inst)} context={value} />;
829 }}
830 </Consumer>
@@ -847,24 +847,24 @@ describe('ReactNewContext', () => {
847 const Consumer = getConsumer(Context);
848
849 function renderChildValue(value) {
850 - Scheduler.yieldValue('Consumer');
850 + Scheduler.unstable_yieldValue('Consumer');
851 return <span prop={value} />;
852 }
853
854 function ChildWithInlineRenderCallback() {
855 - Scheduler.yieldValue('ChildWithInlineRenderCallback');
855 + Scheduler.unstable_yieldValue('ChildWithInlineRenderCallback');
856 // Note: we are intentionally passing an inline arrow. Don't refactor.
857 return <Consumer>{value => renderChildValue(value)}</Consumer>;
858 }
859
860 function ChildWithCachedRenderCallback() {
861 - Scheduler.yieldValue('ChildWithCachedRenderCallback');
861 + Scheduler.unstable_yieldValue('ChildWithCachedRenderCallback');
862 return <Consumer>{renderChildValue}</Consumer>;
863 }
864
865 class PureIndirection extends React.PureComponent {
866 render() {
867 - Scheduler.yieldValue('PureIndirection');
867 + Scheduler.unstable_yieldValue('PureIndirection');
868 return (
869 <React.Fragment>
870 <ChildWithInlineRenderCallback />
@@ -876,7 +876,7 @@ describe('ReactNewContext', () => {
876
877 class App extends React.Component {
878 render() {
879 - Scheduler.yieldValue('App');
879 + Scheduler.unstable_yieldValue('App');
880 return (
881 <Context.Provider value={this.props.value}>
882 <PureIndirection />
@@ -988,7 +988,7 @@ describe('ReactNewContext', () => {
988 };
989
990 render() {
991 - Scheduler.yieldValue('App');
991 + Scheduler.unstable_yieldValue('App');
992 return (
993 <Context.Provider value={this.state.step}>
994 <StaticContent />
@@ -1016,7 +1016,7 @@ describe('ReactNewContext', () => {
1016 return (
1017 <ContextConsumer>
1018 {value => {
1019 - Scheduler.yieldValue('Consumer');
1019 + Scheduler.unstable_yieldValue('Consumer');
1020 return <span prop={value} />;
1021 }}
1022 </ContextConsumer>
@@ -1079,7 +1079,7 @@ describe('ReactNewContext', () => {
1079 const Context = React.createContext(0);
1080
1081 function Foo(props) {
1082 - Scheduler.yieldValue('Foo');
1082 + Scheduler.unstable_yieldValue('Foo');
1083 return null;
1084 }
1085
@@ -1119,14 +1119,14 @@ describe('ReactNewContext', () => {
1119 const Context = React.createContext(0);
1120
1121 function Child() {
1122 - Scheduler.yieldValue('Child');
1122 + Scheduler.unstable_yieldValue('Child');
1123 return <span prop="Child" />;
1124 }
1125
1126 const children = <Child />;
1127
1128 function App(props) {
1129 - Scheduler.yieldValue('App');
1129 + Scheduler.unstable_yieldValue('App');
1130 return (
1131 <Context.Provider value={props.value}>{children}</Context.Provider>
1132 );
@@ -1150,7 +1150,7 @@ describe('ReactNewContext', () => {
1150 const Context = React.createContext(0);
1151
1152 function Child() {
1153 - Scheduler.yieldValue('Child');
1153 + Scheduler.unstable_yieldValue('Child');
1154 return <span prop="Child" />;
1155 }
1156
@@ -1165,7 +1165,7 @@ describe('ReactNewContext', () => {
1165 return {legacyValue: this.state.legacyValue};
1166 }
1167 render() {
1168 - Scheduler.yieldValue('LegacyProvider');
1168 + Scheduler.unstable_yieldValue('LegacyProvider');
1169 return this.props.children;
1170 }
1171 }
@@ -1173,7 +1173,7 @@ describe('ReactNewContext', () => {
1173 class App extends React.Component {
1174 state = {value: 1};
1175 render() {
1176 - Scheduler.yieldValue('App');
1176 + Scheduler.unstable_yieldValue('App');
1177 return (
1178 <Context.Provider value={this.state.value}>
1179 {this.props.children}
@@ -1299,12 +1299,12 @@ describe('ReactNewContext', () => {
1299 };
1300
1301 renderConsumer = context => {
1302 - Scheduler.yieldValue('App#renderConsumer');
1302 + Scheduler.unstable_yieldValue('App#renderConsumer');
1303 return <span prop={this.state.text} />;
1304 };
1305
1306 render() {
1307 - Scheduler.yieldValue('App');
1307 + Scheduler.unstable_yieldValue('App');
1308 return (
1309 <Context.Provider value={this.props.value}>
1310 <Consumer>{this.renderConsumer}</Consumer>
@@ -1439,12 +1439,12 @@ describe('ReactNewContext', () => {
1439 };
1440
1441 renderConsumer = context => {
1442 - Scheduler.yieldValue('App#renderConsumer');
1442 + Scheduler.unstable_yieldValue('App#renderConsumer');
1443 return <span prop={this.state.text} />;
1444 };
1445
1446 render() {
1447 - Scheduler.yieldValue('App');
1447 + Scheduler.unstable_yieldValue('App');
1448 return (
1449 <Context.Provider value={this.props.value}>
1450 <Consumer>{this.renderConsumer}</Consumer>
@@ -1571,12 +1571,12 @@ describe('ReactNewContext', () => {
1571 };
1572
1573 renderConsumer = context => {
1574 - Scheduler.yieldValue('App#renderConsumer');
1574 + Scheduler.unstable_yieldValue('App#renderConsumer');
1575 return <span prop={this.state.text} />;
1576 };
1577
1578 render() {
1579 - Scheduler.yieldValue('App');
1579 + Scheduler.unstable_yieldValue('App');
1580 return (
1581 <Context.Provider value={this.props.value}>
1582 <Consumer>{this.renderConsumer}</Consumer>
@@ -1699,7 +1699,7 @@ describe('ReactNewContext', () => {
1699 return false;
1700 }
1701 render() {
1702 - Scheduler.yieldValue();
1702 + Scheduler.unstable_yieldValue();
1703 if (this.props.depth >= this.props.maxDepth) {
1704 return null;
1705 }
@@ -1777,7 +1777,7 @@ describe('ReactNewContext', () => {
1777 actions.forEach(action => {
1778 switch (action.type) {
1779 case FLUSH_ALL:
1780 - Scheduler.unstable_flushWithoutYielding();
1780 + Scheduler.unstable_flushAllWithoutAsserting();
1781 break;
1782 case FLUSH:
1783 Scheduler.unstable_flushNumberOfYields(action.unitsOfWork);
@@ -1795,7 +1795,7 @@ describe('ReactNewContext', () => {
1795 assertConsistentTree();
1796 });
1797
1798 - Scheduler.unstable_flushWithoutYielding();
1798 + Scheduler.unstable_flushAllWithoutAsserting();
1799 assertConsistentTree(finalExpectedValues);
1800 }
1801
packages/react-reconciler/src/__tests__/ReactNoopRendererAct-test.js
+2 -2
@@ -39,9 +39,9 @@ describe('ReactNoop.act()', () => {
39 function App() {
40 let [ctr, setCtr] = React.useState(0);
41 async function someAsyncFunction() {
42 - Scheduler.yieldValue('stage 1');
42 + Scheduler.unstable_yieldValue('stage 1');
43 await null;
44 - Scheduler.yieldValue('stage 2');
44 + Scheduler.unstable_yieldValue('stage 2');
45 await null;
46 setCtr(1);
47 }
packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.internal.js
+24 -14
@@ -57,7 +57,9 @@ describe('ReactSchedulerIntegration', () => {
57
58 it('has correct priority during rendering', () => {
59 function ReadPriority() {
60 - Scheduler.yieldValue('Priority: ' + getCurrentPriorityAsString());
60 + Scheduler.unstable_yieldValue(
61 + 'Priority: ' + getCurrentPriorityAsString(),
62 + );
63 return null;
64 }
65 ReactNoop.render(<ReadPriority />);
@@ -76,7 +78,9 @@ describe('ReactSchedulerIntegration', () => {
78
79 it('has correct priority when continuing a render after yielding', () => {
80 function ReadPriority() {
79 - Scheduler.yieldValue('Priority: ' + getCurrentPriorityAsString());
81 + Scheduler.unstable_yieldValue(
82 + 'Priority: ' + getCurrentPriorityAsString(),
83 + );
84 return null;
85 }
86
@@ -106,9 +110,11 @@ describe('ReactSchedulerIntegration', () => {
110 it('layout effects have immediate priority', () => {
111 const {useLayoutEffect} = React;
112 function ReadPriority() {
109 - Scheduler.yieldValue('Render priority: ' + getCurrentPriorityAsString());
113 + Scheduler.unstable_yieldValue(
114 + 'Render priority: ' + getCurrentPriorityAsString(),
115 + );
116 useLayoutEffect(() => {
111 - Scheduler.yieldValue(
117 + Scheduler.unstable_yieldValue(
118 'Layout priority: ' + getCurrentPriorityAsString(),
119 );
120 });
@@ -125,9 +131,11 @@ describe('ReactSchedulerIntegration', () => {
131 it('passive effects have the same priority as render', () => {
132 const {useEffect} = React;
133 function ReadPriority() {
128 - Scheduler.yieldValue('Render priority: ' + getCurrentPriorityAsString());
134 + Scheduler.unstable_yieldValue(
135 + 'Render priority: ' + getCurrentPriorityAsString(),
136 + );
137 useEffect(() => {
130 - Scheduler.yieldValue(
138 + Scheduler.unstable_yieldValue(
139 'Passive priority: ' + getCurrentPriorityAsString(),
140 );
141 });
@@ -153,7 +161,9 @@ describe('ReactSchedulerIntegration', () => {
161
162 it('after completing a level of work, infers priority of the next batch based on its expiration time', () => {
163 function App({label}) {
156 - Scheduler.yieldValue(`${label} [${getCurrentPriorityAsString()}]`);
164 + Scheduler.unstable_yieldValue(
165 + `${label} [${getCurrentPriorityAsString()}]`,
166 + );
167 return label;
168 }
169
@@ -172,20 +182,20 @@ describe('ReactSchedulerIntegration', () => {
182
183 const root = ReactNoop.createRoot();
184 root.render('Initial');
175 - Scheduler.flushAll();
185 + Scheduler.unstable_flushAll();
186
177 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'));
178 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('B'));
179 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('C'));
187 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
188 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
189 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
190
191 // Schedule a React render. React will request a paint after committing it.
192 root.render('Update');
193
194 // Advance time just to be sure the next tasks have lower priority
185 - Scheduler.advanceTime(2000);
195 + Scheduler.unstable_advanceTime(2000);
196
187 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('D'));
188 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('E'));
197 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
198 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('E'));
199
200 // Flush everything up to the next paint. Should yield after the
201 // React commit.
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+34 -32
@@ -40,12 +40,12 @@ describe('ReactSuspense', () => {
40 listeners = [{resolve, reject}];
41 setTimeout(() => {
42 if (textResourceShouldFail) {
43 - Scheduler.yieldValue(`Promise rejected [${text}]`);
43 + Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
44 status = 'rejected';
45 value = new Error('Failed to load: ' + text);
46 listeners.forEach(listener => listener.reject(value));
47 } else {
48 - Scheduler.yieldValue(`Promise resolved [${text}]`);
48 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
49 status = 'resolved';
50 value = text;
51 listeners.forEach(listener => listener.resolve(value));
@@ -72,7 +72,7 @@ describe('ReactSuspense', () => {
72 });
73
74 function Text(props) {
75 - Scheduler.yieldValue(props.text);
75 + Scheduler.unstable_yieldValue(props.text);
76 return props.text;
77 }
78
@@ -80,13 +80,13 @@ describe('ReactSuspense', () => {
80 const text = props.text;
81 try {
82 TextResource.read([props.text, props.ms]);
83 - Scheduler.yieldValue(text);
83 + Scheduler.unstable_yieldValue(text);
84 return text;
85 } catch (promise) {
86 if (typeof promise.then === 'function') {
87 - Scheduler.yieldValue(`Suspend! [${text}]`);
87 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
88 } else {
89 - Scheduler.yieldValue(`Error! [${text}]`);
89 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
90 }
91 throw promise;
92 }
@@ -94,12 +94,12 @@ describe('ReactSuspense', () => {
94
95 it('suspends rendering and continues later', () => {
96 function Bar(props) {
97 - Scheduler.yieldValue('Bar');
97 + Scheduler.unstable_yieldValue('Bar');
98 return props.children;
99 }
100
101 function Foo({renderBar}) {
102 - Scheduler.yieldValue('Foo');
102 + Scheduler.unstable_yieldValue('Foo');
103 return (
104 <Suspense fallback={<Text text="Loading..." />}>
105 {renderBar ? (
@@ -211,10 +211,10 @@ describe('ReactSuspense', () => {
211
212 function Async() {
213 if (!didResolve) {
214 - Scheduler.yieldValue('Suspend!');
214 + Scheduler.unstable_yieldValue('Suspend!');
215 throw thenable;
216 }
217 - Scheduler.yieldValue('Async');
217 + Scheduler.unstable_yieldValue('Async');
218 return 'Async';
219 }
220
@@ -266,10 +266,10 @@ describe('ReactSuspense', () => {
266 it('mounts a lazy class component in non-concurrent mode', async () => {
267 class Class extends React.Component {
268 componentDidMount() {
269 - Scheduler.yieldValue('Did mount: ' + this.props.label);
269 + Scheduler.unstable_yieldValue('Did mount: ' + this.props.label);
270 }
271 componentDidUpdate() {
272 - Scheduler.yieldValue('Did update: ' + this.props.label);
272 + Scheduler.unstable_yieldValue('Did update: ' + this.props.label);
273 }
274 render() {
275 return <Text text={this.props.label} />;
@@ -346,13 +346,13 @@ describe('ReactSuspense', () => {
346 it('a mounted class component can suspend without losing state', () => {
347 class TextWithLifecycle extends React.Component {
348 componentDidMount() {
349 - Scheduler.yieldValue(`Mount [${this.props.text}]`);
349 + Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
350 }
351 componentDidUpdate() {
352 - Scheduler.yieldValue(`Update [${this.props.text}]`);
352 + Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
353 }
354 componentWillUnmount() {
355 - Scheduler.yieldValue(`Unmount [${this.props.text}]`);
355 + Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
356 }
357 render() {
358 return <Text {...this.props} />;
@@ -363,15 +363,17 @@ describe('ReactSuspense', () => {
363 class AsyncTextWithLifecycle extends React.Component {
364 state = {step: 1};
365 componentDidMount() {
366 - Scheduler.yieldValue(`Mount [${this.props.text}:${this.state.step}]`);
366 + Scheduler.unstable_yieldValue(
367 + `Mount [${this.props.text}:${this.state.step}]`,
368 + );
369 }
370 componentDidUpdate() {
369 - Scheduler.yieldValue(
371 + Scheduler.unstable_yieldValue(
372 `Update [${this.props.text}:${this.state.step}]`,
373 );
374 }
375 componentWillUnmount() {
374 - Scheduler.yieldValue(
376 + Scheduler.unstable_yieldValue(
377 `Unmount [${this.props.text}:${this.state.step}]`,
378 );
379 }
@@ -381,13 +383,13 @@ describe('ReactSuspense', () => {
383 const ms = this.props.ms;
384 try {
385 TextResource.read([text, ms]);
384 - Scheduler.yieldValue(text);
386 + Scheduler.unstable_yieldValue(text);
387 return text;
388 } catch (promise) {
389 if (typeof promise.then === 'function') {
388 - Scheduler.yieldValue(`Suspend! [${text}]`);
390 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
391 } else {
390 - Scheduler.yieldValue(`Error! [${text}]`);
392 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
393 }
394 throw promise;
395 }
@@ -572,20 +574,20 @@ describe('ReactSuspense', () => {
574 it('suspends in a class that has componentWillUnmount and is then deleted', () => {
575 class AsyncTextWithUnmount extends React.Component {
576 componentWillUnmount() {
575 - Scheduler.yieldValue('will unmount');
577 + Scheduler.unstable_yieldValue('will unmount');
578 }
579 render() {
580 const text = this.props.text;
581 const ms = this.props.ms;
582 try {
583 TextResource.read([text, ms]);
582 - Scheduler.yieldValue(text);
584 + Scheduler.unstable_yieldValue(text);
585 return text;
586 } catch (promise) {
587 if (typeof promise.then === 'function') {
586 - Scheduler.yieldValue(`Suspend! [${text}]`);
588 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
589 } else {
588 - Scheduler.yieldValue(`Error! [${text}]`);
590 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
591 }
592 throw promise;
593 }
@@ -616,20 +618,20 @@ describe('ReactSuspense', () => {
618
619 useLayoutEffect(
620 () => {
619 - Scheduler.yieldValue('Did commit: ' + text);
621 + Scheduler.unstable_yieldValue('Did commit: ' + text);
622 },
623 [text],
624 );
625
626 try {
627 TextResource.read([props.text, props.ms]);
626 - Scheduler.yieldValue(text);
628 + Scheduler.unstable_yieldValue(text);
629 return text;
630 } catch (promise) {
631 if (typeof promise.then === 'function') {
630 - Scheduler.yieldValue(`Suspend! [${text}]`);
632 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
633 } else {
632 - Scheduler.yieldValue(`Error! [${text}]`);
634 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
635 }
636 throw promise;
637 }
@@ -852,13 +854,13 @@ describe('ReactSuspense', () => {
854 const fullText = `${text}:${step}`;
855 try {
856 TextResource.read([fullText, ms]);
855 - Scheduler.yieldValue(fullText);
857 + Scheduler.unstable_yieldValue(fullText);
858 return fullText;
859 } catch (promise) {
860 if (typeof promise.then === 'function') {
859 - Scheduler.yieldValue(`Suspend! [${fullText}]`);
861 + Scheduler.unstable_yieldValue(`Suspend! [${fullText}]`);
862 } else {
861 - Scheduler.yieldValue(`Error! [${fullText}]`);
863 + Scheduler.unstable_yieldValue(`Error! [${fullText}]`);
864 }
865 throw promise;
866 }
packages/react-reconciler/src/__tests__/ReactSuspenseFuzz-test.internal.js
+8 -8
@@ -56,7 +56,7 @@ describe('ReactSuspenseFuzz', () => {
56 };
57 const timeoutID = setTimeout(() => {
58 pendingTasks.delete(task);
59 - Scheduler.yieldValue(task.label);
59 + Scheduler.unstable_yieldValue(task.label);
60 setStep(i + 1);
61 }, remountAfter);
62 pendingTasks.add(task);
@@ -89,7 +89,7 @@ describe('ReactSuspenseFuzz', () => {
89 };
90 const timeoutID = setTimeout(() => {
91 pendingTasks.delete(task);
92 - Scheduler.yieldValue(task.label);
92 + Scheduler.unstable_yieldValue(task.label);
93 setStep([i + 1, suspendFor]);
94 }, beginAfter);
95 pendingTasks.add(task);
@@ -121,36 +121,36 @@ describe('ReactSuspenseFuzz', () => {
121 setTimeout(() => {
122 cache.set(fullText, fullText);
123 pendingTasks.delete(task);
124 - Scheduler.yieldValue(task.label);
124 + Scheduler.unstable_yieldValue(task.label);
125 resolve();
126 }, delay);
127 },
128 };
129 cache.set(fullText, thenable);
130 - Scheduler.yieldValue(`Suspended! [${fullText}]`);
130 + Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
131 throw thenable;
132 } else if (typeof resolvedText.then === 'function') {
133 const thenable = resolvedText;
134 - Scheduler.yieldValue(`Suspended! [${fullText}]`);
134 + Scheduler.unstable_yieldValue(`Suspended! [${fullText}]`);
135 throw thenable;
136 }
137 } else {
138 resolvedText = fullText;
139 }
140
141 - Scheduler.yieldValue(resolvedText);
141 + Scheduler.unstable_yieldValue(resolvedText);
142 return resolvedText;
143 }
144
145 function resolveAllTasks() {
146 - Scheduler.unstable_flushWithoutYielding();
146 + Scheduler.unstable_flushAllWithoutAsserting();
147 let elapsedTime = 0;
148 while (pendingTasks && pendingTasks.size > 0) {
149 if ((elapsedTime += 1000) > 1000000) {
150 throw new Error('Something did not resolve properly.');
151 }
152 ReactNoop.act(() => jest.advanceTimersByTime(1000));
153 - Scheduler.unstable_flushWithoutYielding();
153 + Scheduler.unstable_flushAllWithoutAsserting();
154 }
155 }
156
packages/react-reconciler/src/__tests__/ReactSuspenseList-test.internal.js
+7 -7
@@ -21,7 +21,7 @@ describe('ReactSuspenseList', () => {
21 });
22
23 function Text(props) {
24 - Scheduler.yieldValue(props.text);
24 + Scheduler.unstable_yieldValue(props.text);
25 return <span>{props.text}</span>;
26 }
27
@@ -29,7 +29,7 @@ describe('ReactSuspenseList', () => {
29 let resolved = false;
30 let Component = function() {
31 if (!resolved) {
32 - Scheduler.yieldValue('Suspend! [' + text + ']');
32 + Scheduler.unstable_yieldValue('Suspend! [' + text + ']');
33 throw promise;
34 }
35 return <Text text={text} />;
@@ -54,7 +54,7 @@ describe('ReactSuspenseList', () => {
54
55 ReactNoop.render(<Foo />);
56
57 - expect(() => Scheduler.flushAll()).toWarnDev([
57 + expect(() => Scheduler.unstable_flushAll()).toWarnDev([
58 'Warning: "something" is not a supported revealOrder on ' +
59 '<SuspenseList />. Did you mean "together", "forwards" or "backwards"?' +
60 '\n in SuspenseList (at **)' +
@@ -73,7 +73,7 @@ describe('ReactSuspenseList', () => {
73
74 ReactNoop.render(<Foo />);
75
76 - expect(() => Scheduler.flushAll()).toWarnDev([
76 + expect(() => Scheduler.unstable_flushAll()).toWarnDev([
77 'Warning: "TOGETHER" is not a valid value for revealOrder on ' +
78 '<SuspenseList />. Use lowercase "together" instead.' +
79 '\n in SuspenseList (at **)' +
@@ -92,7 +92,7 @@ describe('ReactSuspenseList', () => {
92
93 ReactNoop.render(<Foo />);
94
95 - expect(() => Scheduler.flushAll()).toWarnDev([
95 + expect(() => Scheduler.unstable_flushAll()).toWarnDev([
96 'Warning: "forward" is not a valid value for revealOrder on ' +
97 '<SuspenseList />. React uses the -s suffix in the spelling. ' +
98 'Use "forwards" instead.' +
@@ -1050,12 +1050,12 @@ describe('ReactSuspenseList', () => {
1050
1051 expect(Scheduler).toFlushAndYieldThrough(['A']);
1052
1053 - Scheduler.advanceTime(300);
1053 + Scheduler.unstable_advanceTime(300);
1054 jest.advanceTimersByTime(300);
1055
1056 expect(Scheduler).toFlushAndYieldThrough(['B']);
1057
1058 - Scheduler.advanceTime(300);
1058 + Scheduler.unstable_advanceTime(300);
1059 jest.advanceTimersByTime(300);
1060
1061 // We've still not been able to show anything on the screen even though
packages/react-reconciler/src/__tests__/ReactSuspensePlaceholder-test.internal.js
+14 -14
@@ -46,12 +46,12 @@ describe('ReactSuspensePlaceholder', () => {
46 listeners = [{resolve, reject}];
47 setTimeout(() => {
48 if (textResourceShouldFail) {
49 - Scheduler.yieldValue(`Promise rejected [${text}]`);
49 + Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
50 status = 'rejected';
51 value = new Error('Failed to load: ' + text);
52 listeners.forEach(listener => listener.reject(value));
53 } else {
54 - Scheduler.yieldValue(`Promise resolved [${text}]`);
54 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
55 status = 'resolved';
56 value = text;
57 listeners.forEach(listener => listener.resolve(value));
@@ -78,22 +78,22 @@ describe('ReactSuspensePlaceholder', () => {
78 });
79
80 function Text({fakeRenderDuration = 0, text = 'Text'}) {
81 - Scheduler.advanceTime(fakeRenderDuration);
82 - Scheduler.yieldValue(text);
81 + Scheduler.unstable_advanceTime(fakeRenderDuration);
82 + Scheduler.unstable_yieldValue(text);
83 return text;
84 }
85
86 function AsyncText({fakeRenderDuration = 0, ms, text}) {
87 - Scheduler.advanceTime(fakeRenderDuration);
87 + Scheduler.unstable_advanceTime(fakeRenderDuration);
88 try {
89 TextResource.read([text, ms]);
90 - Scheduler.yieldValue(text);
90 + Scheduler.unstable_yieldValue(text);
91 return text;
92 } catch (promise) {
93 if (typeof promise.then === 'function') {
94 - Scheduler.yieldValue(`Suspend! [${text}]`);
94 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
95 } else {
96 - Scheduler.yieldValue(`Error! [${text}]`);
96 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
97 }
98 throw promise;
99 }
@@ -103,7 +103,7 @@ describe('ReactSuspensePlaceholder', () => {
103 class HiddenText extends React.PureComponent {
104 render() {
105 const text = this.props.text;
106 - Scheduler.yieldValue(text);
106 + Scheduler.unstable_yieldValue(text);
107 return <span hidden={true}>{text}</span>;
108 }
109 }
@@ -278,19 +278,19 @@ describe('ReactSuspensePlaceholder', () => {
278 onRender = jest.fn();
279
280 const Fallback = () => {
281 - Scheduler.yieldValue('Fallback');
282 - Scheduler.advanceTime(10);
281 + Scheduler.unstable_yieldValue('Fallback');
282 + Scheduler.unstable_advanceTime(10);
283 return 'Loading...';
284 };
285
286 const Suspending = () => {
287 - Scheduler.yieldValue('Suspending');
288 - Scheduler.advanceTime(2);
287 + Scheduler.unstable_yieldValue('Suspending');
288 + Scheduler.unstable_advanceTime(2);
289 return <AsyncText ms={1000} text="Loaded" fakeRenderDuration={1} />;
290 };
291
292 App = ({shouldSuspend, text = 'Text', textRenderDuration = 5}) => {
293 - Scheduler.yieldValue('App');
293 + Scheduler.unstable_yieldValue('App');
294 return (
295 <Profiler id="root" onRender={onRender}>
296 <Suspense fallback={<Fallback />}>
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.internal.js
+101 -99
@@ -26,10 +26,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
26 return new Promise((resolve, reject) =>
27 setTimeout(() => {
28 if (textResourceShouldFail) {
29 - Scheduler.yieldValue(`Promise rejected [${text}]`);
29 + Scheduler.unstable_yieldValue(`Promise rejected [${text}]`);
30 reject(new Error('Failed to load: ' + text));
31 } else {
32 - Scheduler.yieldValue(`Promise resolved [${text}]`);
32 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
33 resolve(text);
34 }
35 }, ms),
@@ -66,7 +66,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
66 }
67
68 function Text(props) {
69 - Scheduler.yieldValue(props.text);
69 + Scheduler.unstable_yieldValue(props.text);
70 return <span prop={props.text} ref={props.hostRef} />;
71 }
72
@@ -74,13 +74,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
74 const text = props.text;
75 try {
76 TextResource.read([props.text, props.ms]);
77 - Scheduler.yieldValue(text);
77 + Scheduler.unstable_yieldValue(text);
78 return <span prop={text} />;
79 } catch (promise) {
80 if (typeof promise.then === 'function') {
81 - Scheduler.yieldValue(`Suspend! [${text}]`);
81 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
82 } else {
83 - Scheduler.yieldValue(`Error! [${text}]`);
83 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
84 }
85 throw promise;
86 }
@@ -97,7 +97,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
97
98 ReactNoop.render(<Foo />);
99
100 - expect(() => Scheduler.flushAll()).toWarnDev([
100 + expect(() => Scheduler.unstable_flushAll()).toWarnDev([
101 'Warning: maxDuration has been removed from React. ' +
102 'Remove the maxDuration prop.' +
103 '\n in Suspense (at **)' +
@@ -107,12 +107,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
107
108 it('does not restart rendering for initial render', async () => {
109 function Bar(props) {
110 - Scheduler.yieldValue('Bar');
110 + Scheduler.unstable_yieldValue('Bar');
111 return props.children;
112 }
113
114 function Foo() {
115 - Scheduler.yieldValue('Foo');
115 + Scheduler.unstable_yieldValue('Foo');
116 return (
117 <React.Fragment>
118 <Suspense fallback={<Text text="Loading..." />}>
@@ -142,7 +142,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
142 expect(ReactNoop.getChildren()).toEqual([]);
143
144 // Flush the promise completely
145 - Scheduler.advanceTime(100);
145 + Scheduler.unstable_advanceTime(100);
146 await advanceTimers(100);
147 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
148
@@ -171,12 +171,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
171
172 it('suspends rendering and continues later', async () => {
173 function Bar(props) {
174 - Scheduler.yieldValue('Bar');
174 + Scheduler.unstable_yieldValue('Bar');
175 return props.children;
176 }
177
178 function Foo({renderBar}) {
179 - Scheduler.yieldValue('Foo');
179 + Scheduler.unstable_yieldValue('Foo');
180 return (
181 <Suspense fallback={<Text text="Loading..." />}>
182 {renderBar ? (
@@ -772,7 +772,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
772 <AsyncText text="B" ms={100} />
773 </Suspense>,
774 );
775 - Scheduler.advanceTime(10000);
775 + Scheduler.unstable_advanceTime(10000);
776 expect(Scheduler).toHaveYielded([
777 'Suspend! [A]',
778 'Suspend! [B]',
@@ -884,10 +884,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
884 it('flushes all expired updates in a single batch', async () => {
885 class Foo extends React.Component {
886 componentDidUpdate() {
887 - Scheduler.yieldValue('Commit: ' + this.props.text);
887 + Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
888 }
889 componentDidMount() {
890 - Scheduler.yieldValue('Commit: ' + this.props.text);
890 + Scheduler.unstable_yieldValue('Commit: ' + this.props.text);
891 }
892 render() {
893 return (
@@ -909,7 +909,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
909 jest.advanceTimersByTime(1000);
910 ReactNoop.render(<Foo text="goodbye" />);
911
912 - Scheduler.advanceTime(10000);
912 + Scheduler.unstable_advanceTime(10000);
913 jest.advanceTimersByTime(10000);
914
915 expect(Scheduler).toHaveYielded([
@@ -919,7 +919,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
919 ]);
920 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
921
922 - Scheduler.advanceTime(20000);
922 + Scheduler.unstable_advanceTime(20000);
923 await advanceTimers(20000);
924 expect(Scheduler).toHaveYielded(['Promise resolved [goodbye]']);
925 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
@@ -932,7 +932,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
932 // Regression test. This test used to fall into an infinite loop.
933 function ExpensiveText({text}) {
934 // This causes the update to expire.
935 - Scheduler.advanceTime(10000);
935 + Scheduler.unstable_advanceTime(10000);
936 // Then something suspends.
937 return <AsyncText text={text} ms={200000} />;
938 }
@@ -1044,7 +1044,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1044
1045 // Update.
1046 text.current.setState({step: 2}, () =>
1047 - Scheduler.yieldValue('Update did commit'),
1047 + Scheduler.unstable_yieldValue('Update did commit'),
1048 );
1049
1050 expect(ReactNoop.flushNextYield()).toEqual([
@@ -1078,10 +1078,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1078 it('does not re-render siblings in loose mode', async () => {
1079 class TextWithLifecycle extends React.Component {
1080 componentDidMount() {
1081 - Scheduler.yieldValue(`Mount [${this.props.text}]`);
1081 + Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1082 }
1083 componentDidUpdate() {
1084 - Scheduler.yieldValue(`Update [${this.props.text}]`);
1084 + Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1085 }
1086 render() {
1087 return <Text {...this.props} />;
@@ -1090,10 +1090,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1090
1091 class AsyncTextWithLifecycle extends React.Component {
1092 componentDidMount() {
1093 - Scheduler.yieldValue(`Mount [${this.props.text}]`);
1093 + Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1094 }
1095 componentDidUpdate() {
1096 - Scheduler.yieldValue(`Update [${this.props.text}]`);
1096 + Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1097 }
1098 render() {
1099 return <AsyncText {...this.props} />;
@@ -1111,7 +1111,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1111 }
1112
1113 ReactNoop.renderLegacySyncRoot(<App />, () =>
1114 - Scheduler.yieldValue('Commit root'),
1114 + Scheduler.unstable_yieldValue('Commit root'),
1115 );
1116 expect(Scheduler).toHaveYielded([
1117 'A',
@@ -1154,24 +1154,24 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1154 constructor(props) {
1155 super(props);
1156 const text = props.text;
1157 - Scheduler.yieldValue('constructor');
1157 + Scheduler.unstable_yieldValue('constructor');
1158 try {
1159 TextResource.read([props.text, props.ms]);
1160 this.state = {text};
1161 } catch (promise) {
1162 if (typeof promise.then === 'function') {
1163 - Scheduler.yieldValue(`Suspend! [${text}]`);
1163 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1164 } else {
1165 - Scheduler.yieldValue(`Error! [${text}]`);
1165 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
1166 }
1167 throw promise;
1168 }
1169 }
1170 componentDidMount() {
1171 - Scheduler.yieldValue('componentDidMount');
1171 + Scheduler.unstable_yieldValue('componentDidMount');
1172 }
1173 render() {
1174 - Scheduler.yieldValue(this.state.text);
1174 + Scheduler.unstable_yieldValue(this.state.text);
1175 return <span prop={this.state.text} />;
1176 }
1177 }
@@ -1248,7 +1248,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1248 const child = useRef(null);
1249
1250 useLayoutEffect(() => {
1251 - Scheduler.yieldValue(ReactNoop.getPendingChildrenAsJSX());
1251 + Scheduler.unstable_yieldValue(ReactNoop.getPendingChildrenAsJSX());
1252 });
1253
1254 return (
@@ -1291,7 +1291,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1291 const child = useRef(null);
1292
1293 useLayoutEffect(() => {
1294 - Scheduler.yieldValue('Child is hidden: ' + child.current.hidden);
1294 + Scheduler.unstable_yieldValue(
1295 + 'Child is hidden: ' + child.current.hidden,
1296 + );
1297 });
1298
1299 return (
@@ -1329,13 +1331,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1331 it('does not call lifecycles of a suspended component', async () => {
1332 class TextWithLifecycle extends React.Component {
1333 componentDidMount() {
1332 - Scheduler.yieldValue(`Mount [${this.props.text}]`);
1334 + Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1335 }
1336 componentDidUpdate() {
1335 - Scheduler.yieldValue(`Update [${this.props.text}]`);
1337 + Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1338 }
1339 componentWillUnmount() {
1338 - Scheduler.yieldValue(`Unmount [${this.props.text}]`);
1340 + Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
1341 }
1342 render() {
1343 return <Text {...this.props} />;
@@ -1344,26 +1346,26 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1346
1347 class AsyncTextWithLifecycle extends React.Component {
1348 componentDidMount() {
1347 - Scheduler.yieldValue(`Mount [${this.props.text}]`);
1349 + Scheduler.unstable_yieldValue(`Mount [${this.props.text}]`);
1350 }
1351 componentDidUpdate() {
1350 - Scheduler.yieldValue(`Update [${this.props.text}]`);
1352 + Scheduler.unstable_yieldValue(`Update [${this.props.text}]`);
1353 }
1354 componentWillUnmount() {
1353 - Scheduler.yieldValue(`Unmount [${this.props.text}]`);
1355 + Scheduler.unstable_yieldValue(`Unmount [${this.props.text}]`);
1356 }
1357 render() {
1358 const text = this.props.text;
1359 const ms = this.props.ms;
1360 try {
1361 TextResource.read([text, ms]);
1360 - Scheduler.yieldValue(text);
1362 + Scheduler.unstable_yieldValue(text);
1363 return <span prop={text} />;
1364 } catch (promise) {
1365 if (typeof promise.then === 'function') {
1364 - Scheduler.yieldValue(`Suspend! [${text}]`);
1366 + Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
1367 } else {
1366 - Scheduler.yieldValue(`Error! [${text}]`);
1368 + Scheduler.unstable_yieldValue(`Error! [${text}]`);
1369 }
1370 throw promise;
1371 }
@@ -1381,7 +1383,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1383 }
1384
1385 ReactNoop.renderLegacySyncRoot(<App />, () =>
1384 - Scheduler.yieldValue('Commit root'),
1386 + Scheduler.unstable_yieldValue('Commit root'),
1387 );
1388 expect(Scheduler).toHaveYielded([
1389 'A',
@@ -1407,7 +1409,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1409
1410 it('suspends for longer if something took a long (CPU bound) time to render', async () => {
1411 function Foo({renderContent}) {
1410 - Scheduler.yieldValue('Foo');
1412 + Scheduler.unstable_yieldValue('Foo');
1413 return (
1414 <Suspense fallback={<Text text="Loading..." />}>
1415 {renderContent ? <AsyncText text="A" ms={5000} /> : null}
@@ -1419,12 +1421,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1421 expect(Scheduler).toFlushAndYield(['Foo']);
1422
1423 ReactNoop.render(<Foo renderContent={true} />);
1422 - Scheduler.advanceTime(100);
1424 + Scheduler.unstable_advanceTime(100);
1425 await advanceTimers(100);
1426 // Start rendering
1427 expect(Scheduler).toFlushAndYieldThrough(['Foo']);
1428 // For some reason it took a long time to render Foo.
1427 - Scheduler.advanceTime(1250);
1429 + Scheduler.unstable_advanceTime(1250);
1430 await advanceTimers(1250);
1431 expect(Scheduler).toFlushAndYield([
1432 // A suspends
@@ -1435,7 +1437,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1437 expect(ReactNoop.getChildren()).toEqual([]);
1438
1439 // Flush some of the time
1438 - Scheduler.advanceTime(450);
1440 + Scheduler.unstable_advanceTime(450);
1441 await advanceTimers(450);
1442 // Because we've already been waiting for so long we can
1443 // wait a bit longer. Still nothing...
@@ -1443,14 +1445,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1445 expect(ReactNoop.getChildren()).toEqual([]);
1446
1447 // Eventually we'll show the fallback.
1446 - Scheduler.advanceTime(500);
1448 + Scheduler.unstable_advanceTime(500);
1449 await advanceTimers(500);
1450 // No need to rerender.
1451 expect(Scheduler).toFlushWithoutYielding();
1452 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1453
1454 // Flush the promise completely
1453 - Scheduler.advanceTime(4500);
1455 + Scheduler.unstable_advanceTime(4500);
1456 await advanceTimers(4500);
1457 // Renders successfully
1458 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
@@ -1460,7 +1462,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1462
1463 it('does not suspends if a fallback has been shown for a long time', async () => {
1464 function Foo() {
1463 - Scheduler.yieldValue('Foo');
1465 + Scheduler.unstable_yieldValue('Foo');
1466 return (
1467 <Suspense fallback={<Text text="Loading..." />}>
1468 <AsyncText text="A" ms={5000} />
@@ -1485,7 +1487,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1487 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1488
1489 // Wait a long time.
1488 - Scheduler.advanceTime(5000);
1490 + Scheduler.unstable_advanceTime(5000);
1491 await advanceTimers(5000);
1492 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
1493
@@ -1504,7 +1506,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1506 ]);
1507
1508 // Flush the last promise completely
1507 - Scheduler.advanceTime(5000);
1509 + Scheduler.unstable_advanceTime(5000);
1510 await advanceTimers(5000);
1511 // Renders successfully
1512 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
@@ -1514,7 +1516,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1516
1517 it('does suspend if a fallback has been shown for a short time', async () => {
1518 function Foo() {
1517 - Scheduler.yieldValue('Foo');
1519 + Scheduler.unstable_yieldValue('Foo');
1520 return (
1521 <Suspense fallback={<Text text="Loading..." />}>
1522 <AsyncText text="A" ms={200} />
@@ -1539,7 +1541,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1541 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1542
1543 // Wait a short time.
1542 - Scheduler.advanceTime(250);
1544 + Scheduler.unstable_advanceTime(250);
1545 await advanceTimers(250);
1546 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
1547
@@ -1554,7 +1556,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1556 // wait a bit longer. Still nothing...
1557 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1558
1557 - Scheduler.advanceTime(200);
1559 + Scheduler.unstable_advanceTime(200);
1560 await advanceTimers(200);
1561
1562 // Before we commit another Promise resolves.
@@ -1568,7 +1570,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1570
1571 it('does not suspend for very long after a higher priority update', async () => {
1572 function Foo({renderContent}) {
1571 - Scheduler.yieldValue('Foo');
1573 + Scheduler.unstable_yieldValue('Foo');
1574 return (
1575 <Suspense fallback={<Text text="Loading..." />}>
1576 {renderContent ? <AsyncText text="A" ms={5000} /> : null}
@@ -1585,7 +1587,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1587 expect(Scheduler).toFlushAndYieldThrough(['Foo']);
1588
1589 // Advance some time.
1588 - Scheduler.advanceTime(100);
1590 + Scheduler.unstable_advanceTime(100);
1591 await advanceTimers(100);
1592
1593 expect(Scheduler).toFlushAndYield([
@@ -1597,7 +1599,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1599 expect(ReactNoop.getChildren()).toEqual([]);
1600
1601 // Flush some of the time
1600 - Scheduler.advanceTime(500);
1602 + Scheduler.unstable_advanceTime(500);
1603 expect(() => {
1604 jest.advanceTimersByTime(500);
1605 }).toWarnDev(
@@ -1616,7 +1618,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1618
1619 it('warns when suspending inside discrete update', async () => {
1620 function A() {
1619 - Scheduler.yieldValue('A');
1621 + Scheduler.unstable_yieldValue('A');
1622 TextResource.read(['A', 1000]);
1623 return 'A';
1624 }
@@ -1650,7 +1652,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1652
1653 // Timeout and commit the fallback
1654 expect(() => {
1653 - Scheduler.flushAll();
1655 + Scheduler.unstable_flushAll();
1656 }).toWarnDev(
1657 'The following components suspended during a user-blocking update: A, C',
1658 {withoutStack: true},
@@ -1659,7 +1661,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1661
1662 it('shows the parent fallback if the inner fallback should be avoided', async () => {
1663 function Foo({showC}) {
1662 - Scheduler.yieldValue('Foo');
1664 + Scheduler.unstable_yieldValue('Foo');
1665 return (
1666 <Suspense fallback={<Text text="Initial load..." />}>
1667 <Suspense
@@ -1683,7 +1685,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1685 expect(ReactNoop.getChildren()).toEqual([span('Initial load...')]);
1686
1687 // Eventually we resolve and show the data.
1686 - Scheduler.advanceTime(5000);
1688 + Scheduler.unstable_advanceTime(5000);
1689 await advanceTimers(5000);
1690 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
1691 expect(Scheduler).toFlushAndYield(['A', 'B']);
@@ -1699,7 +1701,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1701 'B',
1702 ]);
1703 // Flush to skip suspended time.
1702 - Scheduler.advanceTime(600);
1704 + Scheduler.unstable_advanceTime(600);
1705 await advanceTimers(600);
1706 // Since the optional suspense boundary is already showing its content,
1707 // we have to use the inner fallback instead.
@@ -1710,7 +1712,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1712 ]);
1713
1714 // Later we load the data.
1713 - Scheduler.advanceTime(5000);
1715 + Scheduler.unstable_advanceTime(5000);
1716 await advanceTimers(5000);
1717 expect(Scheduler).toHaveYielded(['Promise resolved [C]']);
1718 expect(Scheduler).toFlushAndYield(['A', 'C']);
@@ -1719,7 +1721,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1721
1722 it('favors showing the inner fallback for nested top level avoided fallback', async () => {
1723 function Foo({showB}) {
1722 - Scheduler.yieldValue('Foo');
1724 + Scheduler.unstable_yieldValue('Foo');
1725 return (
1726 <Suspense
1727 unstable_avoidThisFallback={true}
@@ -1742,7 +1744,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1744 'Loading B...',
1745 ]);
1746 // Flush to skip suspended time.
1745 - Scheduler.advanceTime(600);
1747 + Scheduler.unstable_advanceTime(600);
1748 await advanceTimers(600);
1749
1750 expect(ReactNoop.getChildren()).toEqual([span('A'), span('Loading B...')]);
@@ -1750,7 +1752,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1752
1753 it('keeps showing an avoided parent fallback if it is already showing', async () => {
1754 function Foo({showB}) {
1753 - Scheduler.yieldValue('Foo');
1755 + Scheduler.unstable_yieldValue('Foo');
1756 return (
1757 <Suspense fallback={<Text text="Initial load..." />}>
1758 <Suspense
@@ -1785,7 +1787,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1787 expect(ReactNoop.getChildren()).toEqual([span('A')]);
1788
1789 // Flush to skip suspended time.
1788 - Scheduler.advanceTime(600);
1790 + Scheduler.unstable_advanceTime(600);
1791 await advanceTimers(600);
1792
1793 expect(ReactNoop.getChildren()).toEqual([span('A'), span('Loading B...')]);
@@ -1809,7 +1811,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1811
1812 // Took a long time to render. This is to ensure we get a long suspense time.
1813 // Could also use something like withSuspenseConfig to simulate this.
1812 - Scheduler.advanceTime(1500);
1814 + Scheduler.unstable_advanceTime(1500);
1815 await advanceTimers(1500);
1816
1817 expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading A...']);
@@ -1826,14 +1828,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1828 expect(ReactNoop.getChildren()).toEqual([]);
1829
1830 // Advance time a little bit.
1829 - Scheduler.advanceTime(150);
1831 + Scheduler.unstable_advanceTime(150);
1832 await advanceTimers(150);
1833
1834 // We should not have committed yet because we had a long suspense time.
1835 expect(ReactNoop.getChildren()).toEqual([]);
1836
1837 // Flush to skip suspended time.
1836 - Scheduler.advanceTime(600);
1838 + Scheduler.unstable_advanceTime(600);
1839 await advanceTimers(600);
1840
1841 expect(ReactNoop.getChildren()).toEqual([span('Loading A...')]);
@@ -1861,12 +1863,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1863
1864 expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']);
1865 // Only a short time is needed to unsuspend the initial loading state.
1864 - Scheduler.advanceTime(400);
1866 + Scheduler.unstable_advanceTime(400);
1867 await advanceTimers(400);
1868 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1869
1870 // Later we load the data.
1869 - Scheduler.advanceTime(5000);
1871 + Scheduler.unstable_advanceTime(5000);
1872 await advanceTimers(5000);
1873 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
1874 expect(Scheduler).toFlushAndYield(['A']);
@@ -1879,11 +1881,11 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1881 );
1882
1883 expect(Scheduler).toFlushAndYield(['Suspend! [B]', 'Loading...']);
1882 - Scheduler.advanceTime(1000);
1884 + Scheduler.unstable_advanceTime(1000);
1885 await advanceTimers(1000);
1886 // Even after a second, we have still not yet flushed the loading state.
1887 expect(ReactNoop.getChildren()).toEqual([span('A')]);
1886 - Scheduler.advanceTime(1100);
1888 + Scheduler.unstable_advanceTime(1100);
1889 await advanceTimers(1100);
1890 // After the timeout, we do show the loading state.
1891 expect(ReactNoop.getChildren()).toEqual([
@@ -1891,7 +1893,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1893 span('Loading...'),
1894 ]);
1895 // Later we load the data.
1894 - Scheduler.advanceTime(3000);
1896 + Scheduler.unstable_advanceTime(3000);
1897 await advanceTimers(3000);
1898 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
1899 expect(Scheduler).toFlushAndYield(['B']);
@@ -1925,13 +1927,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1927
1928 expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']);
1929 // Only a short time is needed to unsuspend the initial loading state.
1928 - Scheduler.advanceTime(400);
1930 + Scheduler.unstable_advanceTime(400);
1931 await advanceTimers(400);
1932 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
1933 });
1934
1935 // Later we load the data.
1934 - Scheduler.advanceTime(5000);
1936 + Scheduler.unstable_advanceTime(5000);
1937 await advanceTimers(5000);
1938 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
1939 expect(Scheduler).toFlushAndYield(['A']);
@@ -1945,11 +1947,11 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1947 );
1948
1949 expect(Scheduler).toFlushAndYield(['Suspend! [B]', 'Loading...']);
1948 - Scheduler.advanceTime(1000);
1950 + Scheduler.unstable_advanceTime(1000);
1951 await advanceTimers(1000);
1952 // Even after a second, we have still not yet flushed the loading state.
1953 expect(ReactNoop.getChildren()).toEqual([span('A')]);
1952 - Scheduler.advanceTime(1100);
1954 + Scheduler.unstable_advanceTime(1100);
1955 await advanceTimers(1100);
1956 // After the timeout, we do show the loading state.
1957 expect(ReactNoop.getChildren()).toEqual([
@@ -1958,7 +1960,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1960 ]);
1961 });
1962 // Later we load the data.
1961 - Scheduler.advanceTime(3000);
1963 + Scheduler.unstable_advanceTime(3000);
1964 await advanceTimers(3000);
1965 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
1966 expect(Scheduler).toFlushAndYield(['B']);
@@ -1995,13 +1997,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1997
1998 expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']);
1999 // Only a short time is needed to unsuspend the initial loading state.
1998 - Scheduler.advanceTime(400);
2000 + Scheduler.unstable_advanceTime(400);
2001 await advanceTimers(400);
2002 expect(ReactNoop.getChildren()).toEqual([span('Loading...')]);
2003 });
2004
2005 // Later we load the data.
2004 - Scheduler.advanceTime(5000);
2006 + Scheduler.unstable_advanceTime(5000);
2007 await advanceTimers(5000);
2008 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
2009 expect(Scheduler).toFlushAndYield(['A']);
@@ -2015,11 +2017,11 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2017 );
2018
2019 expect(Scheduler).toFlushAndYield(['Suspend! [B]', 'Loading...']);
2018 - Scheduler.advanceTime(1000);
2020 + Scheduler.unstable_advanceTime(1000);
2021 await advanceTimers(1000);
2022 // Even after a second, we have still not yet flushed the loading state.
2023 expect(ReactNoop.getChildren()).toEqual([span('A')]);
2022 - Scheduler.advanceTime(1100);
2024 + Scheduler.unstable_advanceTime(1100);
2025 await advanceTimers(1100);
2026 // After the timeout, we do show the loading state.
2027 expect(ReactNoop.getChildren()).toEqual([
@@ -2028,7 +2030,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2030 ]);
2031 });
2032 // Later we load the data.
2031 - Scheduler.advanceTime(3000);
2033 + Scheduler.unstable_advanceTime(3000);
2034 await advanceTimers(3000);
2035 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
2036 expect(Scheduler).toFlushAndYield(['B']);
@@ -2048,7 +2050,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2050 // Initial render.
2051 ReactNoop.render(<App page="A" />);
2052 expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']);
2051 - Scheduler.advanceTime(2000);
2053 + Scheduler.unstable_advanceTime(2000);
2054 await advanceTimers(2000);
2055 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
2056 expect(Scheduler).toFlushAndYield(['A']);
@@ -2069,7 +2071,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2071 expect(Scheduler).toFlushAndYield(['Suspend! [B]', 'Loading...']);
2072 // Suspended
2073 expect(ReactNoop.getChildren()).toEqual([span('A')]);
2072 - Scheduler.advanceTime(500);
2074 + Scheduler.unstable_advanceTime(500);
2075 await advanceTimers(500);
2076 // Committed loading state.
2077 expect(ReactNoop.getChildren()).toEqual([
@@ -2077,7 +2079,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2079 span('Loading...'),
2080 ]);
2081
2080 - Scheduler.advanceTime(2000);
2082 + Scheduler.unstable_advanceTime(2000);
2083 await advanceTimers(2000);
2084 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
2085 expect(Scheduler).toFlushAndYield(['B']);
@@ -2102,11 +2104,11 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2104 'Loading...',
2105 ]);
2106 expect(ReactNoop.getChildren()).toEqual([span('B')]);
2105 - Scheduler.advanceTime(1200);
2107 + Scheduler.unstable_advanceTime(1200);
2108 await advanceTimers(1200);
2109 // Even after a second, we have still not yet flushed the loading state.
2110 expect(ReactNoop.getChildren()).toEqual([span('B')]);
2109 - Scheduler.advanceTime(1200);
2111 + Scheduler.unstable_advanceTime(1200);
2112 await advanceTimers(1200);
2113 // After the two second timeout we show the loading state.
2114 expect(ReactNoop.getChildren()).toEqual([
@@ -2132,7 +2134,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2134 // Initial render.
2135 ReactNoop.render(<App page="A" />);
2136 expect(Scheduler).toFlushAndYield(['Hi!', 'Suspend! [A]', 'Loading...']);
2135 - Scheduler.advanceTime(3000);
2137 + Scheduler.unstable_advanceTime(3000);
2138 await advanceTimers(3000);
2139 expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
2140 expect(Scheduler).toFlushAndYield(['Hi!', 'A']);
@@ -2148,12 +2150,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2150
2151 // Suspended
2152 expect(ReactNoop.getChildren()).toEqual([span('Hi!'), span('A')]);
2151 - Scheduler.advanceTime(1800);
2153 + Scheduler.unstable_advanceTime(1800);
2154 await advanceTimers(1800);
2155 expect(Scheduler).toFlushAndYield([]);
2156 // We should still be suspended here because this loading state should be avoided.
2157 expect(ReactNoop.getChildren()).toEqual([span('Hi!'), span('A')]);
2156 - Scheduler.advanceTime(1500);
2158 + Scheduler.unstable_advanceTime(1500);
2159 await advanceTimers(1500);
2160 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
2161 expect(ReactNoop.getChildren()).toEqual([
@@ -2196,12 +2198,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2198
2199 // Suspended
2200 expect(ReactNoop.getChildren()).toEqual([span('Hi!'), span('A')]);
2199 - Scheduler.advanceTime(1800);
2201 + Scheduler.unstable_advanceTime(1800);
2202 await advanceTimers(1800);
2203 expect(Scheduler).toFlushAndYield([]);
2204 // We should still be suspended here because this loading state should be avoided.
2205 expect(ReactNoop.getChildren()).toEqual([span('Hi!'), span('A')]);
2204 - Scheduler.advanceTime(1500);
2206 + Scheduler.unstable_advanceTime(1500);
2207 await advanceTimers(1500);
2208 expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
2209 expect(ReactNoop.getChildren()).toEqual([
@@ -2257,7 +2259,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2259 transitionToPage('B');
2260 // Rendering B is quick and we didn't have enough
2261 // time to show the loading indicator.
2260 - Scheduler.advanceTime(200);
2262 + Scheduler.unstable_advanceTime(200);
2263 await advanceTimers(200);
2264 expect(Scheduler).toFlushAndYield(['A', 'L', 'B']);
2265 expect(ReactNoop.getChildren()).toEqual([span('B')]);
@@ -2267,14 +2269,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2269 transitionToPage('C');
2270 // Rendering C is a bit slower so we've already showed
2271 // the loading indicator.
2270 - Scheduler.advanceTime(600);
2272 + Scheduler.unstable_advanceTime(600);
2273 await advanceTimers(600);
2274 expect(Scheduler).toFlushAndYield(['B', 'L', 'C']);
2275 // We're technically done now but we haven't shown the
2276 // loading indicator for long enough yet so we'll suspend
2277 // while we keep it on the screen a bit longer.
2278 expect(ReactNoop.getChildren()).toEqual([span('B'), span('L')]);
2277 - Scheduler.advanceTime(400);
2279 + Scheduler.unstable_advanceTime(400);
2280 await advanceTimers(400);
2281 expect(ReactNoop.getChildren()).toEqual([span('C')]);
2282 });
@@ -2283,7 +2285,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2285 transitionToPage('D');
2286 // Rendering D is very slow so we've already showed
2287 // the loading indicator.
2286 - Scheduler.advanceTime(1000);
2288 + Scheduler.unstable_advanceTime(1000);
2289 await advanceTimers(1000);
2290 expect(Scheduler).toFlushAndYield(['C', 'L', 'D']);
2291 // However, since we exceeded the minimum time to show
@@ -2309,7 +2311,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2311
2312 // Resolve initial render
2313 await ReactNoop.act(async () => {
2312 - Scheduler.advanceTime(2000);
2314 + Scheduler.unstable_advanceTime(2000);
2315 await advanceTimers(2000);
2316 });
2317 expect(Scheduler).toHaveYielded([
packages/react-refresh/src/__tests__/ReactFresh-test.js
+4 -4
@@ -2355,7 +2355,7 @@ describe('ReactFresh', () => {
2355 const AppV1 = prepare(() => {
2356 function Hello() {
2357 React.useLayoutEffect(() => {
2358 - Scheduler.yieldValue('Hello#layout');
2358 + Scheduler.unstable_yieldValue('Hello#layout');
2359 });
2360 const [val, setVal] = React.useState(0);
2361 return (
@@ -2368,7 +2368,7 @@ describe('ReactFresh', () => {
2368
2369 return function App({offscreen}) {
2370 React.useLayoutEffect(() => {
2371 - Scheduler.yieldValue('App#layout');
2371 + Scheduler.unstable_yieldValue('App#layout');
2372 });
2373 return (
2374 <div hidden={offscreen}>
@@ -2389,7 +2389,7 @@ describe('ReactFresh', () => {
2389 patch(() => {
2390 function Hello() {
2391 React.useLayoutEffect(() => {
2392 - Scheduler.yieldValue('Hello#layout');
2392 + Scheduler.unstable_yieldValue('Hello#layout');
2393 });
2394 const [val, setVal] = React.useState(0);
2395 return (
@@ -2423,7 +2423,7 @@ describe('ReactFresh', () => {
2423 patch(() => {
2424 function Hello() {
2425 React.useLayoutEffect(() => {
2426 - Scheduler.yieldValue('Hello#layout');
2426 + Scheduler.unstable_yieldValue('Hello#layout');
2427 });
2428 const [val, setVal] = React.useState(0);
2429 return (
packages/react-test-renderer/src/ReactTestRendererAct.js
+1 -1
@@ -26,7 +26,7 @@ const {ReactCurrentActingRendererSigil} = ReactSharedInternals;
26
27 let hasWarnedAboutMissingMockScheduler = false;
28 const flushWork =
29 - Scheduler.unstable_flushWithoutYielding ||
29 + Scheduler.unstable_flushAllWithoutAsserting ||
30 function() {
31 if (warnAboutMissingMockScheduler === true) {
32 if (hasWarnedAboutMissingMockScheduler === false) {
packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js
+4 -4
@@ -72,7 +72,7 @@ describe('ReactTestRenderer', () => {
72 const root = ReactTestRenderer.create(<App text="initial" />);
73 PendingResources.initial('initial');
74 await Promise.resolve();
75 - Scheduler.flushAll();
75 + Scheduler.unstable_flushAll();
76 expect(root.toJSON()).toEqual('initial');
77
78 root.update(<App text="dynamic" />);
@@ -80,7 +80,7 @@ describe('ReactTestRenderer', () => {
80
81 PendingResources.dynamic('dynamic');
82 await Promise.resolve();
83 - Scheduler.flushAll();
83 + Scheduler.unstable_flushAll();
84 expect(root.toJSON()).toEqual('dynamic');
85
86 done();
@@ -100,7 +100,7 @@ describe('ReactTestRenderer', () => {
100 const root = ReactTestRenderer.create(<App text="initial" />);
101 PendingResources.initial('initial');
102 await Promise.resolve();
103 - Scheduler.flushAll();
103 + Scheduler.unstable_flushAll();
104 expect(root.toJSON().children).toEqual(['initial']);
105
106 root.update(<App text="dynamic" />);
@@ -108,7 +108,7 @@ describe('ReactTestRenderer', () => {
108
109 PendingResources.dynamic('dynamic');
110 await Promise.resolve();
111 - Scheduler.flushAll();
111 + Scheduler.unstable_flushAll();
112 expect(root.toJSON().children).toEqual(['dynamic']);
113
114 done();
packages/react-test-renderer/src/__tests__/ReactTestRendererAct-test.js
+2 -2
@@ -92,9 +92,9 @@ describe('ReactTestRenderer.act()', () => {
92 // This component will keep updating itself until step === 3
93 const [step, proceed] = useReducer(s => (s === 3 ? 3 : s + 1), 1);
94 useEffect(() => {
95 - Scheduler.yieldValue('Effect');
95 + Scheduler.unstable_yieldValue('Effect');
96 alreadyResolvedPromise.then(() => {
97 - Scheduler.yieldValue('Microtask');
97 + Scheduler.unstable_yieldValue('Microtask');
98 proceed();
99 });
100 });
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js
+8 -8
@@ -48,7 +48,7 @@ describe('ReactTestRendererAsync', () => {
48
49 it('flushAll returns array of yielded values', () => {
50 function Child(props) {
51 - Scheduler.yieldValue(props.children);
51 + Scheduler.unstable_yieldValue(props.children);
52 return props.children;
53 }
54 function Parent(props) {
@@ -74,7 +74,7 @@ describe('ReactTestRendererAsync', () => {
74
75 it('flushThrough flushes until the expected values is yielded', () => {
76 function Child(props) {
77 - Scheduler.yieldValue(props.children);
77 + Scheduler.unstable_yieldValue(props.children);
78 return props.children;
79 }
80 function Parent(props) {
@@ -102,7 +102,7 @@ describe('ReactTestRendererAsync', () => {
102
103 it('supports high priority interruptions', () => {
104 function Child(props) {
105 - Scheduler.yieldValue(props.children);
105 + Scheduler.unstable_yieldValue(props.children);
106 return props.children;
107 }
108
@@ -143,7 +143,7 @@ describe('ReactTestRendererAsync', () => {
143 describe('Jest matchers', () => {
144 it('toFlushAndYieldThrough', () => {
145 const Yield = ({id}) => {
146 - Scheduler.yieldValue(id);
146 + Scheduler.unstable_yieldValue(id);
147 return id;
148 };
149
@@ -165,7 +165,7 @@ describe('ReactTestRendererAsync', () => {
165
166 it('toFlushAndYield', () => {
167 const Yield = ({id}) => {
168 - Scheduler.yieldValue(id);
168 + Scheduler.unstable_yieldValue(id);
169 return id;
170 };
171
@@ -199,7 +199,7 @@ describe('ReactTestRendererAsync', () => {
199
200 it('toFlushAndThrow', () => {
201 const Yield = ({id}) => {
202 - Scheduler.yieldValue(id);
202 + Scheduler.unstable_yieldValue(id);
203 return id;
204 };
205
@@ -238,7 +238,7 @@ describe('ReactTestRendererAsync', () => {
238
239 it('toHaveYielded', () => {
240 const Yield = ({id}) => {
241 - Scheduler.yieldValue(id);
241 + Scheduler.unstable_yieldValue(id);
242 return id;
243 };
244
@@ -262,7 +262,7 @@ describe('ReactTestRendererAsync', () => {
262 ReactTestRenderer.create(<div />, {
263 unstable_isConcurrent: true,
264 });
265 - Scheduler.yieldValue('Something');
265 + Scheduler.unstable_yieldValue('Something');
266 expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrow(
267 'Log of yielded values is not empty.',
268 );
packages/react/src/__tests__/ReactDOMTracing-test.internal.js
+33 -33
@@ -69,13 +69,13 @@ describe('ReactDOMTracing', () => {
69 it('traces interaction through hidden subtree', () => {
70 const Child = () => {
71 const [didMount, setDidMount] = React.useState(false);
72 - Scheduler.yieldValue('Child');
72 + Scheduler.unstable_yieldValue('Child');
73 React.useEffect(
74 () => {
75 if (didMount) {
76 - Scheduler.yieldValue('Child:update');
76 + Scheduler.unstable_yieldValue('Child:update');
77 } else {
78 - Scheduler.yieldValue('Child:mount');
78 + Scheduler.unstable_yieldValue('Child:mount');
79 setDidMount(true);
80 }
81 },
@@ -85,9 +85,9 @@ describe('ReactDOMTracing', () => {
85 };
86
87 const App = () => {
88 - Scheduler.yieldValue('App');
88 + Scheduler.unstable_yieldValue('App');
89 React.useEffect(() => {
90 - Scheduler.yieldValue('App:mount');
90 + Scheduler.unstable_yieldValue('App:mount');
91 }, []);
92 return (
93 <div hidden={true}>
@@ -142,17 +142,17 @@ describe('ReactDOMTracing', () => {
142
143 it('traces interaction through hidden subtree when there is other pending traced work', () => {
144 const Child = () => {
145 - Scheduler.yieldValue('Child');
145 + Scheduler.unstable_yieldValue('Child');
146 return <div />;
147 };
148
149 let wrapped = null;
150
151 const App = () => {
152 - Scheduler.yieldValue('App');
152 + Scheduler.unstable_yieldValue('App');
153 React.useEffect(() => {
154 wrapped = SchedulerTracing.unstable_wrap(() => {});
155 - Scheduler.yieldValue('App:mount');
155 + Scheduler.unstable_yieldValue('App:mount');
156 }, []);
157 return (
158 <div hidden={true}>
@@ -210,13 +210,13 @@ describe('ReactDOMTracing', () => {
210 it('traces interaction through hidden subtree that schedules more idle/never work', () => {
211 const Child = () => {
212 const [didMount, setDidMount] = React.useState(false);
213 - Scheduler.yieldValue('Child');
213 + Scheduler.unstable_yieldValue('Child');
214 React.useLayoutEffect(
215 () => {
216 if (didMount) {
217 - Scheduler.yieldValue('Child:update');
217 + Scheduler.unstable_yieldValue('Child:update');
218 } else {
219 - Scheduler.yieldValue('Child:mount');
219 + Scheduler.unstable_yieldValue('Child:mount');
220 Scheduler.unstable_runWithPriority(
221 Scheduler.unstable_IdlePriority,
222 () => setDidMount(true),
@@ -229,9 +229,9 @@ describe('ReactDOMTracing', () => {
229 };
230
231 const App = () => {
232 - Scheduler.yieldValue('App');
232 + Scheduler.unstable_yieldValue('App');
233 React.useEffect(() => {
234 - Scheduler.yieldValue('App:mount');
234 + Scheduler.unstable_yieldValue('App:mount');
235 }, []);
236 return (
237 <div hidden={true}>
@@ -289,14 +289,14 @@ describe('ReactDOMTracing', () => {
289
290 it('does not continue interactions across pre-existing idle work', () => {
291 const Child = () => {
292 - Scheduler.yieldValue('Child');
292 + Scheduler.unstable_yieldValue('Child');
293 return <div />;
294 };
295
296 let update = null;
297
298 const WithHiddenWork = () => {
299 - Scheduler.yieldValue('WithHiddenWork');
299 + Scheduler.unstable_yieldValue('WithHiddenWork');
300 return (
301 <div hidden={true}>
302 <Child />
@@ -305,9 +305,9 @@ describe('ReactDOMTracing', () => {
305 };
306
307 const Updater = () => {
308 - Scheduler.yieldValue('Updater');
308 + Scheduler.unstable_yieldValue('Updater');
309 React.useEffect(() => {
310 - Scheduler.yieldValue('Updater:effect');
310 + Scheduler.unstable_yieldValue('Updater:effect');
311 });
312
313 const setCount = React.useState(0)[1];
@@ -319,9 +319,9 @@ describe('ReactDOMTracing', () => {
319 };
320
321 const App = () => {
322 - Scheduler.yieldValue('App');
322 + Scheduler.unstable_yieldValue('App');
323 React.useEffect(() => {
324 - Scheduler.yieldValue('App:effect');
324 + Scheduler.unstable_yieldValue('App:effect');
325 });
326
327 return (
@@ -389,7 +389,7 @@ describe('ReactDOMTracing', () => {
389
390 it('should properly trace interactions when there is work of interleaved priorities', () => {
391 const Child = () => {
392 - Scheduler.yieldValue('Child');
392 + Scheduler.unstable_yieldValue('Child');
393 return <div />;
394 };
395
@@ -399,9 +399,9 @@ describe('ReactDOMTracing', () => {
399 const MaybeHiddenWork = () => {
400 const [flag, setFlag] = React.useState(false);
401 scheduleUpdateWithHidden = () => setFlag(true);
402 - Scheduler.yieldValue('MaybeHiddenWork');
402 + Scheduler.unstable_yieldValue('MaybeHiddenWork');
403 React.useEffect(() => {
404 - Scheduler.yieldValue('MaybeHiddenWork:effect');
404 + Scheduler.unstable_yieldValue('MaybeHiddenWork:effect');
405 });
406 return flag ? (
407 <div hidden={true}>
@@ -411,9 +411,9 @@ describe('ReactDOMTracing', () => {
411 };
412
413 const Updater = () => {
414 - Scheduler.yieldValue('Updater');
414 + Scheduler.unstable_yieldValue('Updater');
415 React.useEffect(() => {
416 - Scheduler.yieldValue('Updater:effect');
416 + Scheduler.unstable_yieldValue('Updater:effect');
417 });
418
419 const setCount = React.useState(0)[1];
@@ -423,9 +423,9 @@ describe('ReactDOMTracing', () => {
423 };
424
425 const App = () => {
426 - Scheduler.yieldValue('App');
426 + Scheduler.unstable_yieldValue('App');
427 React.useEffect(() => {
428 - Scheduler.yieldValue('App:effect');
428 + Scheduler.unstable_yieldValue('App:effect');
429 });
430
431 return (
@@ -512,9 +512,9 @@ describe('ReactDOMTracing', () => {
512 const SuspenseList = React.unstable_SuspenseList;
513 const Suspense = React.Suspense;
514 function Text({text}) {
515 - Scheduler.yieldValue(text);
515 + Scheduler.unstable_yieldValue(text);
516 React.useEffect(() => {
517 - Scheduler.yieldValue('Commit ' + text);
517 + Scheduler.unstable_yieldValue('Commit ' + text);
518 });
519 return <span>{text}</span>;
520 }
@@ -548,12 +548,12 @@ describe('ReactDOMTracing', () => {
548
549 expect(Scheduler).toFlushAndYieldThrough(['A']);
550
551 - Scheduler.advanceTime(300);
551 + Scheduler.unstable_advanceTime(300);
552 jest.advanceTimersByTime(300);
553
554 expect(Scheduler).toFlushAndYieldThrough(['B']);
555
556 - Scheduler.advanceTime(300);
556 + Scheduler.unstable_advanceTime(300);
557 jest.advanceTimersByTime(300);
558
559 // Time has now elapsed for so long that we're just going to give up
@@ -625,7 +625,7 @@ describe('ReactDOMTracing', () => {
625
626 root.render(<App />);
627 });
628 - Scheduler.flushAll();
628 + Scheduler.unstable_flushAll();
629 jest.runAllTimers();
630
631 expect(ref.current).not.toBe(null);
@@ -685,7 +685,7 @@ describe('ReactDOMTracing', () => {
685
686 root.render(<App />);
687 });
688 - Scheduler.flushAll();
688 + Scheduler.unstable_flushAll();
689 jest.runAllTimers();
690
691 expect(ref.current).toBe(null);
@@ -699,7 +699,7 @@ describe('ReactDOMTracing', () => {
699 suspend = false;
700 resolve();
701 await promise;
702 - Scheduler.flushAll();
702 + Scheduler.unstable_flushAll();
703 jest.runAllTimers();
704
705 expect(ref.current).not.toBe(null);
packages/react/src/__tests__/ReactProfiler-test.internal.js
+99 -93
@@ -59,7 +59,7 @@ function loadModules({
59 }
60 render() {
61 // Simulate time passing when this component is rendered
62 - Scheduler.advanceTime(this.props.byAmount);
62 + Scheduler.unstable_advanceTime(this.props.byAmount);
63 return this.props.children || null;
64 }
65 };
@@ -69,7 +69,7 @@ function loadModules({
69 TextResource = ReactCache.unstable_createResource(([text, ms = 0]) => {
70 resourcePromise = new Promise((resolve, reject) =>
71 setTimeout(() => {
72 - Scheduler.yieldValue(`Promise resolved [${text}]`);
72 + Scheduler.unstable_yieldValue(`Promise resolved [${text}]`);
73 resolve(text);
74 }, ms),
75 );
@@ -79,20 +79,20 @@ function loadModules({
79 AsyncText = ({ms, text}) => {
80 try {
81 TextResource.read([text, ms]);
82 - Scheduler.yieldValue(`AsyncText [${text}]`);
82 + Scheduler.unstable_yieldValue(`AsyncText [${text}]`);
83 return text;
84 } catch (promise) {
85 if (typeof promise.then === 'function') {
86 - Scheduler.yieldValue(`Suspend [${text}]`);
86 + Scheduler.unstable_yieldValue(`Suspend [${text}]`);
87 } else {
88 - Scheduler.yieldValue(`Error [${text}]`);
88 + Scheduler.unstable_yieldValue(`Error [${text}]`);
89 }
90 throw promise;
91 }
92 };
93
94 Text = ({text}) => {
95 - Scheduler.yieldValue(`Text [${text}]`);
95 + Scheduler.unstable_yieldValue(`Text [${text}]`);
96 return text;
97 };
98 }
@@ -237,7 +237,7 @@ describe('Profiler', () => {
237 const callback = jest.fn();
238
239 const Yield = ({value}) => {
240 - Scheduler.yieldValue(value);
240 + Scheduler.unstable_yieldValue(value);
241 return null;
242 };
243
@@ -268,7 +268,7 @@ describe('Profiler', () => {
268 return {
269 ...ActualScheduler,
270 unstable_now: function mockUnstableNow() {
271 - ActualScheduler.yieldValue('read current time');
271 + ActualScheduler.unstable_yieldValue('read current time');
272 return ActualScheduler.unstable_now();
273 },
274 };
@@ -309,7 +309,7 @@ describe('Profiler', () => {
309 it('logs render times for both mount and update', () => {
310 const callback = jest.fn();
311
312 - Scheduler.advanceTime(5); // 0 -> 5
312 + Scheduler.unstable_advanceTime(5); // 0 -> 5
313
314 const renderer = ReactTestRenderer.create(
315 <React.Profiler id="test" onRender={callback}>
@@ -332,7 +332,7 @@ describe('Profiler', () => {
332
333 callback.mockReset();
334
335 - Scheduler.advanceTime(20); // 15 -> 35
335 + Scheduler.unstable_advanceTime(20); // 15 -> 35
336
337 renderer.update(
338 <React.Profiler id="test" onRender={callback}>
@@ -355,7 +355,7 @@ describe('Profiler', () => {
355
356 callback.mockReset();
357
358 - Scheduler.advanceTime(20); // 45 -> 65
358 + Scheduler.unstable_advanceTime(20); // 45 -> 65
359
360 renderer.update(
361 <React.Profiler id="test" onRender={callback}>
@@ -380,7 +380,7 @@ describe('Profiler', () => {
380 it('includes render times of nested Profilers in their parent times', () => {
381 const callback = jest.fn();
382
383 - Scheduler.advanceTime(5); // 0 -> 5
383 + Scheduler.unstable_advanceTime(5); // 0 -> 5
384
385 ReactTestRenderer.create(
386 <React.Fragment>
@@ -415,7 +415,7 @@ describe('Profiler', () => {
415 it('traces sibling Profilers separately', () => {
416 const callback = jest.fn();
417
418 - Scheduler.advanceTime(5); // 0 -> 5
418 + Scheduler.unstable_advanceTime(5); // 0 -> 5
419
420 ReactTestRenderer.create(
421 <React.Fragment>
@@ -448,7 +448,7 @@ describe('Profiler', () => {
448 it('does not include time spent outside of profile root', () => {
449 const callback = jest.fn();
450
451 - Scheduler.advanceTime(5); // 0 -> 5
451 + Scheduler.unstable_advanceTime(5); // 0 -> 5
452
453 ReactTestRenderer.create(
454 <React.Fragment>
@@ -523,7 +523,7 @@ describe('Profiler', () => {
523 it('decreases actual time but not base time when sCU prevents an update', () => {
524 const callback = jest.fn();
525
526 - Scheduler.advanceTime(5); // 0 -> 5
526 + Scheduler.unstable_advanceTime(5); // 0 -> 5
527
528 const renderer = ReactTestRenderer.create(
529 <React.Profiler id="test" onRender={callback}>
@@ -535,7 +535,7 @@ describe('Profiler', () => {
535
536 expect(callback).toHaveBeenCalledTimes(1);
537
538 - Scheduler.advanceTime(30); // 28 -> 58
538 + Scheduler.unstable_advanceTime(30); // 28 -> 58
539
540 renderer.update(
541 <React.Profiler id="test" onRender={callback}>
@@ -566,22 +566,22 @@ describe('Profiler', () => {
566 class WithLifecycles extends React.Component {
567 state = {};
568 static getDerivedStateFromProps() {
569 - Scheduler.advanceTime(3);
569 + Scheduler.unstable_advanceTime(3);
570 return null;
571 }
572 shouldComponentUpdate() {
573 - Scheduler.advanceTime(7);
573 + Scheduler.unstable_advanceTime(7);
574 return true;
575 }
576 render() {
577 - Scheduler.advanceTime(5);
577 + Scheduler.unstable_advanceTime(5);
578 return null;
579 }
580 }
581
582 const callback = jest.fn();
583
584 - Scheduler.advanceTime(5); // 0 -> 5
584 + Scheduler.unstable_advanceTime(5); // 0 -> 5
585
586 const renderer = ReactTestRenderer.create(
587 <React.Profiler id="test" onRender={callback}>
@@ -589,7 +589,7 @@ describe('Profiler', () => {
589 </React.Profiler>,
590 );
591
592 - Scheduler.advanceTime(15); // 13 -> 28
592 + Scheduler.unstable_advanceTime(15); // 13 -> 28
593
594 renderer.update(
595 <React.Profiler id="test" onRender={callback}>
@@ -619,12 +619,12 @@ describe('Profiler', () => {
619 const callback = jest.fn();
620
621 const Yield = ({renderTime}) => {
622 - Scheduler.advanceTime(renderTime);
623 - Scheduler.yieldValue('Yield:' + renderTime);
622 + Scheduler.unstable_advanceTime(renderTime);
623 + Scheduler.unstable_yieldValue('Yield:' + renderTime);
624 return null;
625 };
626
627 - Scheduler.advanceTime(5); // 0 -> 5
627 + Scheduler.unstable_advanceTime(5); // 0 -> 5
628
629 // Render partially, but run out of time before completing.
630 ReactTestRenderer.create(
@@ -653,12 +653,12 @@ describe('Profiler', () => {
653 const callback = jest.fn();
654
655 const Yield = ({renderTime}) => {
656 - Scheduler.advanceTime(renderTime);
657 - Scheduler.yieldValue('Yield:' + renderTime);
656 + Scheduler.unstable_advanceTime(renderTime);
657 + Scheduler.unstable_yieldValue('Yield:' + renderTime);
658 return null;
659 };
660
661 - Scheduler.advanceTime(5); // 0 -> 5
661 + Scheduler.unstable_advanceTime(5); // 0 -> 5
662
663 // Render partially, but don't finish.
664 // This partial render should take 5ms of simulated time.
@@ -676,7 +676,7 @@ describe('Profiler', () => {
676 expect(callback).toHaveBeenCalledTimes(0);
677
678 // Simulate time moving forward while frame is paused.
679 - Scheduler.advanceTime(50); // 10 -> 60
679 + Scheduler.unstable_advanceTime(50); // 10 -> 60
680
681 // Flush the remaining work,
682 // Which should take an additional 10ms of simulated time.
@@ -703,12 +703,12 @@ describe('Profiler', () => {
703 const callback = jest.fn();
704
705 const Yield = ({renderTime}) => {
706 - Scheduler.advanceTime(renderTime);
707 - Scheduler.yieldValue('Yield:' + renderTime);
706 + Scheduler.unstable_advanceTime(renderTime);
707 + Scheduler.unstable_yieldValue('Yield:' + renderTime);
708 return null;
709 };
710
711 - Scheduler.advanceTime(5); // 0 -> 5
711 + Scheduler.unstable_advanceTime(5); // 0 -> 5
712
713 // Render a partially update, but don't finish.
714 // This partial render should take 10ms of simulated time.
@@ -723,7 +723,7 @@ describe('Profiler', () => {
723 expect(callback).toHaveBeenCalledTimes(0);
724
725 // Simulate time moving forward while frame is paused.
726 - Scheduler.advanceTime(100); // 15 -> 115
726 + Scheduler.unstable_advanceTime(100); // 15 -> 115
727
728 // Interrupt with higher priority work.
729 // The interrupted work simulates an additional 5ms of time.
@@ -756,12 +756,12 @@ describe('Profiler', () => {
756 const callback = jest.fn();
757
758 const Yield = ({renderTime}) => {
759 - Scheduler.advanceTime(renderTime);
760 - Scheduler.yieldValue('Yield:' + renderTime);
759 + Scheduler.unstable_advanceTime(renderTime);
760 + Scheduler.unstable_yieldValue('Yield:' + renderTime);
761 return null;
762 };
763
764 - Scheduler.advanceTime(5); // 0 -> 5
764 + Scheduler.unstable_advanceTime(5); // 0 -> 5
765
766 const renderer = ReactTestRenderer.create(
767 <React.Profiler id="test" onRender={callback}>
@@ -783,7 +783,7 @@ describe('Profiler', () => {
783
784 callback.mockReset();
785
786 - Scheduler.advanceTime(30); // 26 -> 56
786 + Scheduler.unstable_advanceTime(30); // 26 -> 56
787
788 // Render a partially update, but don't finish.
789 // This partial render should take 3ms of simulated time.
@@ -798,14 +798,14 @@ describe('Profiler', () => {
798 expect(callback).toHaveBeenCalledTimes(0);
799
800 // Simulate time moving forward while frame is paused.
801 - Scheduler.advanceTime(100); // 59 -> 159
801 + Scheduler.unstable_advanceTime(100); // 59 -> 159
802
803 // Render another 5ms of simulated time.
804 expect(Scheduler).toFlushAndYieldThrough(['Yield:5']);
805 expect(callback).toHaveBeenCalledTimes(0);
806
807 // Simulate time moving forward while frame is paused.
808 - Scheduler.advanceTime(100); // 164 -> 264
808 + Scheduler.unstable_advanceTime(100); // 164 -> 264
809
810 // Interrupt with higher priority work.
811 // The interrupted work simulates an additional 11ms of time.
@@ -837,8 +837,8 @@ describe('Profiler', () => {
837 const callback = jest.fn();
838
839 const Yield = ({renderTime}) => {
840 - Scheduler.advanceTime(renderTime);
841 - Scheduler.yieldValue('Yield:' + renderTime);
840 + Scheduler.unstable_advanceTime(renderTime);
841 + Scheduler.unstable_yieldValue('Yield:' + renderTime);
842 return null;
843 };
844
@@ -847,8 +847,10 @@ describe('Profiler', () => {
847 state = {renderTime: 1};
848 render() {
849 first = this;
850 - Scheduler.advanceTime(this.state.renderTime);
851 - Scheduler.yieldValue('FirstComponent:' + this.state.renderTime);
850 + Scheduler.unstable_advanceTime(this.state.renderTime);
851 + Scheduler.unstable_yieldValue(
852 + 'FirstComponent:' + this.state.renderTime,
853 + );
854 return <Yield renderTime={4} />;
855 }
856 }
@@ -857,13 +859,15 @@ describe('Profiler', () => {
859 state = {renderTime: 2};
860 render() {
861 second = this;
860 - Scheduler.advanceTime(this.state.renderTime);
861 - Scheduler.yieldValue('SecondComponent:' + this.state.renderTime);
862 + Scheduler.unstable_advanceTime(this.state.renderTime);
863 + Scheduler.unstable_yieldValue(
864 + 'SecondComponent:' + this.state.renderTime,
865 + );
866 return <Yield renderTime={7} />;
867 }
868 }
869
866 - Scheduler.advanceTime(5); // 0 -> 5
870 + Scheduler.unstable_advanceTime(5); // 0 -> 5
871
872 const renderer = ReactTestRenderer.create(
873 <React.Profiler id="test" onRender={callback}>
@@ -891,7 +895,7 @@ describe('Profiler', () => {
895
896 callback.mockClear();
897
894 - Scheduler.advanceTime(100); // 19 -> 119
898 + Scheduler.unstable_advanceTime(100); // 19 -> 119
899
900 // Render a partially update, but don't finish.
901 // This partial render will take 10ms of actual render time.
@@ -900,7 +904,7 @@ describe('Profiler', () => {
904 expect(callback).toHaveBeenCalledTimes(0);
905
906 // Simulate time moving forward while frame is paused.
903 - Scheduler.advanceTime(100); // 129 -> 229
907 + Scheduler.unstable_advanceTime(100); // 129 -> 229
908
909 // Interrupt with higher priority work.
910 // This simulates a total of 37ms of actual render time.
@@ -921,7 +925,7 @@ describe('Profiler', () => {
925 callback.mockClear();
926
927 // Simulate time moving forward while frame is paused.
924 - Scheduler.advanceTime(100); // 266 -> 366
928 + Scheduler.unstable_advanceTime(100); // 266 -> 366
929
930 // Resume the original low priority update, with rebased state.
931 // This simulates a total of 14ms of actual render time,
@@ -957,7 +961,7 @@ describe('Profiler', () => {
961 const callback = jest.fn();
962
963 const ThrowsError = () => {
960 - Scheduler.advanceTime(3);
964 + Scheduler.unstable_advanceTime(3);
965 throw Error('expected error');
966 };
967
@@ -967,7 +971,7 @@ describe('Profiler', () => {
971 this.setState({error});
972 }
973 render() {
970 - Scheduler.advanceTime(2);
974 + Scheduler.unstable_advanceTime(2);
975 return this.state.error === null ? (
976 this.props.children
977 ) : (
@@ -976,7 +980,7 @@ describe('Profiler', () => {
980 }
981 }
982
979 - Scheduler.advanceTime(5); // 0 -> 5
983 + Scheduler.unstable_advanceTime(5); // 0 -> 5
984
985 ReactTestRenderer.create(
986 <React.Profiler id="test" onRender={callback}>
@@ -1036,7 +1040,7 @@ describe('Profiler', () => {
1040 const callback = jest.fn();
1041
1042 const ThrowsError = () => {
1039 - Scheduler.advanceTime(10);
1043 + Scheduler.unstable_advanceTime(10);
1044 throw Error('expected error');
1045 };
1046
@@ -1046,7 +1050,7 @@ describe('Profiler', () => {
1050 return {error};
1051 }
1052 render() {
1049 - Scheduler.advanceTime(2);
1053 + Scheduler.unstable_advanceTime(2);
1054 return this.state.error === null ? (
1055 this.props.children
1056 ) : (
@@ -1055,7 +1059,7 @@ describe('Profiler', () => {
1059 }
1060 }
1061
1058 - Scheduler.advanceTime(5); // 0 -> 5
1062 + Scheduler.unstable_advanceTime(5); // 0 -> 5
1063
1064 ReactTestRenderer.create(
1065 <React.Profiler id="test" onRender={callback}>
@@ -1135,7 +1139,7 @@ describe('Profiler', () => {
1139 it('reflects the most recently rendered id value', () => {
1140 const callback = jest.fn();
1141
1138 - Scheduler.advanceTime(5); // 0 -> 5
1142 + Scheduler.unstable_advanceTime(5); // 0 -> 5
1143
1144 const renderer = ReactTestRenderer.create(
1145 <React.Profiler id="one" onRender={callback}>
@@ -1145,7 +1149,7 @@ describe('Profiler', () => {
1149
1150 expect(callback).toHaveBeenCalledTimes(1);
1151
1148 - Scheduler.advanceTime(20); // 7 -> 27
1152 + Scheduler.unstable_advanceTime(20); // 7 -> 27
1153
1154 renderer.update(
1155 <React.Profiler id="two" onRender={callback}>
@@ -1183,11 +1187,11 @@ describe('Profiler', () => {
1187
1188 class ClassComponent extends React.Component {
1189 componentDidMount() {
1186 - Scheduler.advanceTime(5);
1190 + Scheduler.unstable_advanceTime(5);
1191 classComponentMounted = true;
1192 }
1193 render() {
1190 - Scheduler.advanceTime(2);
1194 + Scheduler.unstable_advanceTime(2);
1195 return null;
1196 }
1197 }
@@ -1209,14 +1213,16 @@ describe('Profiler', () => {
1213 loadModules({useNoopRenderer: true});
1214
1215 const Child = ({duration, id}) => {
1212 - Scheduler.advanceTime(duration);
1213 - Scheduler.yieldValue(`Child:render:${id}`);
1216 + Scheduler.unstable_advanceTime(duration);
1217 + Scheduler.unstable_yieldValue(`Child:render:${id}`);
1218 return null;
1219 };
1220
1221 class Parent extends React.Component {
1222 componentDidMount() {
1219 - Scheduler.yieldValue(`Parent:componentDidMount:${this.props.id}`);
1223 + Scheduler.unstable_yieldValue(
1224 + `Parent:componentDidMount:${this.props.id}`,
1225 + );
1226 }
1227 render() {
1228 const {duration, id} = this.props;
@@ -1229,7 +1235,7 @@ describe('Profiler', () => {
1235 }
1236 }
1237
1232 - Scheduler.advanceTime(50);
1238 + Scheduler.unstable_advanceTime(50);
1239
1240 ReactNoop.renderToRootWithID(<Parent duration={3} id="one" />, 'one');
1241
@@ -1242,13 +1248,13 @@ describe('Profiler', () => {
1248
1249 expect(ReactNoop.getRoot('one').current.actualDuration).toBe(0);
1250
1245 - Scheduler.advanceTime(100);
1251 + Scheduler.unstable_advanceTime(100);
1252
1253 // Process some async work, but yield before committing it.
1254 ReactNoop.renderToRootWithID(<Parent duration={7} id="two" />, 'two');
1255 expect(Scheduler).toFlushAndYieldThrough(['Child:render:two']);
1256
1251 - Scheduler.advanceTime(150);
1257 + Scheduler.unstable_advanceTime(150);
1258
1259 // Commit the previously paused, batched work.
1260 commitFirstRender(['Parent:componentDidMount:one']);
@@ -1256,7 +1262,7 @@ describe('Profiler', () => {
1262 expect(ReactNoop.getRoot('one').current.actualDuration).toBe(6);
1263 expect(ReactNoop.getRoot('two').current.actualDuration).toBe(0);
1264
1259 - Scheduler.advanceTime(200);
1265 + Scheduler.unstable_advanceTime(200);
1266
1267 expect(Scheduler).toFlushAndYield([
1268 'Child:render:two',
@@ -1333,7 +1339,7 @@ describe('Profiler', () => {
1339 describe('error handling', () => {
1340 it('should cover errors thrown in onWorkScheduled', () => {
1341 function Component({children}) {
1336 - Scheduler.yieldValue('Component:' + children);
1342 + Scheduler.unstable_yieldValue('Component:' + children);
1343 return children;
1344 }
1345
@@ -1368,7 +1374,7 @@ describe('Profiler', () => {
1374
1375 it('should cover errors thrown in onWorkStarted', () => {
1376 function Component({children}) {
1371 - Scheduler.yieldValue('Component:' + children);
1377 + Scheduler.unstable_yieldValue('Component:' + children);
1378 return children;
1379 }
1380
@@ -1403,7 +1409,7 @@ describe('Profiler', () => {
1409
1410 it('should cover errors thrown in onWorkStopped', () => {
1411 function Component({children}) {
1406 - Scheduler.yieldValue('Component:' + children);
1412 + Scheduler.unstable_yieldValue('Component:' + children);
1413 return children;
1414 }
1415
@@ -1438,7 +1444,7 @@ describe('Profiler', () => {
1444
1445 it('should cover errors thrown in onInteractionScheduledWorkCompleted', () => {
1446 function Component({children}) {
1441 - Scheduler.yieldValue('Component:' + children);
1447 + Scheduler.unstable_yieldValue('Component:' + children);
1448 return children;
1449 }
1450
@@ -1513,8 +1519,8 @@ describe('Profiler', () => {
1519 let instance = null;
1520
1521 const Yield = ({duration = 10, value}) => {
1516 - Scheduler.advanceTime(duration);
1517 - Scheduler.yieldValue(value);
1522 + Scheduler.unstable_advanceTime(duration);
1523 + Scheduler.unstable_yieldValue(value);
1524 return null;
1525 };
1526
@@ -1534,7 +1540,7 @@ describe('Profiler', () => {
1540 }
1541 }
1542
1537 - Scheduler.advanceTime(1);
1543 + Scheduler.unstable_advanceTime(1);
1544
1545 const interactionCreation = {
1546 id: 0,
@@ -1608,7 +1614,7 @@ describe('Profiler', () => {
1614 onWorkStarted.mockClear();
1615 onWorkStopped.mockClear();
1616
1611 - Scheduler.advanceTime(3);
1617 + Scheduler.unstable_advanceTime(3);
1618
1619 let didRunCallback = false;
1620
@@ -1684,7 +1690,7 @@ describe('Profiler', () => {
1690 onWorkStarted.mockClear();
1691 onWorkStopped.mockClear();
1692
1687 - Scheduler.advanceTime(17);
1693 + Scheduler.unstable_advanceTime(17);
1694
1695 // Verify that updating state again does not re-log our interaction.
1696 instance.setState({count: 3});
@@ -1708,7 +1714,7 @@ describe('Profiler', () => {
1714
1715 onRender.mockClear();
1716
1711 - Scheduler.advanceTime(3);
1717 + Scheduler.unstable_advanceTime(3);
1718
1719 // Verify that root updates are also associated with traced events.
1720 const interactionTwo = {
@@ -1781,7 +1787,7 @@ describe('Profiler', () => {
1787 state = {count: 0};
1788 render() {
1789 first = this;
1784 - Scheduler.yieldValue('FirstComponent');
1790 + Scheduler.unstable_yieldValue('FirstComponent');
1791 return null;
1792 }
1793 }
@@ -1790,12 +1796,12 @@ describe('Profiler', () => {
1796 state = {count: 0};
1797 render() {
1798 second = this;
1793 - Scheduler.yieldValue('SecondComponent');
1799 + Scheduler.unstable_yieldValue('SecondComponent');
1800 return null;
1801 }
1802 }
1803
1798 - Scheduler.advanceTime(5);
1804 + Scheduler.unstable_advanceTime(5);
1805
1806 const renderer = ReactTestRenderer.create(
1807 <React.Profiler id="test" onRender={onRender}>
@@ -1813,7 +1819,7 @@ describe('Profiler', () => {
1819
1820 onRender.mockClear();
1821
1816 - Scheduler.advanceTime(100);
1822 + Scheduler.unstable_advanceTime(100);
1823
1824 const interactionLowPri = {
1825 id: 0,
@@ -1847,7 +1853,7 @@ describe('Profiler', () => {
1853 ).toMatchInteractions([interactionLowPri]);
1854 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(0);
1855
1850 - Scheduler.advanceTime(100);
1856 + Scheduler.unstable_advanceTime(100);
1857
1858 const interactionHighPri = {
1859 id: 1,
@@ -1898,7 +1904,7 @@ describe('Profiler', () => {
1904
1905 onRender.mockClear();
1906
1901 - Scheduler.advanceTime(100);
1907 + Scheduler.unstable_advanceTime(100);
1908
1909 // Resume the original low priority update, with rebased state.
1910 // Verify the low priority update was retained.
@@ -1949,18 +1955,18 @@ describe('Profiler', () => {
1955 count: 0,
1956 };
1957 componentDidMount() {
1952 - Scheduler.advanceTime(10); // Advance timer to keep commits separate
1958 + Scheduler.unstable_advanceTime(10); // Advance timer to keep commits separate
1959 this.setState({count: 1}); // Intentional cascading update
1960 }
1961 componentDidUpdate(prevProps, prevState) {
1962 if (this.state.count === 2 && prevState.count === 1) {
1957 - Scheduler.advanceTime(10); // Advance timer to keep commits separate
1963 + Scheduler.unstable_advanceTime(10); // Advance timer to keep commits separate
1964 this.setState({count: 3}); // Intentional cascading update
1965 }
1966 }
1967 render() {
1968 instance = this;
1963 - Scheduler.yieldValue('Example:' + this.state.count);
1969 + Scheduler.unstable_yieldValue('Example:' + this.state.count);
1970 return null;
1971 }
1972 }
@@ -2056,7 +2062,7 @@ describe('Profiler', () => {
2062 expect(getWorkForReactThreads(onWorkStarted)).toHaveLength(2);
2063 expect(getWorkForReactThreads(onWorkStopped)).toHaveLength(2);
2064
2059 - Scheduler.advanceTime(5);
2065 + Scheduler.unstable_advanceTime(5);
2066
2067 // Flush async work (outside of traced scope)
2068 // This will cause an intentional cascading update from did-update
@@ -2174,7 +2180,7 @@ describe('Profiler', () => {
2180
2181 class Child extends React.Component {
2182 render() {
2177 - Scheduler.yieldValue('Child:' + this.props.count);
2183 + Scheduler.unstable_yieldValue('Child:' + this.props.count);
2184 return null;
2185 }
2186 }
@@ -2193,7 +2199,7 @@ describe('Profiler', () => {
2199 }
2200 }
2201
2196 - Scheduler.advanceTime(1);
2202 + Scheduler.unstable_advanceTime(1);
2203
2204 ReactTestRenderer.create(<Parent />, {
2205 unstable_isConcurrent: true,
@@ -2267,7 +2273,7 @@ describe('Profiler', () => {
2273 const monkey = React.createRef();
2274 class Monkey extends React.Component {
2275 render() {
2270 - Scheduler.yieldValue('Monkey');
2276 + Scheduler.unstable_yieldValue('Monkey');
2277 return null;
2278 }
2279 }
@@ -2464,7 +2470,7 @@ describe('Profiler', () => {
2470 },
2471 );
2472
2467 - Scheduler.advanceTime(400);
2473 + Scheduler.unstable_advanceTime(400);
2474 await awaitableAdvanceTimers(400);
2475
2476 expect(Scheduler).toFlushAndYield([
@@ -2473,7 +2479,7 @@ describe('Profiler', () => {
2479 ]);
2480 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
2481
2476 - Scheduler.advanceTime(500);
2482 + Scheduler.unstable_advanceTime(500);
2483 await awaitableAdvanceTimers(500);
2484
2485 expect(Scheduler).toHaveYielded(['Promise resolved [loaded]']);
@@ -2602,7 +2608,7 @@ describe('Profiler', () => {
2608 ).toMatchInteraction(highPriUpdateInteraction);
2609 onInteractionScheduledWorkCompleted.mockClear();
2610
2605 - Scheduler.advanceTime(100);
2611 + Scheduler.unstable_advanceTime(100);
2612 jest.advanceTimersByTime(100);
2613 await originalPromise;
2614
@@ -2662,7 +2668,7 @@ describe('Profiler', () => {
2668 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
2669 expect(onRender).not.toHaveBeenCalled();
2670
2665 - Scheduler.advanceTime(50);
2671 + Scheduler.unstable_advanceTime(50);
2672 jest.advanceTimersByTime(50);
2673
2674 const highPriUpdateInteraction = {
@@ -2704,7 +2710,7 @@ describe('Profiler', () => {
2710
2711 expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);
2712
2707 - Scheduler.advanceTime(50);
2713 + Scheduler.unstable_advanceTime(50);
2714 jest.advanceTimersByTime(50);
2715 await originalPromise;
2716 expect(Scheduler).toHaveYielded(['Promise resolved [loaded]']);
packages/react/src/__tests__/ReactProfilerDOM-test.internal.js
+3 -3
@@ -105,7 +105,7 @@ describe('ProfilerDOM', () => {
105 resourcePromise.then(
106 SchedulerTracing.unstable_wrap(() => {
107 jest.runAllTimers();
108 - Scheduler.flushAll();
108 + Scheduler.unstable_flushAll();
109
110 expect(element.textContent).toBe('Text');
111 expect(onInteractionTraced).toHaveBeenCalledTimes(1);
@@ -133,7 +133,7 @@ describe('ProfilerDOM', () => {
133 }),
134 );
135
136 - Scheduler.flushAll();
136 + Scheduler.unstable_flushAll();
137 });
138
139 expect(onInteractionTraced).toHaveBeenCalledTimes(1);
@@ -141,7 +141,7 @@ describe('ProfilerDOM', () => {
141 interaction,
142 );
143 expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
144 - Scheduler.flushAll();
144 + Scheduler.unstable_flushAll();
145 jest.advanceTimersByTime(500);
146 });
147 });
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+6 -6
@@ -47,7 +47,7 @@ describe('ReactProfiler DevTools integration', () => {
47 }
48 render() {
49 // Simulate time passing when this component is rendered
50 - Scheduler.advanceTime(this.props.byAmount);
50 + Scheduler.unstable_advanceTime(this.props.byAmount);
51 return this.props.children || null;
52 }
53 };
@@ -55,7 +55,7 @@ describe('ReactProfiler DevTools integration', () => {
55
56 it('should auto-Profile all fibers if the DevTools hook is detected', () => {
57 const App = ({multiplier}) => {
58 - Scheduler.advanceTime(2);
58 + Scheduler.unstable_advanceTime(2);
59 return (
60 <React.Profiler id="Profiler" onRender={onRender}>
61 <AdvanceTime byAmount={3 * multiplier} shouldComponentUpdate={true} />
@@ -121,7 +121,7 @@ describe('ReactProfiler DevTools integration', () => {
121 });
122
123 it('should reset the fiber stack correctly after an error when profiling host roots', () => {
124 - Scheduler.advanceTime(20);
124 + Scheduler.unstable_advanceTime(20);
125
126 const rendered = ReactTestRenderer.create(
127 <div>
@@ -129,7 +129,7 @@ describe('ReactProfiler DevTools integration', () => {
129 </div>,
130 );
131
132 - Scheduler.advanceTime(20);
132 + Scheduler.unstable_advanceTime(20);
133
134 expect(() => {
135 rendered.update(
@@ -139,7 +139,7 @@ describe('ReactProfiler DevTools integration', () => {
139 );
140 }).toThrow();
141
142 - Scheduler.advanceTime(20);
142 + Scheduler.unstable_advanceTime(20);
143
144 // But this should render correctly, if the profiler's fiber stack has been reset.
145 rendered.update(
@@ -164,7 +164,7 @@ describe('ReactProfiler DevTools integration', () => {
164 const root = rendered.root._currentFiber().return;
165 expect(root.stateNode.memoizedInteractions).toContainNoInteractions();
166
167 - Scheduler.advanceTime(10);
167 + Scheduler.unstable_advanceTime(10);
168
169 const eventTime = Scheduler.unstable_now();
170
packages/react/src/__tests__/ReactStrictMode-test.internal.js
+8 -8
@@ -348,7 +348,7 @@ describe('ReactStrictMode', () => {
348 unstable_isConcurrent: true,
349 });
350 root.update(<AsyncRoot />);
351 - expect(() => Scheduler.flushAll()).toWarnDev(
351 + expect(() => Scheduler.unstable_flushAll()).toWarnDev(
352 'Unsafe lifecycle methods were found within a strict-mode tree:' +
353 '\n\ncomponentWillMount: Please update the following components ' +
354 'to use componentDidMount instead: AsyncRoot' +
@@ -363,7 +363,7 @@ describe('ReactStrictMode', () => {
363
364 // Dedupe
365 root.update(<AsyncRoot />);
366 - Scheduler.flushAll();
366 + Scheduler.unstable_flushAll();
367 });
368
369 it('should coalesce warnings by lifecycle name', () => {
@@ -395,7 +395,7 @@ describe('ReactStrictMode', () => {
395 root.update(<AsyncRoot />);
396
397 expect(() => {
398 - expect(() => Scheduler.flushAll()).toWarnDev(
398 + expect(() => Scheduler.unstable_flushAll()).toWarnDev(
399 'Unsafe lifecycle methods were found within a strict-mode tree:' +
400 '\n\ncomponentWillMount: Please update the following components ' +
401 'to use componentDidMount instead: AsyncRoot, Parent' +
@@ -418,7 +418,7 @@ describe('ReactStrictMode', () => {
418
419 // Dedupe
420 root.update(<AsyncRoot />);
421 - Scheduler.flushAll();
421 + Scheduler.unstable_flushAll();
422 });
423
424 it('should warn about components not present during the initial render', () => {
@@ -444,7 +444,7 @@ describe('ReactStrictMode', () => {
444 unstable_isConcurrent: true,
445 });
446 root.update(<AsyncRoot foo={true} />);
447 - expect(() => Scheduler.flushAll()).toWarnDev(
447 + expect(() => Scheduler.unstable_flushAll()).toWarnDev(
448 'Unsafe lifecycle methods were found within a strict-mode tree:' +
449 '\n\ncomponentWillMount: Please update the following components ' +
450 'to use componentDidMount instead: Foo' +
@@ -454,7 +454,7 @@ describe('ReactStrictMode', () => {
454 );
455
456 root.update(<AsyncRoot foo={false} />);
457 - expect(() => Scheduler.flushAll()).toWarnDev(
457 + expect(() => Scheduler.unstable_flushAll()).toWarnDev(
458 'Unsafe lifecycle methods were found within a strict-mode tree:' +
459 '\n\ncomponentWillMount: Please update the following components ' +
460 'to use componentDidMount instead: Bar' +
@@ -465,9 +465,9 @@ describe('ReactStrictMode', () => {
465
466 // Dedupe
467 root.update(<AsyncRoot foo={true} />);
468 - Scheduler.flushAll();
468 + Scheduler.unstable_flushAll();
469 root.update(<AsyncRoot foo={false} />);
470 - Scheduler.flushAll();
470 + Scheduler.unstable_flushAll();
471 });
472
473 it('should also warn inside of "strict" mode trees', () => {
packages/react/src/__tests__/forwardRef-test.internal.js
+13 -13
@@ -28,7 +28,7 @@ describe('forwardRef', () => {
28 it('should work without a ref to be forwarded', () => {
29 class Child extends React.Component {
30 render() {
31 - Scheduler.yieldValue(this.props.value);
31 + Scheduler.unstable_yieldValue(this.props.value);
32 return null;
33 }
34 }
@@ -48,7 +48,7 @@ describe('forwardRef', () => {
48 it('should forward a ref for a single child', () => {
49 class Child extends React.Component {
50 render() {
51 - Scheduler.yieldValue(this.props.value);
51 + Scheduler.unstable_yieldValue(this.props.value);
52 return null;
53 }
54 }
@@ -71,7 +71,7 @@ describe('forwardRef', () => {
71 it('should forward a ref for multiple children', () => {
72 class Child extends React.Component {
73 render() {
74 - Scheduler.yieldValue(this.props.value);
74 + Scheduler.unstable_yieldValue(this.props.value);
75 return null;
76 }
77 }
@@ -103,7 +103,7 @@ describe('forwardRef', () => {
103 super(props);
104 }
105 render() {
106 - Scheduler.yieldValue(this.props.value);
106 + Scheduler.unstable_yieldValue(this.props.value);
107 return null;
108 }
109 }
@@ -138,28 +138,28 @@ describe('forwardRef', () => {
138 class ErrorBoundary extends React.Component {
139 state = {error: null};
140 componentDidCatch(error) {
141 - Scheduler.yieldValue('ErrorBoundary.componentDidCatch');
141 + Scheduler.unstable_yieldValue('ErrorBoundary.componentDidCatch');
142 this.setState({error});
143 }
144 render() {
145 if (this.state.error) {
146 - Scheduler.yieldValue('ErrorBoundary.render: catch');
146 + Scheduler.unstable_yieldValue('ErrorBoundary.render: catch');
147 return null;
148 }
149 - Scheduler.yieldValue('ErrorBoundary.render: try');
149 + Scheduler.unstable_yieldValue('ErrorBoundary.render: try');
150 return this.props.children;
151 }
152 }
153
154 class BadRender extends React.Component {
155 render() {
156 - Scheduler.yieldValue('BadRender throw');
156 + Scheduler.unstable_yieldValue('BadRender throw');
157 throw new Error('oops!');
158 }
159 }
160
161 function Wrapper(props) {
162 - Scheduler.yieldValue('Wrapper');
162 + Scheduler.unstable_yieldValue('Wrapper');
163 return <BadRender {...props} ref={props.forwardedRef} />;
164 }
165
@@ -196,24 +196,24 @@ describe('forwardRef', () => {
196
197 class Inner extends React.Component {
198 render() {
199 - Scheduler.yieldValue('Inner');
199 + Scheduler.unstable_yieldValue('Inner');
200 inst = this;
201 return <div ref={this.props.forwardedRef} />;
202 }
203 }
204
205 function Middle(props) {
206 - Scheduler.yieldValue('Middle');
206 + Scheduler.unstable_yieldValue('Middle');
207 return <Inner {...props} />;
208 }
209
210 const Forward = React.forwardRef((props, ref) => {
211 - Scheduler.yieldValue('Forward');
211 + Scheduler.unstable_yieldValue('Forward');
212 return <Middle {...props} forwardedRef={ref} />;
213 });
214
215 function App() {
216 - Scheduler.yieldValue('App');
216 + Scheduler.unstable_yieldValue('App');
217 return <Forward />;
218 }
219
packages/scheduler/src/__tests__/Scheduler-test.js
+153 -115
@@ -39,10 +39,10 @@ describe('Scheduler', () => {
39 });
40
41 it('flushes work incrementally', () => {
42 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'));
43 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('B'));
44 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('C'));
45 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('D'));
42 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
43 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
44 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
45 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('D'));
46
47 expect(Scheduler).toFlushAndYieldThrough(['A', 'B']);
48 expect(Scheduler).toFlushAndYieldThrough(['C']);
@@ -50,11 +50,11 @@ describe('Scheduler', () => {
50 });
51
52 it('cancels work', () => {
53 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'));
53 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
54 const callbackHandleB = scheduleCallback(NormalPriority, () =>
55 - Scheduler.yieldValue('B'),
55 + Scheduler.unstable_yieldValue('B'),
56 );
57 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('C'));
57 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
58
59 cancelCallback(callbackHandleB);
60
@@ -66,14 +66,18 @@ describe('Scheduler', () => {
66 });
67
68 it('executes the highest priority callbacks first', () => {
69 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'));
70 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('B'));
69 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
70 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('B'));
71
72 // Yield before B is flushed
73 expect(Scheduler).toFlushAndYieldThrough(['A']);
74
75 - scheduleCallback(UserBlockingPriority, () => Scheduler.yieldValue('C'));
76 - scheduleCallback(UserBlockingPriority, () => Scheduler.yieldValue('D'));
75 + scheduleCallback(UserBlockingPriority, () =>
76 + Scheduler.unstable_yieldValue('C'),
77 + );
78 + scheduleCallback(UserBlockingPriority, () =>
79 + Scheduler.unstable_yieldValue('D'),
80 + );
81
82 // C and D should come first, because they are higher priority
83 expect(Scheduler).toFlushAndYield(['C', 'D', 'B']);
@@ -81,41 +85,41 @@ describe('Scheduler', () => {
85
86 it('expires work', () => {
87 scheduleCallback(NormalPriority, didTimeout => {
84 - Scheduler.advanceTime(100);
85 - Scheduler.yieldValue(`A (did timeout: ${didTimeout})`);
88 + Scheduler.unstable_advanceTime(100);
89 + Scheduler.unstable_yieldValue(`A (did timeout: ${didTimeout})`);
90 });
91 scheduleCallback(UserBlockingPriority, didTimeout => {
88 - Scheduler.advanceTime(100);
89 - Scheduler.yieldValue(`B (did timeout: ${didTimeout})`);
92 + Scheduler.unstable_advanceTime(100);
93 + Scheduler.unstable_yieldValue(`B (did timeout: ${didTimeout})`);
94 });
95 scheduleCallback(UserBlockingPriority, didTimeout => {
92 - Scheduler.advanceTime(100);
93 - Scheduler.yieldValue(`C (did timeout: ${didTimeout})`);
96 + Scheduler.unstable_advanceTime(100);
97 + Scheduler.unstable_yieldValue(`C (did timeout: ${didTimeout})`);
98 });
99
100 // Advance time, but not by enough to expire any work
97 - Scheduler.advanceTime(249);
101 + Scheduler.unstable_advanceTime(249);
102 expect(Scheduler).toHaveYielded([]);
103
104 // Schedule a few more callbacks
105 scheduleCallback(NormalPriority, didTimeout => {
102 - Scheduler.advanceTime(100);
103 - Scheduler.yieldValue(`D (did timeout: ${didTimeout})`);
106 + Scheduler.unstable_advanceTime(100);
107 + Scheduler.unstable_yieldValue(`D (did timeout: ${didTimeout})`);
108 });
109 scheduleCallback(NormalPriority, didTimeout => {
106 - Scheduler.advanceTime(100);
107 - Scheduler.yieldValue(`E (did timeout: ${didTimeout})`);
110 + Scheduler.unstable_advanceTime(100);
111 + Scheduler.unstable_yieldValue(`E (did timeout: ${didTimeout})`);
112 });
113
114 // Advance by just a bit more to expire the user blocking callbacks
111 - Scheduler.advanceTime(1);
115 + Scheduler.unstable_advanceTime(1);
116 expect(Scheduler).toHaveYielded([
117 'B (did timeout: true)',
118 'C (did timeout: true)',
119 ]);
120
121 // Expire A
118 - Scheduler.advanceTime(4600);
122 + Scheduler.unstable_advanceTime(4600);
123 expect(Scheduler).toHaveYielded(['A (did timeout: true)']);
124
125 // Flush the rest without expiring
@@ -126,23 +130,23 @@ describe('Scheduler', () => {
130 });
131
132 it('has a default expiration of ~5 seconds', () => {
129 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'));
133 + scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('A'));
134
131 - Scheduler.advanceTime(4999);
135 + Scheduler.unstable_advanceTime(4999);
136 expect(Scheduler).toHaveYielded([]);
137
134 - Scheduler.advanceTime(1);
138 + Scheduler.unstable_advanceTime(1);
139 expect(Scheduler).toHaveYielded(['A']);
140 });
141
142 it('continues working on same task after yielding', () => {
143 scheduleCallback(NormalPriority, () => {
140 - Scheduler.advanceTime(100);
141 - Scheduler.yieldValue('A');
144 + Scheduler.unstable_advanceTime(100);
145 + Scheduler.unstable_yieldValue('A');
146 });
147 scheduleCallback(NormalPriority, () => {
144 - Scheduler.advanceTime(100);
145 - Scheduler.yieldValue('B');
148 + Scheduler.unstable_advanceTime(100);
149 + Scheduler.unstable_yieldValue('B');
150 });
151
152 let didYield = false;
@@ -150,8 +154,8 @@ describe('Scheduler', () => {
154 const C = () => {
155 while (tasks.length > 0) {
156 const [label, ms] = tasks.shift();
153 - Scheduler.advanceTime(ms);
154 - Scheduler.yieldValue(label);
157 + Scheduler.unstable_advanceTime(ms);
158 + Scheduler.unstable_yieldValue(label);
159 if (shouldYield()) {
160 didYield = true;
161 return C;
@@ -162,12 +166,12 @@ describe('Scheduler', () => {
166 scheduleCallback(NormalPriority, C);
167
168 scheduleCallback(NormalPriority, () => {
165 - Scheduler.advanceTime(100);
166 - Scheduler.yieldValue('D');
169 + Scheduler.unstable_advanceTime(100);
170 + Scheduler.unstable_yieldValue('D');
171 });
172 scheduleCallback(NormalPriority, () => {
169 - Scheduler.advanceTime(100);
170 - Scheduler.yieldValue('E');
173 + Scheduler.unstable_advanceTime(100);
174 + Scheduler.unstable_yieldValue('E');
175 });
176
177 // Flush, then yield while in the middle of C.
@@ -184,8 +188,8 @@ describe('Scheduler', () => {
188 const work = () => {
189 while (tasks.length > 0) {
190 const [label, ms] = tasks.shift();
187 - Scheduler.advanceTime(ms);
188 - Scheduler.yieldValue(label);
191 + Scheduler.unstable_advanceTime(ms);
192 + Scheduler.unstable_yieldValue(label);
193 if (shouldYield()) {
194 return work;
195 }
@@ -199,7 +203,7 @@ describe('Scheduler', () => {
203 expect(Scheduler).toFlushAndYieldThrough(['A', 'B']);
204
205 // Advance time by just a bit more. This should expire all the remaining work.
202 - Scheduler.advanceTime(1);
206 + Scheduler.unstable_advanceTime(1);
207 expect(Scheduler).toHaveYielded(['C', 'D']);
208 });
209
@@ -208,8 +212,8 @@ describe('Scheduler', () => {
212 const work = () => {
213 while (tasks.length > 0) {
214 const [label, ms] = tasks.shift();
211 - Scheduler.advanceTime(ms);
212 - Scheduler.yieldValue(label);
215 + Scheduler.unstable_advanceTime(ms);
216 + Scheduler.unstable_yieldValue(label);
217 if (tasks.length > 0 && shouldYield()) {
218 return work;
219 }
@@ -219,8 +223,8 @@ describe('Scheduler', () => {
223 expect(Scheduler).toFlushAndYieldThrough(['A']);
224
225 scheduleCallback(UserBlockingPriority, () => {
222 - Scheduler.advanceTime(100);
223 - Scheduler.yieldValue('High pri');
226 + Scheduler.unstable_advanceTime(100);
227 + Scheduler.unstable_yieldValue('High pri');
228 });
229
230 expect(Scheduler).toFlushAndYield(['High pri', 'B', 'C', 'D']);
@@ -235,18 +239,18 @@ describe('Scheduler', () => {
239 while (tasks.length > 0) {
240 const task = tasks.shift();
241 const [label, ms] = task;
238 - Scheduler.advanceTime(ms);
239 - Scheduler.yieldValue(label);
242 + Scheduler.unstable_advanceTime(ms);
243 + Scheduler.unstable_yieldValue(label);
244 if (label === 'B') {
245 // Schedule high pri work from inside another callback
242 - Scheduler.yieldValue('Schedule high pri');
246 + Scheduler.unstable_yieldValue('Schedule high pri');
247 scheduleCallback(UserBlockingPriority, () => {
244 - Scheduler.advanceTime(100);
245 - Scheduler.yieldValue('High pri');
248 + Scheduler.unstable_advanceTime(100);
249 + Scheduler.unstable_yieldValue('High pri');
250 });
251 }
252 if (tasks.length > 0 && shouldYield()) {
249 - Scheduler.yieldValue('Yield!');
253 + Scheduler.unstable_yieldValue('Yield!');
254 return work;
255 }
256 }
@@ -268,10 +272,18 @@ describe('Scheduler', () => {
272 );
273
274 it('top-level immediate callbacks fire in a subsequent task', () => {
271 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('A'));
272 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('B'));
273 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('C'));
274 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('D'));
275 + scheduleCallback(ImmediatePriority, () =>
276 + Scheduler.unstable_yieldValue('A'),
277 + );
278 + scheduleCallback(ImmediatePriority, () =>
279 + Scheduler.unstable_yieldValue('B'),
280 + );
281 + scheduleCallback(ImmediatePriority, () =>
282 + Scheduler.unstable_yieldValue('C'),
283 + );
284 + scheduleCallback(ImmediatePriority, () =>
285 + Scheduler.unstable_yieldValue('D'),
286 + );
287 // Immediate callback hasn't fired, yet.
288 expect(Scheduler).toHaveYielded([]);
289 // They all flush immediately within the subsequent task.
@@ -279,13 +291,19 @@ describe('Scheduler', () => {
291 });
292
293 it('nested immediate callbacks are added to the queue of immediate callbacks', () => {
282 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('A'));
294 + scheduleCallback(ImmediatePriority, () =>
295 + Scheduler.unstable_yieldValue('A'),
296 + );
297 scheduleCallback(ImmediatePriority, () => {
284 - Scheduler.yieldValue('B');
298 + Scheduler.unstable_yieldValue('B');
299 // This callback should go to the end of the queue
286 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('C'));
300 + scheduleCallback(ImmediatePriority, () =>
301 + Scheduler.unstable_yieldValue('C'),
302 + );
303 });
288 - scheduleCallback(ImmediatePriority, () => Scheduler.yieldValue('D'));
304 + scheduleCallback(ImmediatePriority, () =>
305 + Scheduler.unstable_yieldValue('D'),
306 + );
307 expect(Scheduler).toHaveYielded([]);
308 // C should flush at the end
309 expect(Scheduler).toFlushExpired(['A', 'B', 'D', 'C']);
@@ -299,7 +317,7 @@ describe('Scheduler', () => {
317 it('wrapped callbacks inherit the current priority', () => {
318 const wrappedCallback = runWithPriority(NormalPriority, () =>
319 wrapCallback(() => {
302 - Scheduler.yieldValue(getCurrentPriorityLevel());
320 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
321 }),
322 );
323
@@ -307,7 +325,7 @@ describe('Scheduler', () => {
325 UserBlockingPriority,
326 () =>
327 wrapCallback(() => {
310 - Scheduler.yieldValue(getCurrentPriorityLevel());
328 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
329 }),
330 );
331
@@ -324,11 +342,11 @@ describe('Scheduler', () => {
342
343 runWithPriority(NormalPriority, () => {
344 wrappedCallback = wrapCallback(() => {
327 - Scheduler.yieldValue(getCurrentPriorityLevel());
345 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
346 });
347 wrappedUserBlockingCallback = runWithPriority(UserBlockingPriority, () =>
348 wrapCallback(() => {
331 - Scheduler.yieldValue(getCurrentPriorityLevel());
349 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
350 }),
351 );
352 });
@@ -342,14 +360,14 @@ describe('Scheduler', () => {
360
361 it("immediate callbacks fire even if there's an error", () => {
362 scheduleCallback(ImmediatePriority, () => {
345 - Scheduler.yieldValue('A');
363 + Scheduler.unstable_yieldValue('A');
364 throw new Error('Oops A');
365 });
366 scheduleCallback(ImmediatePriority, () => {
349 - Scheduler.yieldValue('B');
367 + Scheduler.unstable_yieldValue('B');
368 });
369 scheduleCallback(ImmediatePriority, () => {
352 - Scheduler.yieldValue('C');
370 + Scheduler.unstable_yieldValue('C');
371 throw new Error('Oops C');
372 });
373
@@ -369,22 +387,22 @@ describe('Scheduler', () => {
387 scheduleCallback(ImmediatePriority, () => {
388 throw new Error('Second error');
389 });
372 - expect(() => Scheduler.flushAll()).toThrow('First error');
390 + expect(() => Scheduler.unstable_flushAll()).toThrow('First error');
391 // The next error is thrown in the subsequent event
374 - expect(() => Scheduler.flushAll()).toThrow('Second error');
392 + expect(() => Scheduler.unstable_flushAll()).toThrow('Second error');
393 });
394
395 it('exposes the current priority level', () => {
378 - Scheduler.yieldValue(getCurrentPriorityLevel());
396 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
397 runWithPriority(ImmediatePriority, () => {
380 - Scheduler.yieldValue(getCurrentPriorityLevel());
398 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
399 runWithPriority(NormalPriority, () => {
382 - Scheduler.yieldValue(getCurrentPriorityLevel());
400 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
401 runWithPriority(UserBlockingPriority, () => {
384 - Scheduler.yieldValue(getCurrentPriorityLevel());
402 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
403 });
404 });
387 - Scheduler.yieldValue(getCurrentPriorityLevel());
405 + Scheduler.unstable_yieldValue(getCurrentPriorityLevel());
406 });
407
408 expect(Scheduler).toHaveYielded([
@@ -398,53 +416,73 @@ describe('Scheduler', () => {
416
417 describe('delayed tasks', () => {
418 it('schedules a delayed task', () => {
401 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'), {
402 - delay: 1000,
403 - });
419 + scheduleCallback(
420 + NormalPriority,
421 + () => Scheduler.unstable_yieldValue('A'),
422 + {
423 + delay: 1000,
424 + },
425 + );
426
427 // Should flush nothing, because delay hasn't elapsed
428 expect(Scheduler).toFlushAndYield([]);
429
430 // Advance time until right before the threshold
409 - Scheduler.advanceTime(999);
431 + Scheduler.unstable_advanceTime(999);
432 // Still nothing
433 expect(Scheduler).toFlushAndYield([]);
434
435 // Advance time past the threshold
414 - Scheduler.advanceTime(1);
436 + Scheduler.unstable_advanceTime(1);
437
438 // Now it should flush like normal
439 expect(Scheduler).toFlushAndYield(['A']);
440 });
441
442 it('schedules multiple delayed tasks', () => {
421 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('C'), {
422 - delay: 300,
423 - });
443 + scheduleCallback(
444 + NormalPriority,
445 + () => Scheduler.unstable_yieldValue('C'),
446 + {
447 + delay: 300,
448 + },
449 + );
450
425 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('B'), {
426 - delay: 200,
427 - });
451 + scheduleCallback(
452 + NormalPriority,
453 + () => Scheduler.unstable_yieldValue('B'),
454 + {
455 + delay: 200,
456 + },
457 + );
458
429 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('D'), {
430 - delay: 400,
431 - });
459 + scheduleCallback(
460 + NormalPriority,
461 + () => Scheduler.unstable_yieldValue('D'),
462 + {
463 + delay: 400,
464 + },
465 + );
466
433 - scheduleCallback(NormalPriority, () => Scheduler.yieldValue('A'), {
434 - delay: 100,
435 - });
467 + scheduleCallback(
468 + NormalPriority,
469 + () => Scheduler.unstable_yieldValue('A'),
470 + {
471 + delay: 100,
472 + },
473 + );
474
475 // Should flush nothing, because delay hasn't elapsed
476 expect(Scheduler).toFlushAndYield([]);
477
478 // Advance some time.
441 - Scheduler.advanceTime(200);
479 + Scheduler.unstable_advanceTime(200);
480 // Both A and B are no longer delayed. They can now flush incrementally.
481 expect(Scheduler).toFlushAndYieldThrough(['A']);
482 expect(Scheduler).toFlushAndYield(['B']);
483
484 // Advance the rest
447 - Scheduler.advanceTime(200);
485 + Scheduler.unstable_advanceTime(200);
486 expect(Scheduler).toFlushAndYield(['C', 'D']);
487 });
488
@@ -453,31 +491,31 @@ describe('Scheduler', () => {
491 // elapses, they will be the most important callback in the queue.
492 scheduleCallback(
493 UserBlockingPriority,
456 - () => Scheduler.yieldValue('Timer 2'),
494 + () => Scheduler.unstable_yieldValue('Timer 2'),
495 {delay: 300},
496 );
497 scheduleCallback(
498 UserBlockingPriority,
461 - () => Scheduler.yieldValue('Timer 1'),
499 + () => Scheduler.unstable_yieldValue('Timer 1'),
500 {delay: 100},
501 );
502
503 // Schedule some tasks at default priority.
504 scheduleCallback(NormalPriority, () => {
467 - Scheduler.yieldValue('A');
468 - Scheduler.advanceTime(100);
505 + Scheduler.unstable_yieldValue('A');
506 + Scheduler.unstable_advanceTime(100);
507 });
508 scheduleCallback(NormalPriority, () => {
471 - Scheduler.yieldValue('B');
472 - Scheduler.advanceTime(100);
509 + Scheduler.unstable_yieldValue('B');
510 + Scheduler.unstable_advanceTime(100);
511 });
512 scheduleCallback(NormalPriority, () => {
475 - Scheduler.yieldValue('C');
476 - Scheduler.advanceTime(100);
513 + Scheduler.unstable_yieldValue('C');
514 + Scheduler.unstable_advanceTime(100);
515 });
516 scheduleCallback(NormalPriority, () => {
479 - Scheduler.yieldValue('D');
480 - Scheduler.advanceTime(100);
517 + Scheduler.unstable_yieldValue('D');
518 + Scheduler.unstable_advanceTime(100);
519 });
520
521 // Flush all the work. The timers should be interleaved with the
@@ -497,12 +535,12 @@ describe('Scheduler', () => {
535 // elapses, they will be the most important callback in the queue.
536 scheduleCallback(
537 UserBlockingPriority,
500 - () => Scheduler.yieldValue('Timer 2'),
538 + () => Scheduler.unstable_yieldValue('Timer 2'),
539 {delay: 300},
540 );
541 scheduleCallback(
542 UserBlockingPriority,
505 - () => Scheduler.yieldValue('Timer 1'),
543 + () => Scheduler.unstable_yieldValue('Timer 1'),
544 {delay: 100},
545 );
546
@@ -512,8 +550,8 @@ describe('Scheduler', () => {
550 while (tasks.length > 0) {
551 const task = tasks.shift();
552 const [label, ms] = task;
515 - Scheduler.advanceTime(ms);
516 - Scheduler.yieldValue(label);
553 + Scheduler.unstable_advanceTime(ms);
554 + Scheduler.unstable_yieldValue(label);
555 if (tasks.length > 0 && shouldYield()) {
556 return work;
557 }
@@ -537,26 +575,26 @@ describe('Scheduler', () => {
575 scheduleCallback(
576 NormalPriority,
577 () => {
540 - Scheduler.yieldValue('A');
541 - Scheduler.advanceTime(100);
578 + Scheduler.unstable_yieldValue('A');
579 + Scheduler.unstable_advanceTime(100);
580 },
581 {delay: 100, timeout: 900},
582 );
583
546 - Scheduler.advanceTime(99);
584 + Scheduler.unstable_advanceTime(99);
585 // Does not flush because delay has not elapsed
586 expect(Scheduler).toFlushAndYield([]);
587
588 // Delay has elapsed but task has not expired
551 - Scheduler.advanceTime(1);
589 + Scheduler.unstable_advanceTime(1);
590 expect(Scheduler).toFlushExpired([]);
591
592 // Still not expired
555 - Scheduler.advanceTime(899);
593 + Scheduler.unstable_advanceTime(899);
594 expect(Scheduler).toFlushExpired([]);
595
596 // Now it expires
559 - Scheduler.advanceTime(1);
597 + Scheduler.unstable_advanceTime(1);
598 expect(Scheduler).toHaveYielded(['A']);
599 });
600
@@ -566,17 +604,17 @@ describe('Scheduler', () => {
604
605 scheduleCallback(
606 NormalPriority,
569 - () => Scheduler.yieldValue('A'),
607 + () => Scheduler.unstable_yieldValue('A'),
608 options,
609 );
610 const taskB = scheduleCallback(
611 NormalPriority,
574 - () => Scheduler.yieldValue('B'),
612 + () => Scheduler.unstable_yieldValue('B'),
613 options,
614 );
615 const taskC = scheduleCallback(
616 NormalPriority,
579 - () => Scheduler.yieldValue('C'),
617 + () => Scheduler.unstable_yieldValue('C'),
618 options,
619 );
620
@@ -585,7 +623,7 @@ describe('Scheduler', () => {
623 cancelCallback(taskB);
624
625 // Cancel C after its delay has elapsed
588 - Scheduler.advanceTime(500);
626 + Scheduler.unstable_advanceTime(500);
627 cancelCallback(taskC);
628
629 // Only A should flush
packages/scheduler/src/forks/SchedulerHostConfig.mock.js
+5 -5
@@ -140,7 +140,7 @@ export function unstable_flushExpired() {
140 }
141 }
142
143 -export function unstable_flushWithoutYielding(): boolean {
143 +export function unstable_flushAllWithoutAsserting(): boolean {
144 // Returns false if no work was flushed.
145 if (isFlushing) {
146 throw new Error('Already flushing work.');
@@ -174,14 +174,14 @@ export function unstable_clearYields(): Array<mixed> {
174 return values;
175 }
176
177 -export function flushAll(): void {
177 +export function unstable_flushAll(): void {
178 if (yieldedValues !== null) {
179 throw new Error(
180 'Log is not empty. Assert on the log of yielded values before ' +
181 'flushing additional work.',
182 );
183 }
184 - unstable_flushWithoutYielding();
184 + unstable_flushAllWithoutAsserting();
185 if (yieldedValues !== null) {
186 throw new Error(
187 'While flushing work, something yielded a value. Use an ' +
@@ -191,7 +191,7 @@ export function flushAll(): void {
191 }
192 }
193
194 -export function yieldValue(value: mixed): void {
194 +export function unstable_yieldValue(value: mixed): void {
195 if (yieldedValues === null) {
196 yieldedValues = [value];
197 } else {
@@ -199,7 +199,7 @@ export function yieldValue(value: mixed): void {
199 }
200 }
201
202 -export function advanceTime(ms: number) {
202 +export function unstable_advanceTime(ms: number) {
203 currentTime += ms;
204 if (!isFlushing) {
205 if (scheduledTimeout !== null && timeoutTime <= currentTime) {
packages/scheduler/unstable_mock.js
+4 -4
@@ -10,12 +10,12 @@
10 export * from './src/Scheduler';
11
12 export {
13 - unstable_flushWithoutYielding,
13 + unstable_flushAllWithoutAsserting,
14 unstable_flushNumberOfYields,
15 unstable_flushExpired,
16 unstable_clearYields,
17 unstable_flushUntilNextPaint,
18 - flushAll,
19 - yieldValue,
20 - advanceTime,
18 + unstable_flushAll,
19 + unstable_yieldValue,
20 + unstable_advanceTime,
21 } from './src/SchedulerHostConfig.js';
packages/shared/forks/Scheduler.umd.js
+2 -2
@@ -32,7 +32,7 @@ const {
32
33 // this doesn't actually exist on the scheduler, but it *does*
34 // on scheduler/unstable_mock, which we'll need inside act().
35 - unstable_flushWithoutYielding,
35 + unstable_flushAllWithoutAsserting,
36 } = ReactInternals.Scheduler;
37
38 export {
@@ -53,5 +53,5 @@ export {
53 unstable_LowPriority,
54 unstable_IdlePriority,
55 unstable_forceFrameRate,
56 - unstable_flushWithoutYielding,
56 + unstable_flushAllWithoutAsserting,
57 };
scripts/jest/matchers/schedulerTestMatchers.js
+2 -2
@@ -28,7 +28,7 @@ function assertYieldsWereCleared(Scheduler) {
28
29 function toFlushAndYield(Scheduler, expectedYields) {
30 assertYieldsWereCleared(Scheduler);
31 - Scheduler.unstable_flushWithoutYielding();
31 + Scheduler.unstable_flushAllWithoutAsserting();
32 const actualYields = Scheduler.unstable_clearYields();
33 return captureAssertion(() => {
34 expect(actualYields).toEqual(expectedYields);
@@ -68,7 +68,7 @@ function toFlushAndThrow(Scheduler, ...rest) {
68 assertYieldsWereCleared(Scheduler);
69 return captureAssertion(() => {
70 expect(() => {
71 - Scheduler.unstable_flushWithoutYielding();
71 + Scheduler.unstable_flushAllWithoutAsserting();
72 }).toThrow(...rest);
73 });
74 }