ReactNoop.yield -> Scheduler.yieldValue (#15008)
These used to be different things, but now ReactNoop.yield merely re-exports Scheduler.yieldValue, so let's get rid of it.
Andrew Clark committed
Mar 4, 2019 at 11:23 UTC
757a70b25dd33966380409d6c491bc0fe741ce08
19 files changed
+359
-361
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
- ReactNoop.yield(value);
63
+ Scheduler.yieldValue(value);
64
return null;
65
}}
66
</Subscription>,
@@ -97,7 +97,7 @@ describe('createSubscription', () => {
97
});
98
99
function render(value = 'default') {
100
- ReactNoop.yield(value);
100
+ Scheduler.yieldValue(value);
101
return null;
102
}
103
@@ -126,9 +126,9 @@ describe('createSubscription', () => {
126
127
function render(hasLoaded) {
128
if (hasLoaded === undefined) {
129
- ReactNoop.yield('loading');
129
+ Scheduler.yieldValue('loading');
130
} else {
131
- ReactNoop.yield(hasLoaded ? 'finished' : 'failed');
131
+ Scheduler.yieldValue(hasLoaded ? 'finished' : 'failed');
132
}
133
return null;
134
}
@@ -169,7 +169,7 @@ describe('createSubscription', () => {
169
});
170
171
function render(value = 'default') {
172
- ReactNoop.yield(value);
172
+ Scheduler.yieldValue(value);
173
return null;
174
}
175
@@ -203,7 +203,7 @@ describe('createSubscription', () => {
203
});
204
205
function render(hasLoaded) {
206
- ReactNoop.yield('rendered');
206
+ Scheduler.yieldValue('rendered');
207
return null;
208
}
209
@@ -235,7 +235,7 @@ describe('createSubscription', () => {
235
});
236
237
function render(value = 'default') {
238
- ReactNoop.yield(value);
238
+ Scheduler.yieldValue(value);
239
return null;
240
}
241
@@ -268,7 +268,7 @@ describe('createSubscription', () => {
268
const log = [];
269
270
function Child({value}) {
271
- ReactNoop.yield('Child: ' + value);
271
+ Scheduler.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
- ReactNoop.yield('Subscriber: ' + value);
308
+ Scheduler.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
- ReactNoop.yield('Child: ' + value);
358
+ Scheduler.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
- ReactNoop.yield('Subscriber: ' + value);
395
+ Scheduler.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
- ReactNoop.yield(props.value);
362
+ Scheduler.yieldValue(props.value);
363
return null;
364
}
365
packages/react-noop-renderer/src/createReactNoop.js
-2
@@ -696,8 +696,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
696
return Scheduler.unstable_flushExpired();
697
},
698
699
- yield: Scheduler.yieldValue,
700
-
699
batchedUpdates: NoopRenderer.batchedUpdates,
700
701
deferredUpdates: NoopRenderer.deferredUpdates,
packages/react-reconciler/src/__tests__/ReactExpiration-test.internal.js
+9
-9
@@ -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
- ReactNoop.yield(`${this.props.text} [commit]`);
54
+ Scheduler.yieldValue(`${this.props.text} [commit]`);
55
}
56
componentDidUpdate() {
57
- ReactNoop.yield(`${this.props.text} [commit]`);
57
+ Scheduler.yieldValue(`${this.props.text} [commit]`);
58
}
59
render() {
60
- ReactNoop.yield(`${this.props.text} [render]`);
60
+ Scheduler.yieldValue(`${this.props.text} [render]`);
61
return <span prop={this.props.text} />;
62
}
63
}
@@ -116,13 +116,13 @@ describe('ReactExpiration', () => {
116
() => {
117
class Text extends React.Component {
118
componentDidMount() {
119
- ReactNoop.yield(`${this.props.text} [commit]`);
119
+ Scheduler.yieldValue(`${this.props.text} [commit]`);
120
}
121
componentDidUpdate() {
122
- ReactNoop.yield(`${this.props.text} [commit]`);
122
+ Scheduler.yieldValue(`${this.props.text} [commit]`);
123
}
124
render() {
125
- ReactNoop.yield(`${this.props.text} [render]`);
125
+ Scheduler.yieldValue(`${this.props.text} [render]`);
126
return <span prop={this.props.text} />;
127
}
128
}
@@ -188,13 +188,13 @@ describe('ReactExpiration', () => {
188
state = {text: store.text};
189
componentDidMount() {
190
subscribers.push(this);
191
- ReactNoop.yield(`${this.state.text} [${this.props.label}] [commit]`);
191
+ Scheduler.yieldValue(`${this.state.text} [${this.props.label}] [commit]`);
192
}
193
componentDidUpdate() {
194
- ReactNoop.yield(`${this.state.text} [${this.props.label}] [commit]`);
194
+ Scheduler.yieldValue(`${this.state.text} [${this.props.label}] [commit]`);
195
}
196
render() {
197
- ReactNoop.yield(`${this.state.text} [${this.props.label}] [render]`);
197
+ Scheduler.yieldValue(`${this.state.text} [${this.props.label}] [render]`);
198
return <span prop={this.state.text} />;
199
}
200
}
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js
+107
-107
@@ -61,7 +61,7 @@ describe('ReactHooksWithNoopRenderer', () => {
61
}
62
63
function Text(props) {
64
- ReactNoop.yield(props.text);
64
+ Scheduler.yieldValue(props.text);
65
return <span prop={props.text} />;
66
}
67
@@ -176,7 +176,7 @@ describe('ReactHooksWithNoopRenderer', () => {
176
it('lazy state initializer', () => {
177
function Counter(props, ref) {
178
const [count, updateCount] = useState(() => {
179
- ReactNoop.yield('getInitialState');
179
+ Scheduler.yieldValue('getInitialState');
180
return props.initialState;
181
});
182
useImperativeHandle(ref, () => ({updateCount}));
@@ -325,7 +325,7 @@ describe('ReactHooksWithNoopRenderer', () => {
325
if (count < 3) {
326
setCount(count + 1);
327
}
328
- ReactNoop.yield('Render: ' + count);
328
+ Scheduler.yieldValue('Render: ' + count);
329
return <Text text={count} />;
330
}
331
@@ -348,7 +348,7 @@ describe('ReactHooksWithNoopRenderer', () => {
348
setCount(c => c + 1);
349
setCount(c => c + 1);
350
}
351
- ReactNoop.yield('Render: ' + count);
351
+ Scheduler.yieldValue('Render: ' + count);
352
return <Text text={count} />;
353
}
354
@@ -369,7 +369,7 @@ describe('ReactHooksWithNoopRenderer', () => {
369
function Counter({row: newRow}) {
370
let [count, setCount] = useState(0);
371
setCount(count + 1);
372
- ReactNoop.yield('Render: ' + count);
372
+ Scheduler.yieldValue('Render: ' + count);
373
return <Text text={count} />;
374
}
375
ReactNoop.render(<Counter />);
@@ -388,7 +388,7 @@ describe('ReactHooksWithNoopRenderer', () => {
388
if (count < 3) {
389
dispatch('increment');
390
}
391
- ReactNoop.yield('Render: ' + count);
391
+ Scheduler.yieldValue('Render: ' + count);
392
return <Text text={count} />;
393
}
394
@@ -437,7 +437,7 @@ describe('ReactHooksWithNoopRenderer', () => {
437
setReducer(() => reducerA);
438
}
439
}
440
- ReactNoop.yield('Render: ' + count);
440
+ Scheduler.yieldValue('Render: ' + count);
441
return <Text text={count} />;
442
}
443
Counter = forwardRef(Counter);
@@ -529,7 +529,7 @@ describe('ReactHooksWithNoopRenderer', () => {
529
530
function Counter(props, ref) {
531
const [count, dispatch] = useReducer(reducer, props, p => {
532
- ReactNoop.yield('Init');
532
+ Scheduler.yieldValue('Init');
533
return p.initialCount;
534
});
535
useImperativeHandle(ref, () => ({dispatch}));
@@ -597,12 +597,12 @@ describe('ReactHooksWithNoopRenderer', () => {
597
it('simple mount and update', () => {
598
function Counter(props) {
599
useEffect(() => {
600
- ReactNoop.yield(`Passive effect [${props.count}]`);
600
+ Scheduler.yieldValue(`Passive effect [${props.count}]`);
601
});
602
return <Text text={'Count: ' + props.count} />;
603
}
604
ReactNoop.render(<Counter count={0} />, () =>
605
- ReactNoop.yield('Sync effect'),
605
+ Scheduler.yieldValue('Sync effect'),
606
);
607
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
608
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -610,7 +610,7 @@ describe('ReactHooksWithNoopRenderer', () => {
610
expect(Scheduler).toFlushAndYield(['Passive effect [0]']);
611
612
ReactNoop.render(<Counter count={1} />, () =>
613
- ReactNoop.yield('Sync effect'),
613
+ Scheduler.yieldValue('Sync effect'),
614
);
615
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
616
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -621,13 +621,13 @@ describe('ReactHooksWithNoopRenderer', () => {
621
it('flushes passive effects even with sibling deletions', () => {
622
function LayoutEffect(props) {
623
useLayoutEffect(() => {
624
- ReactNoop.yield(`Layout effect`);
624
+ Scheduler.yieldValue(`Layout effect`);
625
});
626
return <Text text="Layout" />;
627
}
628
function PassiveEffect(props) {
629
useEffect(() => {
630
- ReactNoop.yield(`Passive effect`);
630
+ Scheduler.yieldValue(`Passive effect`);
631
}, []);
632
return <Text text="Passive" />;
633
}
@@ -658,7 +658,7 @@ describe('ReactHooksWithNoopRenderer', () => {
658
it('flushes passive effects even if siblings schedule an update', () => {
659
function PassiveEffect(props) {
660
useEffect(() => {
661
- ReactNoop.yield('Passive effect');
661
+ Scheduler.yieldValue('Passive effect');
662
});
663
return <Text text="Passive" />;
664
}
@@ -669,7 +669,7 @@ describe('ReactHooksWithNoopRenderer', () => {
669
if (count === 0) {
670
setCount(1);
671
}
672
- ReactNoop.yield('Layout effect ' + count);
672
+ Scheduler.yieldValue('Layout effect ' + count);
673
});
674
return <Text text="Layout" />;
675
}
@@ -696,13 +696,13 @@ describe('ReactHooksWithNoopRenderer', () => {
696
it('flushes passive effects even if siblings schedule a new root', () => {
697
function PassiveEffect(props) {
698
useEffect(() => {
699
- ReactNoop.yield('Passive effect');
699
+ Scheduler.yieldValue('Passive effect');
700
}, []);
701
return <Text text="Passive" />;
702
}
703
function LayoutEffect(props) {
704
useLayoutEffect(() => {
705
- ReactNoop.yield('Layout effect');
705
+ Scheduler.yieldValue('Layout effect');
706
// Scheduling work shouldn't interfere with the queued passive effect
707
ReactNoop.renderToRootWithID(<Text text="New Root" />, 'root2');
708
});
@@ -736,21 +736,21 @@ describe('ReactHooksWithNoopRenderer', () => {
736
737
function Counter(props) {
738
useEffect(() => {
739
- ReactNoop.yield(
739
+ Scheduler.yieldValue(
740
`Committed state when effect was fired: ${getCommittedText()}`,
741
);
742
});
743
return <Text text={props.count} />;
744
}
745
ReactNoop.render(<Counter count={0} />, () =>
746
- ReactNoop.yield('Sync effect'),
746
+ Scheduler.yieldValue('Sync effect'),
747
);
748
expect(Scheduler).toFlushAndYieldThrough([0, 'Sync effect']);
749
expect(ReactNoop.getChildren()).toEqual([span(0)]);
750
751
// Before the effects have a chance to flush, schedule another update
752
ReactNoop.render(<Counter count={1} />, () =>
753
- ReactNoop.yield('Sync effect'),
753
+ Scheduler.yieldValue('Sync effect'),
754
);
755
expect(Scheduler).toHaveYielded([
756
// The previous effect flushes before the reconciliation
@@ -771,7 +771,7 @@ describe('ReactHooksWithNoopRenderer', () => {
771
const [count, updateCount] = useState('(empty)');
772
useEffect(
773
() => {
774
- ReactNoop.yield(`Schedule update [${props.count}]`);
774
+ Scheduler.yieldValue(`Schedule update [${props.count}]`);
775
updateCount(props.count);
776
},
777
[props.count],
@@ -779,7 +779,7 @@ describe('ReactHooksWithNoopRenderer', () => {
779
return <Text text={'Count: ' + count} />;
780
}
781
ReactNoop.render(<Counter count={0} />, () =>
782
- ReactNoop.yield('Sync effect'),
782
+ Scheduler.yieldValue('Sync effect'),
783
);
784
expect(Scheduler).toFlushAndYieldThrough([
785
'Count: (empty)',
@@ -791,7 +791,7 @@ describe('ReactHooksWithNoopRenderer', () => {
791
expect(Scheduler).toFlushAndYield(['Count: 0']);
792
793
ReactNoop.render(<Counter count={1} />, () =>
794
- ReactNoop.yield('Sync effect'),
794
+ Scheduler.yieldValue('Sync effect'),
795
);
796
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
797
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -805,7 +805,7 @@ describe('ReactHooksWithNoopRenderer', () => {
805
const [count, updateCount] = useState('(empty)');
806
useEffect(
807
() => {
808
- ReactNoop.yield(`Schedule update [${props.count}]`);
808
+ Scheduler.yieldValue(`Schedule update [${props.count}]`);
809
updateCount(props.count);
810
},
811
[props.count],
@@ -813,7 +813,7 @@ describe('ReactHooksWithNoopRenderer', () => {
813
return <Text text={'Count: ' + count} />;
814
}
815
ReactNoop.render(<Counter count={0} />, () =>
816
- ReactNoop.yield('Sync effect'),
816
+ Scheduler.yieldValue('Sync effect'),
817
);
818
expect(Scheduler).toFlushAndYieldThrough([
819
'Count: (empty)',
@@ -823,7 +823,7 @@ describe('ReactHooksWithNoopRenderer', () => {
823
824
// Rendering again should flush the previous commit's effects
825
ReactNoop.render(<Counter count={1} />, () =>
826
- ReactNoop.yield('Sync effect'),
826
+ Scheduler.yieldValue('Sync effect'),
827
);
828
expect(Scheduler).toHaveYielded(['Schedule update [0]']);
829
expect(Scheduler).toFlushAndYieldThrough(['Count: 0']);
@@ -844,14 +844,14 @@ describe('ReactHooksWithNoopRenderer', () => {
844
const [count, updateCount] = useState(0);
845
_updateCount = updateCount;
846
useEffect(() => {
847
- ReactNoop.yield(`Will set count to 1`);
847
+ Scheduler.yieldValue(`Will set count to 1`);
848
updateCount(1);
849
}, []);
850
return <Text text={'Count: ' + count} />;
851
}
852
853
ReactNoop.render(<Counter count={0} />, () =>
854
- ReactNoop.yield('Sync effect'),
854
+ Scheduler.yieldValue('Sync effect'),
855
);
856
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
857
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -884,7 +884,7 @@ describe('ReactHooksWithNoopRenderer', () => {
884
expect(SchedulerTracing.unstable_getCurrent()).toMatchInteractions([
885
tracingEvent,
886
]);
887
- ReactNoop.yield(`Will set count to 1`);
887
+ Scheduler.yieldValue(`Will set count to 1`);
888
updateCount(1);
889
}, []);
890
return <Text text={'Count: ' + count} />;
@@ -896,7 +896,7 @@ describe('ReactHooksWithNoopRenderer', () => {
896
tracingEvent.timestamp,
897
() => {
898
ReactNoop.render(<Counter count={0} />, () =>
899
- ReactNoop.yield('Sync effect'),
899
+ Scheduler.yieldValue('Sync effect'),
900
);
901
},
902
);
@@ -955,7 +955,7 @@ describe('ReactHooksWithNoopRenderer', () => {
955
const [count, updateCount] = useState('(empty)');
956
useEffect(
957
() => {
958
- ReactNoop.yield(`Schedule update [${props.count}]`);
958
+ Scheduler.yieldValue(`Schedule update [${props.count}]`);
959
ReactNoop.flushSync(() => {
960
updateCount(props.count);
961
});
@@ -965,7 +965,7 @@ describe('ReactHooksWithNoopRenderer', () => {
965
return <Text text={'Count: ' + count} />;
966
}
967
ReactNoop.render(<Counter count={0} />, () =>
968
- ReactNoop.yield('Sync effect'),
968
+ Scheduler.yieldValue('Sync effect'),
969
);
970
expect(Scheduler).toFlushAndYieldThrough([
971
'Count: (empty)',
@@ -981,15 +981,15 @@ describe('ReactHooksWithNoopRenderer', () => {
981
it('unmounts previous effect', () => {
982
function Counter(props) {
983
useEffect(() => {
984
- ReactNoop.yield(`Did create [${props.count}]`);
984
+ Scheduler.yieldValue(`Did create [${props.count}]`);
985
return () => {
986
- ReactNoop.yield(`Did destroy [${props.count}]`);
986
+ Scheduler.yieldValue(`Did destroy [${props.count}]`);
987
};
988
});
989
return <Text text={'Count: ' + props.count} />;
990
}
991
ReactNoop.render(<Counter count={0} />, () =>
992
- ReactNoop.yield('Sync effect'),
992
+ Scheduler.yieldValue('Sync effect'),
993
);
994
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
995
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -997,7 +997,7 @@ describe('ReactHooksWithNoopRenderer', () => {
997
expect(Scheduler).toHaveYielded(['Did create [0]']);
998
999
ReactNoop.render(<Counter count={1} />, () =>
1000
- ReactNoop.yield('Sync effect'),
1000
+ Scheduler.yieldValue('Sync effect'),
1001
);
1002
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1003
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1008,15 +1008,15 @@ describe('ReactHooksWithNoopRenderer', () => {
1008
it('unmounts on deletion', () => {
1009
function Counter(props) {
1010
useEffect(() => {
1011
- ReactNoop.yield(`Did create [${props.count}]`);
1011
+ Scheduler.yieldValue(`Did create [${props.count}]`);
1012
return () => {
1013
- ReactNoop.yield(`Did destroy [${props.count}]`);
1013
+ Scheduler.yieldValue(`Did destroy [${props.count}]`);
1014
};
1015
});
1016
return <Text text={'Count: ' + props.count} />;
1017
}
1018
ReactNoop.render(<Counter count={0} />, () =>
1019
- ReactNoop.yield('Sync effect'),
1019
+ Scheduler.yieldValue('Sync effect'),
1020
);
1021
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1022
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1031,15 +1031,15 @@ describe('ReactHooksWithNoopRenderer', () => {
1031
it('unmounts on deletion after skipped effect', () => {
1032
function Counter(props) {
1033
useEffect(() => {
1034
- ReactNoop.yield(`Did create [${props.count}]`);
1034
+ Scheduler.yieldValue(`Did create [${props.count}]`);
1035
return () => {
1036
- ReactNoop.yield(`Did destroy [${props.count}]`);
1036
+ Scheduler.yieldValue(`Did destroy [${props.count}]`);
1037
};
1038
}, []);
1039
return <Text text={'Count: ' + props.count} />;
1040
}
1041
ReactNoop.render(<Counter count={0} />, () =>
1042
- ReactNoop.yield('Sync effect'),
1042
+ Scheduler.yieldValue('Sync effect'),
1043
);
1044
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1045
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1047,7 +1047,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1047
expect(Scheduler).toHaveYielded(['Did create [0]']);
1048
1049
ReactNoop.render(<Counter count={1} />, () =>
1050
- ReactNoop.yield('Sync effect'),
1050
+ Scheduler.yieldValue('Sync effect'),
1051
);
1052
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1053
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1061,9 +1061,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1061
1062
it('always fires effects if no dependencies are provided', () => {
1063
function effect() {
1064
- ReactNoop.yield(`Did create`);
1064
+ Scheduler.yieldValue(`Did create`);
1065
return () => {
1066
- ReactNoop.yield(`Did destroy`);
1066
+ Scheduler.yieldValue(`Did destroy`);
1067
};
1068
}
1069
function Counter(props) {
@@ -1071,7 +1071,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1071
return <Text text={'Count: ' + props.count} />;
1072
}
1073
ReactNoop.render(<Counter count={0} />, () =>
1074
- ReactNoop.yield('Sync effect'),
1074
+ Scheduler.yieldValue('Sync effect'),
1075
);
1076
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1077
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1079,7 +1079,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1079
expect(Scheduler).toHaveYielded(['Did create']);
1080
1081
ReactNoop.render(<Counter count={1} />, () =>
1082
- ReactNoop.yield('Sync effect'),
1082
+ Scheduler.yieldValue('Sync effect'),
1083
);
1084
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1085
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1096,9 +1096,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1096
const text = `${props.label}: ${props.count}`;
1097
useEffect(
1098
() => {
1099
- ReactNoop.yield(`Did create [${text}]`);
1099
+ Scheduler.yieldValue(`Did create [${text}]`);
1100
return () => {
1101
- ReactNoop.yield(`Did destroy [${text}]`);
1101
+ Scheduler.yieldValue(`Did destroy [${text}]`);
1102
};
1103
},
1104
[props.label, props.count],
@@ -1106,7 +1106,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1106
return <Text text={text} />;
1107
}
1108
ReactNoop.render(<Counter label="Count" count={0} />, () =>
1109
- ReactNoop.yield('Sync effect'),
1109
+ Scheduler.yieldValue('Sync effect'),
1110
);
1111
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1112
ReactNoop.flushPassiveEffects();
@@ -1114,7 +1114,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1114
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1115
1116
ReactNoop.render(<Counter label="Count" count={1} />, () =>
1117
- ReactNoop.yield('Sync effect'),
1117
+ Scheduler.yieldValue('Sync effect'),
1118
);
1119
// Count changed
1120
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
@@ -1126,7 +1126,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1126
]);
1127
1128
ReactNoop.render(<Counter label="Count" count={1} />, () =>
1129
- ReactNoop.yield('Sync effect'),
1129
+ Scheduler.yieldValue('Sync effect'),
1130
);
1131
// Nothing changed, so no effect should have fired
1132
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
@@ -1135,7 +1135,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1135
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1136
1137
ReactNoop.render(<Counter label="Total" count={1} />, () =>
1138
- ReactNoop.yield('Sync effect'),
1138
+ Scheduler.yieldValue('Sync effect'),
1139
);
1140
// Label changed
1141
expect(Scheduler).toFlushAndYieldThrough(['Total: 1', 'Sync effect']);
@@ -1150,15 +1150,15 @@ describe('ReactHooksWithNoopRenderer', () => {
1150
it('multiple effects', () => {
1151
function Counter(props) {
1152
useEffect(() => {
1153
- ReactNoop.yield(`Did commit 1 [${props.count}]`);
1153
+ Scheduler.yieldValue(`Did commit 1 [${props.count}]`);
1154
});
1155
useEffect(() => {
1156
- ReactNoop.yield(`Did commit 2 [${props.count}]`);
1156
+ Scheduler.yieldValue(`Did commit 2 [${props.count}]`);
1157
});
1158
return <Text text={'Count: ' + props.count} />;
1159
}
1160
ReactNoop.render(<Counter count={0} />, () =>
1161
- ReactNoop.yield('Sync effect'),
1161
+ Scheduler.yieldValue('Sync effect'),
1162
);
1163
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1164
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1166,7 +1166,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1166
expect(Scheduler).toHaveYielded(['Did commit 1 [0]', 'Did commit 2 [0]']);
1167
1168
ReactNoop.render(<Counter count={1} />, () =>
1169
- ReactNoop.yield('Sync effect'),
1169
+ Scheduler.yieldValue('Sync effect'),
1170
);
1171
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1172
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1177,21 +1177,21 @@ describe('ReactHooksWithNoopRenderer', () => {
1177
it('unmounts all previous effects before creating any new ones', () => {
1178
function Counter(props) {
1179
useEffect(() => {
1180
- ReactNoop.yield(`Mount A [${props.count}]`);
1180
+ Scheduler.yieldValue(`Mount A [${props.count}]`);
1181
return () => {
1182
- ReactNoop.yield(`Unmount A [${props.count}]`);
1182
+ Scheduler.yieldValue(`Unmount A [${props.count}]`);
1183
};
1184
});
1185
useEffect(() => {
1186
- ReactNoop.yield(`Mount B [${props.count}]`);
1186
+ Scheduler.yieldValue(`Mount B [${props.count}]`);
1187
return () => {
1188
- ReactNoop.yield(`Unmount B [${props.count}]`);
1188
+ Scheduler.yieldValue(`Unmount B [${props.count}]`);
1189
};
1190
});
1191
return <Text text={'Count: ' + props.count} />;
1192
}
1193
ReactNoop.render(<Counter count={0} />, () =>
1194
- ReactNoop.yield('Sync effect'),
1194
+ Scheduler.yieldValue('Sync effect'),
1195
);
1196
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1197
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1199,7 +1199,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1199
expect(Scheduler).toHaveYielded(['Mount A [0]', 'Mount B [0]']);
1200
1201
ReactNoop.render(<Counter count={1} />, () =>
1202
- ReactNoop.yield('Sync effect'),
1202
+ Scheduler.yieldValue('Sync effect'),
1203
);
1204
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1205
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1215,24 +1215,24 @@ describe('ReactHooksWithNoopRenderer', () => {
1215
it('handles errors on mount', () => {
1216
function Counter(props) {
1217
useEffect(() => {
1218
- ReactNoop.yield(`Mount A [${props.count}]`);
1218
+ Scheduler.yieldValue(`Mount A [${props.count}]`);
1219
return () => {
1220
- ReactNoop.yield(`Unmount A [${props.count}]`);
1220
+ Scheduler.yieldValue(`Unmount A [${props.count}]`);
1221
};
1222
});
1223
useEffect(() => {
1224
- ReactNoop.yield('Oops!');
1224
+ Scheduler.yieldValue('Oops!');
1225
throw new Error('Oops!');
1226
// eslint-disable-next-line no-unreachable
1227
- ReactNoop.yield(`Mount B [${props.count}]`);
1227
+ Scheduler.yieldValue(`Mount B [${props.count}]`);
1228
return () => {
1229
- ReactNoop.yield(`Unmount B [${props.count}]`);
1229
+ Scheduler.yieldValue(`Unmount B [${props.count}]`);
1230
};
1231
});
1232
return <Text text={'Count: ' + props.count} />;
1233
}
1234
ReactNoop.render(<Counter count={0} />, () =>
1235
- ReactNoop.yield('Sync effect'),
1235
+ Scheduler.yieldValue('Sync effect'),
1236
);
1237
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1238
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1250,25 +1250,25 @@ describe('ReactHooksWithNoopRenderer', () => {
1250
it('handles errors on update', () => {
1251
function Counter(props) {
1252
useEffect(() => {
1253
- ReactNoop.yield(`Mount A [${props.count}]`);
1253
+ Scheduler.yieldValue(`Mount A [${props.count}]`);
1254
return () => {
1255
- ReactNoop.yield(`Unmount A [${props.count}]`);
1255
+ Scheduler.yieldValue(`Unmount A [${props.count}]`);
1256
};
1257
});
1258
useEffect(() => {
1259
if (props.count === 1) {
1260
- ReactNoop.yield('Oops!');
1260
+ Scheduler.yieldValue('Oops!');
1261
throw new Error('Oops!');
1262
}
1263
- ReactNoop.yield(`Mount B [${props.count}]`);
1263
+ Scheduler.yieldValue(`Mount B [${props.count}]`);
1264
return () => {
1265
- ReactNoop.yield(`Unmount B [${props.count}]`);
1265
+ Scheduler.yieldValue(`Unmount B [${props.count}]`);
1266
};
1267
});
1268
return <Text text={'Count: ' + props.count} />;
1269
}
1270
ReactNoop.render(<Counter count={0} />, () =>
1271
- ReactNoop.yield('Sync effect'),
1271
+ Scheduler.yieldValue('Sync effect'),
1272
);
1273
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1274
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1277,7 +1277,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1277
1278
// This update will trigger an errror
1279
ReactNoop.render(<Counter count={1} />, () =>
1280
- ReactNoop.yield('Sync effect'),
1280
+ Scheduler.yieldValue('Sync effect'),
1281
);
1282
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1283
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1297,24 +1297,24 @@ describe('ReactHooksWithNoopRenderer', () => {
1297
it('handles errors on unmount', () => {
1298
function Counter(props) {
1299
useEffect(() => {
1300
- ReactNoop.yield(`Mount A [${props.count}]`);
1300
+ Scheduler.yieldValue(`Mount A [${props.count}]`);
1301
return () => {
1302
- ReactNoop.yield('Oops!');
1302
+ Scheduler.yieldValue('Oops!');
1303
throw new Error('Oops!');
1304
// eslint-disable-next-line no-unreachable
1305
- ReactNoop.yield(`Unmount A [${props.count}]`);
1305
+ Scheduler.yieldValue(`Unmount A [${props.count}]`);
1306
};
1307
});
1308
useEffect(() => {
1309
- ReactNoop.yield(`Mount B [${props.count}]`);
1309
+ Scheduler.yieldValue(`Mount B [${props.count}]`);
1310
return () => {
1311
- ReactNoop.yield(`Unmount B [${props.count}]`);
1311
+ Scheduler.yieldValue(`Unmount B [${props.count}]`);
1312
};
1313
});
1314
return <Text text={'Count: ' + props.count} />;
1315
}
1316
ReactNoop.render(<Counter count={0} />, () =>
1317
- ReactNoop.yield('Sync effect'),
1317
+ Scheduler.yieldValue('Sync effect'),
1318
);
1319
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1320
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
@@ -1323,7 +1323,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1323
1324
// This update will trigger an errror
1325
ReactNoop.render(<Counter count={1} />, () =>
1326
- ReactNoop.yield('Sync effect'),
1326
+ Scheduler.yieldValue('Sync effect'),
1327
);
1328
expect(Scheduler).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1329
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
@@ -1339,15 +1339,15 @@ describe('ReactHooksWithNoopRenderer', () => {
1339
it('works with memo', () => {
1340
function Counter({count}) {
1341
useLayoutEffect(() => {
1342
- ReactNoop.yield('Mount: ' + count);
1343
- return () => ReactNoop.yield('Unmount: ' + count);
1342
+ Scheduler.yieldValue('Mount: ' + count);
1343
+ return () => Scheduler.yieldValue('Unmount: ' + count);
1344
});
1345
return <Text text={'Count: ' + count} />;
1346
}
1347
Counter = memo(Counter);
1348
1349
ReactNoop.render(<Counter count={0} />, () =>
1350
- ReactNoop.yield('Sync effect'),
1350
+ Scheduler.yieldValue('Sync effect'),
1351
);
1352
expect(Scheduler).toFlushAndYieldThrough([
1353
'Count: 0',
@@ -1357,7 +1357,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1357
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1358
1359
ReactNoop.render(<Counter count={1} />, () =>
1360
- ReactNoop.yield('Sync effect'),
1360
+ Scheduler.yieldValue('Sync effect'),
1361
);
1362
expect(Scheduler).toFlushAndYieldThrough([
1363
'Count: 1',
@@ -1378,7 +1378,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1378
function getCommittedText() {
1379
const yields = Scheduler.unstable_clearYields();
1380
const children = ReactNoop.getChildren();
1381
- ReactNoop.yield(yields);
1381
+ Scheduler.yieldValue(yields);
1382
if (children === null) {
1383
return null;
1384
}
@@ -1387,13 +1387,13 @@ describe('ReactHooksWithNoopRenderer', () => {
1387
1388
function Counter(props) {
1389
useLayoutEffect(() => {
1390
- ReactNoop.yield(`Current: ${getCommittedText()}`);
1390
+ Scheduler.yieldValue(`Current: ${getCommittedText()}`);
1391
});
1392
return <Text text={props.count} />;
1393
}
1394
1395
ReactNoop.render(<Counter count={0} />, () =>
1396
- ReactNoop.yield('Sync effect'),
1396
+ Scheduler.yieldValue('Sync effect'),
1397
);
1398
expect(Scheduler).toFlushAndYieldThrough([
1399
[0],
@@ -1403,7 +1403,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1403
expect(ReactNoop.getChildren()).toEqual([span(0)]);
1404
1405
ReactNoop.render(<Counter count={1} />, () =>
1406
- ReactNoop.yield('Sync effect'),
1406
+ Scheduler.yieldValue('Sync effect'),
1407
);
1408
expect(Scheduler).toFlushAndYieldThrough([
1409
[1],
@@ -1422,22 +1422,22 @@ describe('ReactHooksWithNoopRenderer', () => {
1422
// intentionally omits a mutation effect.
1423
committedText = props.count + '';
1424
1425
- ReactNoop.yield(`Mount layout [current: ${committedText}]`);
1425
+ Scheduler.yieldValue(`Mount layout [current: ${committedText}]`);
1426
return () => {
1427
- ReactNoop.yield(`Unmount layout [current: ${committedText}]`);
1427
+ Scheduler.yieldValue(`Unmount layout [current: ${committedText}]`);
1428
};
1429
});
1430
useEffect(() => {
1431
- ReactNoop.yield(`Mount normal [current: ${committedText}]`);
1431
+ Scheduler.yieldValue(`Mount normal [current: ${committedText}]`);
1432
return () => {
1433
- ReactNoop.yield(`Unmount normal [current: ${committedText}]`);
1433
+ Scheduler.yieldValue(`Unmount normal [current: ${committedText}]`);
1434
};
1435
});
1436
return null;
1437
}
1438
1439
ReactNoop.render(<Counter count={0} />, () =>
1440
- ReactNoop.yield('Sync effect'),
1440
+ Scheduler.yieldValue('Sync effect'),
1441
);
1442
expect(Scheduler).toFlushAndYieldThrough([
1443
'Mount layout [current: 0]',
@@ -1446,7 +1446,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1446
expect(committedText).toEqual('0');
1447
1448
ReactNoop.render(<Counter count={1} />, () =>
1449
- ReactNoop.yield('Sync effect'),
1449
+ Scheduler.yieldValue('Sync effect'),
1450
);
1451
expect(Scheduler).toHaveYielded(['Mount normal [current: 0]']);
1452
expect(Scheduler).toFlushAndYieldThrough([
@@ -1535,7 +1535,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1535
const text = props.text;
1536
const capitalizedText = useMemo(
1537
() => {
1538
- ReactNoop.yield(`Capitalize '${text}'`);
1538
+ Scheduler.yieldValue(`Capitalize '${text}'`);
1539
return text.toUpperCase();
1540
},
1541
[text],
@@ -1567,12 +1567,12 @@ describe('ReactHooksWithNoopRenderer', () => {
1567
}
1568
1569
function computeA() {
1570
- ReactNoop.yield('compute A');
1570
+ Scheduler.yieldValue('compute A');
1571
return 'A';
1572
}
1573
1574
function computeB() {
1575
- ReactNoop.yield('compute B');
1575
+ Scheduler.yieldValue('compute B');
1576
return 'B';
1577
}
1578
@@ -1602,7 +1602,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1602
}
1603
1604
function compute(val) {
1605
- ReactNoop.yield('compute ' + val);
1605
+ Scheduler.yieldValue('compute ' + val);
1606
return val;
1607
}
1608
@@ -1642,7 +1642,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1642
function App() {
1643
ping = useDebouncedCallback(
1644
value => {
1645
- ReactNoop.yield('ping: ' + value);
1645
+ Scheduler.yieldValue('ping: ' + value);
1646
},
1647
100,
1648
[],
@@ -1911,17 +1911,17 @@ describe('ReactHooksWithNoopRenderer', () => {
1911
it('unmount effects', () => {
1912
function App(props) {
1913
useEffect(() => {
1914
- ReactNoop.yield('Mount A');
1914
+ Scheduler.yieldValue('Mount A');
1915
return () => {
1916
- ReactNoop.yield('Unmount A');
1916
+ Scheduler.yieldValue('Unmount A');
1917
};
1918
}, []);
1919
1920
if (props.showMore) {
1921
useEffect(() => {
1922
- ReactNoop.yield('Mount B');
1922
+ Scheduler.yieldValue('Mount B');
1923
return () => {
1924
- ReactNoop.yield('Unmount B');
1924
+ Scheduler.yieldValue('Unmount B');
1925
};
1926
}, []);
1927
}
@@ -1930,7 +1930,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1930
}
1931
1932
ReactNoop.render(<App showMore={false} />, () =>
1933
- ReactNoop.yield('Sync effect'),
1933
+ Scheduler.yieldValue('Sync effect'),
1934
);
1935
expect(Scheduler).toFlushAndYieldThrough(['Sync effect']);
1936
ReactNoop.flushPassiveEffects();
packages/react-reconciler/src/__tests__/ReactIncremental-test.internal.js
+31
-31
@@ -42,7 +42,7 @@ describe('ReactIncremental', () => {
42
43
it('should render a simple component, in steps if needed', () => {
44
function Bar() {
45
- ReactNoop.yield('Bar');
45
+ Scheduler.yieldValue('Bar');
46
return (
47
<span>
48
<div>Hello World</div>
@@ -51,11 +51,11 @@ describe('ReactIncremental', () => {
51
}
52
53
function Foo() {
54
- ReactNoop.yield('Foo');
54
+ Scheduler.yieldValue('Foo');
55
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
56
}
57
58
- ReactNoop.render(<Foo />, () => ReactNoop.yield('callback'));
58
+ ReactNoop.render(<Foo />, () => Scheduler.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
- ReactNoop.yield('Bar');
135
+ Scheduler.yieldValue('Bar');
136
return <div>{props.children}</div>;
137
}
138
139
function Foo(props) {
140
- ReactNoop.yield('Foo');
140
+ Scheduler.yieldValue('Foo');
141
return (
142
<div>
143
<Bar>{props.text}</Bar>
@@ -192,10 +192,10 @@ describe('ReactIncremental', () => {
192
193
inst.setState(
194
() => {
195
- ReactNoop.yield('setState1');
195
+ Scheduler.yieldValue('setState1');
196
return {text: 'bar'};
197
},
198
- () => ReactNoop.yield('callback1'),
198
+ () => Scheduler.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
- ReactNoop.yield('setState2');
208
+ Scheduler.yieldValue('setState2');
209
return {text2: 'baz'};
210
},
211
- () => ReactNoop.yield('callback2'),
211
+ () => Scheduler.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
- ReactNoop.yield('Bar');
226
+ Scheduler.yieldValue('Bar');
227
return <div>{props.children}</div>;
228
}
229
230
function Middle(props) {
231
- ReactNoop.yield('Middle');
231
+ Scheduler.yieldValue('Middle');
232
return <span>{props.children}</span>;
233
}
234
235
function Foo(props) {
236
- ReactNoop.yield('Foo');
236
+ Scheduler.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
- ReactNoop.yield(msg);
1089
+ Scheduler.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
- ReactNoop.yield('getDerivedStateFromProps');
1459
+ Scheduler.yieldValue('getDerivedStateFromProps');
1460
return prevState.parentRenders + 1;
1461
}
1462
render() {
1463
- ReactNoop.yield('Parent');
1463
+ Scheduler.yieldValue('Parent');
1464
return <Child parentRenders={this.state.parentRenders} ref={child} />;
1465
}
1466
}
1467
1468
class Child extends React.Component {
1469
render() {
1470
- ReactNoop.yield('Child');
1470
+ Scheduler.yieldValue('Child');
1471
return this.props.parentRenders;
1472
}
1473
}
@@ -1819,7 +1819,7 @@ describe('ReactIncremental', () => {
1819
};
1820
}
1821
render() {
1822
- ReactNoop.yield('Intl ' + JSON.stringify(this.context));
1822
+ Scheduler.yieldValue('Intl ' + JSON.stringify(this.context));
1823
return this.props.children;
1824
}
1825
}
@@ -1834,7 +1834,7 @@ describe('ReactIncremental', () => {
1834
};
1835
}
1836
render() {
1837
- ReactNoop.yield('Router ' + JSON.stringify(this.context));
1837
+ Scheduler.yieldValue('Router ' + JSON.stringify(this.context));
1838
return this.props.children;
1839
}
1840
}
@@ -1844,7 +1844,7 @@ describe('ReactIncremental', () => {
1844
locale: PropTypes.string,
1845
};
1846
render() {
1847
- ReactNoop.yield('ShowLocale ' + JSON.stringify(this.context));
1847
+ Scheduler.yieldValue('ShowLocale ' + JSON.stringify(this.context));
1848
return this.context.locale;
1849
}
1850
}
@@ -1854,13 +1854,13 @@ describe('ReactIncremental', () => {
1854
route: PropTypes.string,
1855
};
1856
render() {
1857
- ReactNoop.yield('ShowRoute ' + JSON.stringify(this.context));
1857
+ Scheduler.yieldValue('ShowRoute ' + JSON.stringify(this.context));
1858
return this.context.route;
1859
}
1860
}
1861
1862
function ShowBoth(props, context) {
1863
- ReactNoop.yield('ShowBoth ' + JSON.stringify(context));
1863
+ Scheduler.yieldValue('ShowBoth ' + JSON.stringify(context));
1864
return `${context.route} in ${context.locale}`;
1865
}
1866
ShowBoth.contextTypes = {
@@ -1870,14 +1870,14 @@ describe('ReactIncremental', () => {
1870
1871
class ShowNeither extends React.Component {
1872
render() {
1873
- ReactNoop.yield('ShowNeither ' + JSON.stringify(this.context));
1873
+ Scheduler.yieldValue('ShowNeither ' + JSON.stringify(this.context));
1874
return null;
1875
}
1876
}
1877
1878
class Indirection extends React.Component {
1879
render() {
1880
- ReactNoop.yield('Indirection ' + JSON.stringify(this.context));
1880
+ Scheduler.yieldValue('Indirection ' + JSON.stringify(this.context));
1881
return [
1882
<ShowLocale key="a" />,
1883
<ShowRoute key="b" />,
@@ -2049,7 +2049,7 @@ describe('ReactIncremental', () => {
2049
};
2050
}
2051
render() {
2052
- ReactNoop.yield('Intl ' + JSON.stringify(this.context));
2052
+ Scheduler.yieldValue('Intl ' + JSON.stringify(this.context));
2053
return this.props.children;
2054
}
2055
}
@@ -2059,7 +2059,7 @@ describe('ReactIncremental', () => {
2059
locale: PropTypes.string,
2060
};
2061
render() {
2062
- ReactNoop.yield('ShowLocale ' + JSON.stringify(this.context));
2062
+ Scheduler.yieldValue('ShowLocale ' + JSON.stringify(this.context));
2063
return this.context.locale;
2064
}
2065
}
@@ -2810,12 +2810,12 @@ describe('ReactIncremental', () => {
2810
2811
it('does not interrupt for update at same priority', () => {
2812
function Parent(props) {
2813
- ReactNoop.yield('Parent: ' + props.step);
2813
+ Scheduler.yieldValue('Parent: ' + props.step);
2814
return <Child step={props.step} />;
2815
}
2816
2817
function Child(props) {
2818
- ReactNoop.yield('Child: ' + props.step);
2818
+ Scheduler.yieldValue('Child: ' + props.step);
2819
return null;
2820
}
2821
@@ -2830,12 +2830,12 @@ describe('ReactIncremental', () => {
2830
2831
it('does not interrupt for update at lower priority', () => {
2832
function Parent(props) {
2833
- ReactNoop.yield('Parent: ' + props.step);
2833
+ Scheduler.yieldValue('Parent: ' + props.step);
2834
return <Child step={props.step} />;
2835
}
2836
2837
function Child(props) {
2838
- ReactNoop.yield('Child: ' + props.step);
2838
+ Scheduler.yieldValue('Child: ' + props.step);
2839
return null;
2840
}
2841
@@ -2851,12 +2851,12 @@ describe('ReactIncremental', () => {
2851
2852
it('does interrupt for update at higher priority', () => {
2853
function Parent(props) {
2854
- ReactNoop.yield('Parent: ' + props.step);
2854
+ Scheduler.yieldValue('Parent: ' + props.step);
2855
return <Child step={props.step} />;
2856
}
2857
2858
function Child(props) {
2859
- ReactNoop.yield('Child: ' + props.step);
2859
+ Scheduler.yieldValue('Child: ' + props.step);
2860
return null;
2861
}
2862
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+48
-48
@@ -45,31 +45,31 @@ describe('ReactIncrementalErrorHandling', () => {
45
class ErrorBoundary extends React.Component {
46
state = {error: null};
47
static getDerivedStateFromError(error) {
48
- ReactNoop.yield('getDerivedStateFromError');
48
+ Scheduler.yieldValue('getDerivedStateFromError');
49
return {error};
50
}
51
render() {
52
if (this.state.error) {
53
- ReactNoop.yield('ErrorBoundary (catch)');
53
+ Scheduler.yieldValue('ErrorBoundary (catch)');
54
return <ErrorMessage error={this.state.error} />;
55
}
56
- ReactNoop.yield('ErrorBoundary (try)');
56
+ Scheduler.yieldValue('ErrorBoundary (try)');
57
return this.props.children;
58
}
59
}
60
61
function ErrorMessage(props) {
62
- ReactNoop.yield('ErrorMessage');
62
+ Scheduler.yieldValue('ErrorMessage');
63
return <span prop={`Caught an error: ${props.error.message}`} />;
64
}
65
66
function Indirection(props) {
67
- ReactNoop.yield('Indirection');
67
+ Scheduler.yieldValue('Indirection');
68
return props.children || null;
69
}
70
71
function BadRender() {
72
- ReactNoop.yield('throw');
72
+ Scheduler.yieldValue('throw');
73
throw new Error('oops!');
74
}
75
@@ -138,31 +138,31 @@ describe('ReactIncrementalErrorHandling', () => {
138
class ErrorBoundary extends React.Component {
139
state = {error: null};
140
componentDidCatch(error) {
141
- ReactNoop.yield('componentDidCatch');
141
+ Scheduler.yieldValue('componentDidCatch');
142
this.setState({error});
143
}
144
render() {
145
if (this.state.error) {
146
- ReactNoop.yield('ErrorBoundary (catch)');
146
+ Scheduler.yieldValue('ErrorBoundary (catch)');
147
return <ErrorMessage error={this.state.error} />;
148
}
149
- ReactNoop.yield('ErrorBoundary (try)');
149
+ Scheduler.yieldValue('ErrorBoundary (try)');
150
return this.props.children;
151
}
152
}
153
154
function ErrorMessage(props) {
155
- ReactNoop.yield('ErrorMessage');
155
+ Scheduler.yieldValue('ErrorMessage');
156
return <span prop={`Caught an error: ${props.error.message}`} />;
157
}
158
159
function Indirection(props) {
160
- ReactNoop.yield('Indirection');
160
+ Scheduler.yieldValue('Indirection');
161
return props.children || null;
162
}
163
164
function BadRender() {
165
- ReactNoop.yield('throw');
165
+ Scheduler.yieldValue('throw');
166
throw new Error('oops!');
167
}
168
@@ -217,15 +217,15 @@ describe('ReactIncrementalErrorHandling', () => {
217
it("retries at a lower priority if there's additional pending work", () => {
218
function App(props) {
219
if (props.isBroken) {
220
- ReactNoop.yield('error');
220
+ Scheduler.yieldValue('error');
221
throw new Error('Oops!');
222
}
223
- ReactNoop.yield('success');
223
+ Scheduler.yieldValue('success');
224
return <span prop="Everything is fine." />;
225
}
226
227
function onCommit() {
228
- ReactNoop.yield('commit');
228
+ Scheduler.yieldValue('commit');
229
}
230
231
function interrupt() {
@@ -259,11 +259,11 @@ describe('ReactIncrementalErrorHandling', () => {
259
class Parent extends React.Component {
260
state = {hideChild: false};
261
componentDidUpdate() {
262
- ReactNoop.yield('commit: ' + this.state.hideChild);
262
+ Scheduler.yieldValue('commit: ' + this.state.hideChild);
263
}
264
render() {
265
if (this.state.hideChild) {
266
- ReactNoop.yield('(empty)');
266
+ Scheduler.yieldValue('(empty)');
267
return <span prop="(empty)" />;
268
}
269
return <Child isBroken={this.props.childIsBroken} />;
@@ -272,10 +272,10 @@ describe('ReactIncrementalErrorHandling', () => {
272
273
function Child(props) {
274
if (props.isBroken) {
275
- ReactNoop.yield('Error!');
275
+ Scheduler.yieldValue('Error!');
276
throw new Error('Error!');
277
}
278
- ReactNoop.yield('Child');
278
+ Scheduler.yieldValue('Child');
279
return <span prop="Child" />;
280
}
281
@@ -309,19 +309,19 @@ describe('ReactIncrementalErrorHandling', () => {
309
let ops = [];
310
function BadRender() {
311
ops.push('BadRender');
312
- ReactNoop.yield('BadRender');
312
+ Scheduler.yieldValue('BadRender');
313
throw new Error('oops');
314
}
315
316
function Sibling() {
317
ops.push('Sibling');
318
- ReactNoop.yield('Sibling');
318
+ Scheduler.yieldValue('Sibling');
319
return <span prop="Sibling" />;
320
}
321
322
function Parent() {
323
ops.push('Parent');
324
- ReactNoop.yield('Parent');
324
+ Scheduler.yieldValue('Parent');
325
return (
326
<React.Fragment>
327
<BadRender />
@@ -330,7 +330,7 @@ describe('ReactIncrementalErrorHandling', () => {
330
);
331
}
332
333
- ReactNoop.render(<Parent />, () => ReactNoop.yield('commit'));
333
+ ReactNoop.render(<Parent />, () => Scheduler.yieldValue('commit'));
334
335
// Render the bad component asynchronously
336
expect(Scheduler).toFlushAndYieldThrough(['Parent', 'BadRender']);
@@ -355,7 +355,7 @@ describe('ReactIncrementalErrorHandling', () => {
355
throw new Error(`Error ${++id}`);
356
}
357
render() {
358
- ReactNoop.yield('BadMount');
358
+ Scheduler.yieldValue('BadMount');
359
return null;
360
}
361
}
@@ -363,14 +363,14 @@ describe('ReactIncrementalErrorHandling', () => {
363
class ErrorBoundary extends React.Component {
364
state = {errorCount: 0};
365
componentDidCatch(error) {
366
- ReactNoop.yield(`componentDidCatch: ${error.message}`);
366
+ Scheduler.yieldValue(`componentDidCatch: ${error.message}`);
367
this.setState(state => ({errorCount: state.errorCount + 1}));
368
}
369
render() {
370
if (this.state.errorCount > 0) {
371
return <span prop={`Number of errors: ${this.state.errorCount}`} />;
372
}
373
- ReactNoop.yield('ErrorBoundary');
373
+ Scheduler.yieldValue('ErrorBoundary');
374
return this.props.children;
375
}
376
}
@@ -428,23 +428,23 @@ describe('ReactIncrementalErrorHandling', () => {
428
class ErrorBoundary extends React.Component {
429
state = {error: null};
430
componentDidCatch(error) {
431
- ReactNoop.yield('ErrorBoundary componentDidCatch');
431
+ Scheduler.yieldValue('ErrorBoundary componentDidCatch');
432
this.setState({error});
433
}
434
render() {
435
if (this.state.error) {
436
- ReactNoop.yield('ErrorBoundary render error');
436
+ Scheduler.yieldValue('ErrorBoundary render error');
437
return (
438
<span prop={`Caught an error: ${this.state.error.message}.`} />
439
);
440
}
441
- ReactNoop.yield('ErrorBoundary render success');
441
+ Scheduler.yieldValue('ErrorBoundary render success');
442
return this.props.children;
443
}
444
}
445
446
function BrokenRender(props) {
447
- ReactNoop.yield('BrokenRender');
447
+ Scheduler.yieldValue('BrokenRender');
448
throw new Error('Hello');
449
}
450
@@ -601,17 +601,17 @@ describe('ReactIncrementalErrorHandling', () => {
601
it('propagates an error from a noop error boundary during partial deferred mounting', () => {
602
class RethrowErrorBoundary extends React.Component {
603
componentDidCatch(error) {
604
- ReactNoop.yield('RethrowErrorBoundary componentDidCatch');
604
+ Scheduler.yieldValue('RethrowErrorBoundary componentDidCatch');
605
throw error;
606
}
607
render() {
608
- ReactNoop.yield('RethrowErrorBoundary render');
608
+ Scheduler.yieldValue('RethrowErrorBoundary render');
609
return this.props.children;
610
}
611
}
612
613
function BrokenRender() {
614
- ReactNoop.yield('BrokenRender');
614
+ Scheduler.yieldValue('BrokenRender');
615
throw new Error('Hello');
616
}
617
@@ -858,7 +858,7 @@ describe('ReactIncrementalErrorHandling', () => {
858
it('should not attempt to recover an unmounting error boundary', () => {
859
class Parent extends React.Component {
860
componentWillUnmount() {
861
- ReactNoop.yield('Parent componentWillUnmount');
861
+ Scheduler.yieldValue('Parent componentWillUnmount');
862
}
863
render() {
864
return <Boundary />;
@@ -867,7 +867,7 @@ describe('ReactIncrementalErrorHandling', () => {
867
868
class Boundary extends React.Component {
869
componentDidCatch(e) {
870
- ReactNoop.yield(`Caught error: ${e.message}`);
870
+ Scheduler.yieldValue(`Caught error: ${e.message}`);
871
}
872
render() {
873
return <ThrowsOnUnmount />;
@@ -876,7 +876,7 @@ describe('ReactIncrementalErrorHandling', () => {
876
877
class ThrowsOnUnmount extends React.Component {
878
componentWillUnmount() {
879
- ReactNoop.yield('ThrowsOnUnmount componentWillUnmount');
879
+ Scheduler.yieldValue('ThrowsOnUnmount componentWillUnmount');
880
throw new Error('unmount error');
881
}
882
render() {
@@ -1406,31 +1406,31 @@ describe('ReactIncrementalErrorHandling', () => {
1406
class ErrorBoundary extends React.Component {
1407
state = {error: null};
1408
componentDidCatch(error) {
1409
- ReactNoop.yield('componentDidCatch');
1409
+ Scheduler.yieldValue('componentDidCatch');
1410
this.setState({error});
1411
}
1412
render() {
1413
if (this.state.error) {
1414
- ReactNoop.yield('ErrorBoundary (catch)');
1414
+ Scheduler.yieldValue('ErrorBoundary (catch)');
1415
return <ErrorMessage error={this.state.error} />;
1416
}
1417
- ReactNoop.yield('ErrorBoundary (try)');
1417
+ Scheduler.yieldValue('ErrorBoundary (try)');
1418
return this.props.children;
1419
}
1420
}
1421
1422
function ErrorMessage(props) {
1423
- ReactNoop.yield('ErrorMessage');
1423
+ Scheduler.yieldValue('ErrorMessage');
1424
return <span prop={`Caught an error: ${props.error.message}`} />;
1425
}
1426
1427
function BadRenderSibling(props) {
1428
- ReactNoop.yield('BadRenderSibling');
1428
+ Scheduler.yieldValue('BadRenderSibling');
1429
return null;
1430
}
1431
1432
function BadRender() {
1433
- ReactNoop.yield('throw');
1433
+ Scheduler.yieldValue('throw');
1434
throw new Error('oops!');
1435
}
1436
@@ -1468,25 +1468,25 @@ describe('ReactIncrementalErrorHandling', () => {
1468
// where we checked for the existence of didUpdate instead of didMount, and
1469
// didMount was not defined.
1470
function BadRender() {
1471
- ReactNoop.yield('throw');
1471
+ Scheduler.yieldValue('throw');
1472
throw new Error('oops!');
1473
}
1474
1475
class Parent extends React.Component {
1476
state = {error: null, other: false};
1477
componentDidCatch(error) {
1478
- ReactNoop.yield('did catch');
1478
+ Scheduler.yieldValue('did catch');
1479
this.setState({error});
1480
}
1481
componentDidUpdate() {
1482
- ReactNoop.yield('did update');
1482
+ Scheduler.yieldValue('did update');
1483
}
1484
render() {
1485
if (this.state.error) {
1486
- ReactNoop.yield('render error message');
1486
+ Scheduler.yieldValue('render error message');
1487
return <span prop={`Caught an error: ${this.state.error.message}`} />;
1488
}
1489
- ReactNoop.yield('render');
1489
+ Scheduler.yieldValue('render');
1490
return <BadRender />;
1491
}
1492
}
@@ -1512,7 +1512,7 @@ describe('ReactIncrementalErrorHandling', () => {
1512
}
1513
render() {
1514
if (this.state.errorInfo) {
1515
- ReactNoop.yield('render error message');
1515
+ Scheduler.yieldValue('render error message');
1516
return (
1517
<span
1518
prop={`Caught an error:${normalizeCodeLocInfo(
packages/react-reconciler/src/__tests__/ReactIncrementalErrorLogging-test.js
+2
-2
@@ -167,10 +167,10 @@ describe('ReactIncrementalErrorLogging', () => {
167
this.setState({step: 1});
168
}
169
componentWillUnmount() {
170
- ReactNoop.yield('componentWillUnmount: ' + this.state.step);
170
+ Scheduler.yieldValue('componentWillUnmount: ' + this.state.step);
171
}
172
render() {
173
- ReactNoop.yield('render: ' + this.state.step);
173
+ Scheduler.yieldValue('render: ' + this.state.step);
174
if (this.state.step > 0) {
175
throw new Error('oops');
176
}
packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js
+4
-4
@@ -399,21 +399,21 @@ describe('ReactDebugFiberPerf', () => {
399
it('measures deferred work in chunks', () => {
400
class A extends React.Component {
401
render() {
402
- ReactNoop.yield('A');
402
+ Scheduler.yieldValue('A');
403
return <div>{this.props.children}</div>;
404
}
405
}
406
407
class B extends React.Component {
408
render() {
409
- ReactNoop.yield('B');
409
+ Scheduler.yieldValue('B');
410
return <div>{this.props.children}</div>;
411
}
412
}
413
414
class C extends React.Component {
415
render() {
416
- ReactNoop.yield('C');
416
+ Scheduler.yieldValue('C');
417
return <div>{this.props.children}</div>;
418
}
419
}
@@ -644,7 +644,7 @@ describe('ReactDebugFiberPerf', () => {
644
645
it('warns if an in-progress update is interrupted', () => {
646
function Foo() {
647
- ReactNoop.yield('Foo');
647
+ Scheduler.yieldValue('Foo');
648
return <span />;
649
}
650
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.internal.js
+12
-12
@@ -47,10 +47,10 @@ describe('ReactIncrementalReflection', () => {
47
}
48
UNSAFE_componentWillMount() {
49
instances.push(this);
50
- ReactNoop.yield('componentWillMount: ' + this._isMounted());
50
+ Scheduler.yieldValue('componentWillMount: ' + this._isMounted());
51
}
52
componentDidMount() {
53
- ReactNoop.yield('componentDidMount: ' + this._isMounted());
53
+ Scheduler.yieldValue('componentDidMount: ' + this._isMounted());
54
}
55
render() {
56
return <span />;
@@ -91,16 +91,16 @@ describe('ReactIncrementalReflection', () => {
91
instances.push(this);
92
}
93
componentWillUnmount() {
94
- ReactNoop.yield('componentWillUnmount: ' + this._isMounted());
94
+ Scheduler.yieldValue('componentWillUnmount: ' + this._isMounted());
95
}
96
render() {
97
- ReactNoop.yield('Component');
97
+ Scheduler.yieldValue('Component');
98
return <span />;
99
}
100
}
101
102
function Other() {
103
- ReactNoop.yield('Other');
103
+ Scheduler.yieldValue('Other');
104
return <span />;
105
}
106
@@ -149,22 +149,22 @@ describe('ReactIncrementalReflection', () => {
149
class Component extends React.Component {
150
UNSAFE_componentWillMount() {
151
classInstance = this;
152
- ReactNoop.yield(['componentWillMount', findInstance(this)]);
152
+ Scheduler.yieldValue(['componentWillMount', findInstance(this)]);
153
}
154
componentDidMount() {
155
- ReactNoop.yield(['componentDidMount', findInstance(this)]);
155
+ Scheduler.yieldValue(['componentDidMount', findInstance(this)]);
156
}
157
UNSAFE_componentWillUpdate() {
158
- ReactNoop.yield(['componentWillUpdate', findInstance(this)]);
158
+ Scheduler.yieldValue(['componentWillUpdate', findInstance(this)]);
159
}
160
componentDidUpdate() {
161
- ReactNoop.yield(['componentDidUpdate', findInstance(this)]);
161
+ Scheduler.yieldValue(['componentDidUpdate', findInstance(this)]);
162
}
163
componentWillUnmount() {
164
- ReactNoop.yield(['componentWillUnmount', findInstance(this)]);
164
+ Scheduler.yieldValue(['componentWillUnmount', findInstance(this)]);
165
}
166
render() {
167
- ReactNoop.yield('render');
167
+ Scheduler.yieldValue('render');
168
return this.props.step < 2 ? (
169
<span ref={ref => (this.span = ref)} />
170
) : this.props.step === 2 ? (
@@ -177,7 +177,7 @@ describe('ReactIncrementalReflection', () => {
177
178
function Sibling() {
179
// Sibling is used to assert that we've rendered past the first component.
180
- ReactNoop.yield('render sibling');
180
+ Scheduler.yieldValue('render sibling');
181
return <span />;
182
}
183
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.internal.js
+14
-14
@@ -92,7 +92,7 @@ describe('ReactIncrementalScheduling', () => {
92
function Text({text}) {
93
useEffect(
94
() => {
95
- ReactNoop.yield(text);
95
+ Scheduler.yieldValue(text);
96
},
97
[text],
98
);
@@ -144,24 +144,24 @@ describe('ReactIncrementalScheduling', () => {
144
state = {tick: 0};
145
146
componentDidMount() {
147
- ReactNoop.yield(
147
+ Scheduler.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
- ReactNoop.yield(
152
+ Scheduler.yieldValue(
153
'componentDidMount (after setState): ' + this.state.tick,
154
);
155
}
156
157
componentDidUpdate() {
158
- ReactNoop.yield('componentDidUpdate: ' + this.state.tick);
158
+ Scheduler.yieldValue('componentDidUpdate: ' + this.state.tick);
159
if (this.state.tick === 2) {
160
- ReactNoop.yield(
160
+ Scheduler.yieldValue(
161
'componentDidUpdate (before setState): ' + this.state.tick,
162
);
163
this.setState({tick: 3});
164
- ReactNoop.yield(
164
+ Scheduler.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
- ReactNoop.yield('render: ' + this.state.tick);
172
+ Scheduler.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
- ReactNoop.yield(
212
+ Scheduler.yieldValue(
213
'componentDidMount (before setState): ' + this.state.tick,
214
);
215
this.setState({tick: 1});
216
- ReactNoop.yield(
216
+ Scheduler.yieldValue(
217
'componentDidMount (after setState): ' + this.state.tick,
218
);
219
});
@@ -221,13 +221,13 @@ describe('ReactIncrementalScheduling', () => {
221
222
componentDidUpdate() {
223
ReactNoop.deferredUpdates(() => {
224
- ReactNoop.yield('componentDidUpdate: ' + this.state.tick);
224
+ Scheduler.yieldValue('componentDidUpdate: ' + this.state.tick);
225
if (this.state.tick === 2) {
226
- ReactNoop.yield(
226
+ Scheduler.yieldValue(
227
'componentDidUpdate (before setState): ' + this.state.tick,
228
);
229
this.setState({tick: 3});
230
- ReactNoop.yield(
230
+ Scheduler.yieldValue(
231
'componentDidUpdate (after setState): ' + this.state.tick,
232
);
233
}
@@ -235,7 +235,7 @@ describe('ReactIncrementalScheduling', () => {
235
}
236
237
render() {
238
- ReactNoop.yield('render: ' + this.state.tick);
238
+ Scheduler.yieldValue('render: ' + this.state.tick);
239
instance = this;
240
return <span prop={this.state.tick} />;
241
}
@@ -285,7 +285,7 @@ describe('ReactIncrementalScheduling', () => {
285
});
286
}
287
render() {
288
- ReactNoop.yield('Foo');
288
+ Scheduler.yieldValue('Foo');
289
return <span prop={this.state.step} />;
290
}
291
}
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.internal.js
+14
-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
- ReactNoop.yield('Bar');
378
+ Scheduler.yieldValue('Bar');
379
return <span prop={props.text} />;
380
}
381
382
function Foo(props) {
383
- ReactNoop.yield('Foo');
383
+ Scheduler.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
- ReactNoop.yield('Middle');
412
+ Scheduler.yieldValue('Middle');
413
return <span prop={props.children} />;
414
}
415
416
function Foo(props) {
417
- ReactNoop.yield('Foo');
417
+ Scheduler.yieldValue('Foo');
418
return (
419
<div>
420
<div hidden={true}>
@@ -435,7 +435,7 @@ describe('ReactIncrementalSideEffects', () => {
435
</div>,
436
);
437
438
- ReactNoop.render(<Foo text="bar" />, () => ReactNoop.yield('commit'));
438
+ ReactNoop.render(<Foo text="bar" />, () => Scheduler.yieldValue('commit'));
439
expect(Scheduler).toFlushAndYieldThrough(['Foo', 'commit']);
440
expect(ReactNoop.getChildrenAsJSX()).toEqual(
441
<div>
@@ -457,7 +457,7 @@ describe('ReactIncrementalSideEffects', () => {
457
458
it('can reuse side-effects after being preempted', () => {
459
function Bar(props) {
460
- ReactNoop.yield('Bar');
460
+ Scheduler.yieldValue('Bar');
461
return <span prop={props.children} />;
462
}
463
@@ -469,7 +469,7 @@ describe('ReactIncrementalSideEffects', () => {
469
);
470
471
function Foo(props) {
472
- ReactNoop.yield('Foo');
472
+ Scheduler.yieldValue('Foo');
473
return (
474
<div hidden={true}>
475
{props.step === 0 ? (
@@ -500,7 +500,7 @@ describe('ReactIncrementalSideEffects', () => {
500
// Make a quick update which will schedule low priority work to
501
// update the middle content.
502
ReactNoop.render(<Foo text="bar" step={1} />, () =>
503
- ReactNoop.yield('commit'),
503
+ Scheduler.yieldValue('commit'),
504
);
505
expect(Scheduler).toFlushAndYieldThrough(['Foo', 'commit', 'Bar']);
506
@@ -540,7 +540,7 @@ describe('ReactIncrementalSideEffects', () => {
540
return this.props.children !== nextProps.children;
541
}
542
render() {
543
- ReactNoop.yield('Bar');
543
+ Scheduler.yieldValue('Bar');
544
return <span prop={this.props.children} />;
545
}
546
}
@@ -550,7 +550,7 @@ describe('ReactIncrementalSideEffects', () => {
550
return this.props.step !== nextProps.step;
551
}
552
render() {
553
- ReactNoop.yield('Content');
553
+ Scheduler.yieldValue('Content');
554
return (
555
<div>
556
<Bar>{this.props.step === 0 ? 'Hi' : 'Hello'}</Bar>
@@ -561,7 +561,7 @@ describe('ReactIncrementalSideEffects', () => {
561
}
562
563
function Foo(props) {
564
- ReactNoop.yield('Foo');
564
+ Scheduler.yieldValue('Foo');
565
return (
566
<div hidden={true}>
567
<Content step={props.step} text={props.text} />
@@ -619,7 +619,7 @@ describe('ReactIncrementalSideEffects', () => {
619
620
it('can update a completed tree before it has a chance to commit', () => {
621
function Foo(props) {
622
- ReactNoop.yield('Foo');
622
+ Scheduler.yieldValue('Foo');
623
return <span prop={props.step} />;
624
}
625
ReactNoop.render(<Foo step={1} />);
@@ -901,12 +901,12 @@ describe('ReactIncrementalSideEffects', () => {
901
this.setState({active: true});
902
}
903
render() {
904
- ReactNoop.yield('Bar');
904
+ Scheduler.yieldValue('Bar');
905
return <span prop={this.state.active ? 'X' : this.props.idx} />;
906
}
907
}
908
function Foo(props) {
909
- ReactNoop.yield('Foo');
909
+ Scheduler.yieldValue('Foo');
910
return (
911
<div>
912
<span prop={props.tick} />
packages/react-reconciler/src/__tests__/ReactIncrementalTriangle-test.internal.js
+1
-1
@@ -216,7 +216,7 @@ describe('ReactIncrementalTriangle', () => {
216
}
217
render() {
218
if (yieldAfterEachRender) {
219
- ReactNoop.yield(this);
219
+ Scheduler.yieldValue(this);
220
}
221
const {counter, remainingDepth} = this.props;
222
return (
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.internal.js
+7
-7
@@ -34,7 +34,7 @@ describe('ReactIncrementalUpdates', () => {
34
class Foo extends React.Component {
35
state = {};
36
componentDidMount() {
37
- ReactNoop.yield('commit');
37
+ Scheduler.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
- ReactNoop.yield(letter);
153
+ Scheduler.yieldValue(letter);
154
return {
155
[letter]: letter,
156
};
@@ -221,7 +221,7 @@ describe('ReactIncrementalUpdates', () => {
221
222
function createUpdate(letter) {
223
return () => {
224
- ReactNoop.yield(letter);
224
+ Scheduler.yieldValue(letter);
225
return {
226
[letter]: letter,
227
};
@@ -461,9 +461,9 @@ describe('ReactIncrementalUpdates', () => {
461
const {useEffect} = React;
462
463
function App({label}) {
464
- ReactNoop.yield('Render: ' + label);
464
+ Scheduler.yieldValue('Render: ' + label);
465
useEffect(() => {
466
- ReactNoop.yield('Commit: ' + label);
466
+ Scheduler.yieldValue('Commit: ' + label);
467
});
468
return label;
469
}
@@ -547,9 +547,9 @@ describe('ReactIncrementalUpdates', () => {
547
const {useEffect} = React;
548
549
function App({label}) {
550
- ReactNoop.yield('Render: ' + label);
550
+ Scheduler.yieldValue('Render: ' + label);
551
useEffect(() => {
552
- ReactNoop.yield('Commit: ' + label);
552
+ Scheduler.yieldValue('Commit: ' + label);
553
});
554
return label;
555
}
packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js
+2
-2
@@ -36,7 +36,7 @@ describe('memo', () => {
36
}
37
38
function Text(props) {
39
- ReactNoop.yield(props.text);
39
+ Scheduler.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
- ReactNoop.yield(
187
+ Scheduler.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
+42
-42
@@ -30,7 +30,7 @@ describe('ReactNewContext', () => {
30
});
31
32
function Text(props) {
33
- ReactNoop.yield(props.text);
33
+ Scheduler.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
- ReactNoop.yield('Provider');
163
+ Scheduler.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
- ReactNoop.yield('Consumer');
172
+ Scheduler.yieldValue('Consumer');
173
return (
174
<ContextConsumer>
175
{value => {
176
- ReactNoop.yield('Consumer render prop');
176
+ Scheduler.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
- ReactNoop.yield('Indirection');
188
+ Scheduler.yieldValue('Indirection');
189
return this.props.children;
190
}
191
}
192
193
function App(props) {
194
- ReactNoop.yield('App');
194
+ Scheduler.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
- ReactNoop.yield('Provider');
232
+ Scheduler.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
- ReactNoop.yield('Consumer');
241
+ Scheduler.yieldValue('Consumer');
242
return (
243
<ContextConsumer>
244
{value => {
245
- ReactNoop.yield('Consumer render prop');
245
+ Scheduler.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
- ReactNoop.yield('Indirection');
257
+ Scheduler.yieldValue('Indirection');
258
return this.props.children;
259
}
260
}
261
262
function App(props) {
263
- ReactNoop.yield('App');
263
+ Scheduler.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
- ReactNoop.yield('Provider');
466
+ Scheduler.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
- ReactNoop.yield('Consumer');
475
+ Scheduler.yieldValue('Consumer');
476
return (
477
<ContextConsumer>
478
{value => {
479
- ReactNoop.yield('Consumer render prop');
479
+ Scheduler.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
- ReactNoop.yield('Indirection');
491
+ Scheduler.yieldValue('Indirection');
492
return this.props.children;
493
}
494
}
495
496
function App(props) {
497
- ReactNoop.yield('App');
497
+ Scheduler.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
- ReactNoop.yield('Foo');
608
+ Scheduler.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
- ReactNoop.yield('Bar');
619
+ Scheduler.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
- ReactNoop.yield('Foo');
707
+ Scheduler.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
- ReactNoop.yield('Bar');
723
+ Scheduler.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
- ReactNoop.yield('Child');
811
+ Scheduler.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
- ReactNoop.yield('Consumer render prop');
827
+ Scheduler.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
- ReactNoop.yield('Consumer');
850
+ Scheduler.yieldValue('Consumer');
851
return <span prop={value} />;
852
}
853
854
function ChildWithInlineRenderCallback() {
855
- ReactNoop.yield('ChildWithInlineRenderCallback');
855
+ Scheduler.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
- ReactNoop.yield('ChildWithCachedRenderCallback');
861
+ Scheduler.yieldValue('ChildWithCachedRenderCallback');
862
return <Consumer>{renderChildValue}</Consumer>;
863
}
864
865
class PureIndirection extends React.PureComponent {
866
render() {
867
- ReactNoop.yield('PureIndirection');
867
+ Scheduler.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
- ReactNoop.yield('App');
879
+ Scheduler.yieldValue('App');
880
return (
881
<Context.Provider value={this.props.value}>
882
<PureIndirection />
@@ -988,7 +988,7 @@ describe('ReactNewContext', () => {
988
};
989
990
render() {
991
- ReactNoop.yield('App');
991
+ Scheduler.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
- ReactNoop.yield('Consumer');
1019
+ Scheduler.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
- ReactNoop.yield('Foo');
1082
+ Scheduler.yieldValue('Foo');
1083
return null;
1084
}
1085
@@ -1119,14 +1119,14 @@ describe('ReactNewContext', () => {
1119
const Context = React.createContext(0);
1120
1121
function Child() {
1122
- ReactNoop.yield('Child');
1122
+ Scheduler.yieldValue('Child');
1123
return <span prop="Child" />;
1124
}
1125
1126
const children = <Child />;
1127
1128
function App(props) {
1129
- ReactNoop.yield('App');
1129
+ Scheduler.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
- ReactNoop.yield('Child');
1153
+ Scheduler.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
- ReactNoop.yield('LegacyProvider');
1168
+ Scheduler.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
- ReactNoop.yield('App');
1176
+ Scheduler.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
- ReactNoop.yield('App#renderConsumer');
1302
+ Scheduler.yieldValue('App#renderConsumer');
1303
return <span prop={this.state.text} />;
1304
};
1305
1306
render() {
1307
- ReactNoop.yield('App');
1307
+ Scheduler.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
- ReactNoop.yield('App#renderConsumer');
1442
+ Scheduler.yieldValue('App#renderConsumer');
1443
return <span prop={this.state.text} />;
1444
};
1445
1446
render() {
1447
- ReactNoop.yield('App');
1447
+ Scheduler.yieldValue('App');
1448
return (
1449
<Context.Provider value={this.props.value}>
1450
<Consumer>{this.renderConsumer}</Consumer>
@@ -1566,12 +1566,12 @@ describe('ReactNewContext', () => {
1566
};
1567
1568
renderConsumer = context => {
1569
- ReactNoop.yield('App#renderConsumer');
1569
+ Scheduler.yieldValue('App#renderConsumer');
1570
return <span prop={this.state.text} />;
1571
};
1572
1573
render() {
1574
- ReactNoop.yield('App');
1574
+ Scheduler.yieldValue('App');
1575
return (
1576
<Context.Provider value={this.props.value}>
1577
<Consumer>{this.renderConsumer}</Consumer>
@@ -1694,7 +1694,7 @@ describe('ReactNewContext', () => {
1694
return false;
1695
}
1696
render() {
1697
- ReactNoop.yield();
1697
+ Scheduler.yieldValue();
1698
if (this.props.depth >= this.props.maxDepth) {
1699
return null;
1700
}
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.internal.js
+38
-38
@@ -33,10 +33,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
33
return new Promise((resolve, reject) =>
34
setTimeout(() => {
35
if (textResourceShouldFail) {
36
- ReactNoop.yield(`Promise rejected [${text}]`);
36
+ Scheduler.yieldValue(`Promise rejected [${text}]`);
37
reject(new Error('Failed to load: ' + text));
38
} else {
39
- ReactNoop.yield(`Promise resolved [${text}]`);
39
+ Scheduler.yieldValue(`Promise resolved [${text}]`);
40
resolve(text);
41
}
42
}, ms),
@@ -69,7 +69,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
69
}
70
71
function Text(props) {
72
- ReactNoop.yield(props.text);
72
+ Scheduler.yieldValue(props.text);
73
return <span prop={props.text} ref={props.hostRef} />;
74
}
75
@@ -77,13 +77,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
77
const text = props.text;
78
try {
79
TextResource.read([props.text, props.ms]);
80
- ReactNoop.yield(text);
80
+ Scheduler.yieldValue(text);
81
return <span prop={text} />;
82
} catch (promise) {
83
if (typeof promise.then === 'function') {
84
- ReactNoop.yield(`Suspend! [${text}]`);
84
+ Scheduler.yieldValue(`Suspend! [${text}]`);
85
} else {
86
- ReactNoop.yield(`Error! [${text}]`);
86
+ Scheduler.yieldValue(`Error! [${text}]`);
87
}
88
throw promise;
89
}
@@ -91,12 +91,12 @@ describe('ReactSuspenseWithNoopRenderer', () => {
91
92
it('suspends rendering and continues later', async () => {
93
function Bar(props) {
94
- ReactNoop.yield('Bar');
94
+ Scheduler.yieldValue('Bar');
95
return props.children;
96
}
97
98
function Foo() {
99
- ReactNoop.yield('Foo');
99
+ Scheduler.yieldValue('Foo');
100
return (
101
<Suspense fallback={<Text text="Loading..." />}>
102
<Bar>
@@ -758,10 +758,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
758
it('flushes all expired updates in a single batch', async () => {
759
class Foo extends React.Component {
760
componentDidUpdate() {
761
- ReactNoop.yield('Commit: ' + this.props.text);
761
+ Scheduler.yieldValue('Commit: ' + this.props.text);
762
}
763
componentDidMount() {
764
- ReactNoop.yield('Commit: ' + this.props.text);
764
+ Scheduler.yieldValue('Commit: ' + this.props.text);
765
}
766
render() {
767
return (
@@ -919,7 +919,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
919
920
// Update. This starts out asynchronously.
921
text.current.setState({step: 2}, () =>
922
- ReactNoop.yield('Update did commit'),
922
+ Scheduler.yieldValue('Update did commit'),
923
);
924
925
// Suspend during an async render.
@@ -1001,7 +1001,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1001
1002
// Initial mount
1003
ReactNoop.renderLegacySyncRoot(<App />, () =>
1004
- ReactNoop.yield('Did mount'),
1004
+ Scheduler.yieldValue('Did mount'),
1005
);
1006
await advanceTimers(100);
1007
expect(Scheduler).toHaveYielded([
@@ -1030,10 +1030,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1030
1031
// Update. This starts out asynchronously.
1032
text1.current.setState({text: 'Async: 2'}, () =>
1033
- ReactNoop.yield('Update 1 did commit'),
1033
+ Scheduler.yieldValue('Update 1 did commit'),
1034
);
1035
text2.current.setState({text: 'Sync: 2'}, () =>
1036
- ReactNoop.yield('Update 2 did commit'),
1036
+ Scheduler.yieldValue('Update 2 did commit'),
1037
);
1038
1039
// Start rendering asynchronously
@@ -1136,7 +1136,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1136
1137
// Initial mount
1138
ReactNoop.renderLegacySyncRoot(<App />, () =>
1139
- ReactNoop.yield('Did mount'),
1139
+ Scheduler.yieldValue('Did mount'),
1140
);
1141
await advanceTimers(100);
1142
expect(Scheduler).toHaveYielded([
@@ -1165,10 +1165,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1165
1166
// Update. This starts out asynchronously.
1167
text1.current.setState({text: 'Async: 2'}, () =>
1168
- ReactNoop.yield('Update 1 did commit'),
1168
+ Scheduler.yieldValue('Update 1 did commit'),
1169
);
1170
text2.current.setState({text: 'Sync: 2'}, () =>
1171
- ReactNoop.yield('Update 2 did commit'),
1171
+ Scheduler.yieldValue('Update 2 did commit'),
1172
);
1173
1174
// Start rendering asynchronously
@@ -1226,10 +1226,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1226
it('does not re-render siblings in loose mode', async () => {
1227
class TextWithLifecycle extends React.Component {
1228
componentDidMount() {
1229
- ReactNoop.yield(`Mount [${this.props.text}]`);
1229
+ Scheduler.yieldValue(`Mount [${this.props.text}]`);
1230
}
1231
componentDidUpdate() {
1232
- ReactNoop.yield(`Update [${this.props.text}]`);
1232
+ Scheduler.yieldValue(`Update [${this.props.text}]`);
1233
}
1234
render() {
1235
return <Text {...this.props} />;
@@ -1238,10 +1238,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1238
1239
class AsyncTextWithLifecycle extends React.Component {
1240
componentDidMount() {
1241
- ReactNoop.yield(`Mount [${this.props.text}]`);
1241
+ Scheduler.yieldValue(`Mount [${this.props.text}]`);
1242
}
1243
componentDidUpdate() {
1244
- ReactNoop.yield(`Update [${this.props.text}]`);
1244
+ Scheduler.yieldValue(`Update [${this.props.text}]`);
1245
}
1246
render() {
1247
return <AsyncText {...this.props} />;
@@ -1261,7 +1261,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1261
}
1262
1263
ReactNoop.renderLegacySyncRoot(<App />, () =>
1264
- ReactNoop.yield('Commit root'),
1264
+ Scheduler.yieldValue('Commit root'),
1265
);
1266
expect(Scheduler).toHaveYielded([
1267
'A',
@@ -1303,24 +1303,24 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1303
constructor(props) {
1304
super(props);
1305
const text = props.text;
1306
- ReactNoop.yield('constructor');
1306
+ Scheduler.yieldValue('constructor');
1307
try {
1308
TextResource.read([props.text, props.ms]);
1309
this.state = {text};
1310
} catch (promise) {
1311
if (typeof promise.then === 'function') {
1312
- ReactNoop.yield(`Suspend! [${text}]`);
1312
+ Scheduler.yieldValue(`Suspend! [${text}]`);
1313
} else {
1314
- ReactNoop.yield(`Error! [${text}]`);
1314
+ Scheduler.yieldValue(`Error! [${text}]`);
1315
}
1316
throw promise;
1317
}
1318
}
1319
componentDidMount() {
1320
- ReactNoop.yield('componentDidMount');
1320
+ Scheduler.yieldValue('componentDidMount');
1321
}
1322
render() {
1323
- ReactNoop.yield(this.state.text);
1323
+ Scheduler.yieldValue(this.state.text);
1324
return <span prop={this.state.text} />;
1325
}
1326
}
@@ -1394,7 +1394,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1394
const child = useRef(null);
1395
1396
useLayoutEffect(() => {
1397
- ReactNoop.yield('Child is hidden: ' + child.current.hidden);
1397
+ Scheduler.yieldValue('Child is hidden: ' + child.current.hidden);
1398
});
1399
1400
return (
@@ -1430,13 +1430,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1430
it('does not call lifecycles of a suspended component', async () => {
1431
class TextWithLifecycle extends React.Component {
1432
componentDidMount() {
1433
- ReactNoop.yield(`Mount [${this.props.text}]`);
1433
+ Scheduler.yieldValue(`Mount [${this.props.text}]`);
1434
}
1435
componentDidUpdate() {
1436
- ReactNoop.yield(`Update [${this.props.text}]`);
1436
+ Scheduler.yieldValue(`Update [${this.props.text}]`);
1437
}
1438
componentWillUnmount() {
1439
- ReactNoop.yield(`Unmount [${this.props.text}]`);
1439
+ Scheduler.yieldValue(`Unmount [${this.props.text}]`);
1440
}
1441
render() {
1442
return <Text {...this.props} />;
@@ -1445,26 +1445,26 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1445
1446
class AsyncTextWithLifecycle extends React.Component {
1447
componentDidMount() {
1448
- ReactNoop.yield(`Mount [${this.props.text}]`);
1448
+ Scheduler.yieldValue(`Mount [${this.props.text}]`);
1449
}
1450
componentDidUpdate() {
1451
- ReactNoop.yield(`Update [${this.props.text}]`);
1451
+ Scheduler.yieldValue(`Update [${this.props.text}]`);
1452
}
1453
componentWillUnmount() {
1454
- ReactNoop.yield(`Unmount [${this.props.text}]`);
1454
+ Scheduler.yieldValue(`Unmount [${this.props.text}]`);
1455
}
1456
render() {
1457
const text = this.props.text;
1458
const ms = this.props.ms;
1459
try {
1460
TextResource.read([text, ms]);
1461
- ReactNoop.yield(text);
1461
+ Scheduler.yieldValue(text);
1462
return <span prop={text} />;
1463
} catch (promise) {
1464
if (typeof promise.then === 'function') {
1465
- ReactNoop.yield(`Suspend! [${text}]`);
1465
+ Scheduler.yieldValue(`Suspend! [${text}]`);
1466
} else {
1467
- ReactNoop.yield(`Error! [${text}]`);
1467
+ Scheduler.yieldValue(`Error! [${text}]`);
1468
}
1469
throw promise;
1470
}
@@ -1484,7 +1484,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1484
}
1485
1486
ReactNoop.renderLegacySyncRoot(<App />, () =>
1487
- ReactNoop.yield('Commit root'),
1487
+ Scheduler.yieldValue('Commit root'),
1488
);
1489
expect(Scheduler).toHaveYielded([
1490
'A',
packages/react/src/__tests__/ReactProfiler-test.internal.js
+3
-3
@@ -1208,13 +1208,13 @@ describe('Profiler', () => {
1208
1209
const Child = ({duration, id}) => {
1210
Scheduler.advanceTime(duration);
1211
- ReactNoop.yield(`Child:render:${id}`);
1211
+ Scheduler.yieldValue(`Child:render:${id}`);
1212
return null;
1213
};
1214
1215
class Parent extends React.Component {
1216
componentDidMount() {
1217
- ReactNoop.yield(`Parent:componentDidMount:${this.props.id}`);
1217
+ Scheduler.yieldValue(`Parent:componentDidMount:${this.props.id}`);
1218
}
1219
render() {
1220
const {duration, id} = this.props;
@@ -2261,7 +2261,7 @@ describe('Profiler', () => {
2261
const monkey = React.createRef();
2262
class Monkey extends React.Component {
2263
render() {
2264
- ReactNoop.yield('Monkey');
2264
+ Scheduler.yieldValue('Monkey');
2265
return null;
2266
}
2267
}
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
- ReactNoop.yield(this.props.value);
31
+ Scheduler.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
- ReactNoop.yield(this.props.value);
51
+ Scheduler.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
- ReactNoop.yield(this.props.value);
74
+ Scheduler.yieldValue(this.props.value);
75
return null;
76
}
77
}
@@ -103,7 +103,7 @@ describe('forwardRef', () => {
103
super(props);
104
}
105
render() {
106
- ReactNoop.yield(this.props.value);
106
+ Scheduler.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
- ReactNoop.yield('ErrorBoundary.componentDidCatch');
141
+ Scheduler.yieldValue('ErrorBoundary.componentDidCatch');
142
this.setState({error});
143
}
144
render() {
145
if (this.state.error) {
146
- ReactNoop.yield('ErrorBoundary.render: catch');
146
+ Scheduler.yieldValue('ErrorBoundary.render: catch');
147
return null;
148
}
149
- ReactNoop.yield('ErrorBoundary.render: try');
149
+ Scheduler.yieldValue('ErrorBoundary.render: try');
150
return this.props.children;
151
}
152
}
153
154
class BadRender extends React.Component {
155
render() {
156
- ReactNoop.yield('BadRender throw');
156
+ Scheduler.yieldValue('BadRender throw');
157
throw new Error('oops!');
158
}
159
}
160
161
function Wrapper(props) {
162
- ReactNoop.yield('Wrapper');
162
+ Scheduler.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
- ReactNoop.yield('Inner');
199
+ Scheduler.yieldValue('Inner');
200
inst = this;
201
return <div ref={this.props.forwardedRef} />;
202
}
203
}
204
205
function Middle(props) {
206
- ReactNoop.yield('Middle');
206
+ Scheduler.yieldValue('Middle');
207
return <Inner {...props} />;
208
}
209
210
const Forward = React.forwardRef((props, ref) => {
211
- ReactNoop.yield('Forward');
211
+ Scheduler.yieldValue('Forward');
212
return <Middle {...props} forwardedRef={ref} />;
213
});
214
215
function App() {
216
- ReactNoop.yield('App');
216
+ Scheduler.yieldValue('App');
217
return <Forward />;
218
}
219