Use ReactDOM.unstable_batchedUpdates in Fiber tests (#8263)
Dan Abramov committed
Nov 10, 2016 at 21:28 UTC
da021ca4aeb5d83414cabbe370b65412a41deb1a
4 files changed
+31
-33
scripts/fiber/tests-failing.txt
-11
@@ -567,20 +567,9 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
567
* should warn when using non-React functions in JSX
568
569
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
570
-* should batch state when updating state twice
571
-* should batch state when updating two different state keys
572
-* should batch state and props together
573
-* should batch parent/child state updates together
574
-* should batch child/parent state updates together
575
-* should support chained state updates
576
-* should batch forceUpdate together
577
-* should update children even if parent blocks updates
578
-* should flow updates correctly
570
* should share reconcile transaction across different roots
571
* should queue mount-ready handlers across different roots
581
-* should flush updates in the correct order across roots
572
* should queue updates from during mount
583
-* does not call render after a component as been deleted
573
* marks top-level updates
574
* throws in setState if the update callback is not a function
575
* throws in replaceState if the update callback is not a function
scripts/fiber/tests-passing.txt
+11
@@ -1155,10 +1155,21 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
1155
* should allow simple functions to return false
1156
1157
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
1158
+* should batch state when updating state twice
1159
+* should batch state when updating two different state keys
1160
+* should batch state and props together
1161
+* should batch parent/child state updates together
1162
+* should batch child/parent state updates together
1163
+* should support chained state updates
1164
+* should batch forceUpdate together
1165
+* should update children even if parent blocks updates
1166
* should not reconcile children passed via props
1167
+* should flow updates correctly
1168
* should flush updates in the correct order
1169
+* should flush updates in the correct order across roots
1170
* should queue nested updates
1171
* calls componentWillReceiveProps setState callback properly
1172
+* does not call render after a component as been deleted
1173
* does not update one component twice in a batch (#2410)
1174
* does not update one component twice in a batch (#6371)
1175
* unstable_batchedUpdates should return value from a callback
src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js
+3
-5
@@ -19,7 +19,6 @@ var ReactCurrentOwner;
19
var ReactPropTypes;
20
var ReactServerRendering;
21
var ReactTestUtils;
22
-var ReactUpdates;
22
23
describe('ReactCompositeComponent', () => {
24
@@ -31,7 +30,6 @@ describe('ReactCompositeComponent', () => {
30
ReactPropTypes = require('ReactPropTypes');
31
ReactTestUtils = require('ReactTestUtils');
32
ReactServerRendering = require('ReactServerRendering');
34
- ReactUpdates = require('ReactUpdates');
33
34
MorphingComponent = class extends React.Component {
35
state = {activated: false};
@@ -813,7 +811,7 @@ describe('ReactCompositeComponent', () => {
811
expect(childInstance).toBeNull();
812
813
expect(parentInstance.state.flag).toBe(false);
816
- ReactUpdates.batchedUpdates(function() {
814
+ ReactDOM.unstable_batchedUpdates(function() {
815
parentInstance.setState({flag: true});
816
});
817
expect(parentInstance.state.flag).toBe(true);
@@ -1209,7 +1207,7 @@ describe('ReactCompositeComponent', () => {
1207
1208
// When more than one state update is enqueued, we have the same behavior
1209
var fifthState = new NotActuallyImmutable('fifth');
1212
- ReactUpdates.batchedUpdates(function() {
1210
+ ReactDOM.unstable_batchedUpdates(function() {
1211
moo.setState({str: 'fourth'});
1212
moo.replaceState(fifthState);
1213
});
@@ -1217,7 +1215,7 @@ describe('ReactCompositeComponent', () => {
1215
1216
// When more than one state update is enqueued, we have the same behavior
1217
var sixthState = new NotActuallyImmutable('sixth');
1220
- ReactUpdates.batchedUpdates(function() {
1218
+ ReactDOM.unstable_batchedUpdates(function() {
1219
moo.replaceState(sixthState);
1220
moo.setState({str: 'seventh'});
1221
});
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
+17
-17
@@ -42,7 +42,7 @@ describe('ReactUpdates', () => {
42
var instance = ReactTestUtils.renderIntoDocument(<Component />);
43
expect(instance.state.x).toBe(0);
44
45
- ReactUpdates.batchedUpdates(function() {
45
+ ReactDOM.unstable_batchedUpdates(function() {
46
instance.setState({x: 1});
47
instance.setState({x: 2});
48
expect(instance.state.x).toBe(0);
@@ -72,7 +72,7 @@ describe('ReactUpdates', () => {
72
expect(instance.state.x).toBe(0);
73
expect(instance.state.y).toBe(0);
74
75
- ReactUpdates.batchedUpdates(function() {
75
+ ReactDOM.unstable_batchedUpdates(function() {
76
instance.setState({x: 1});
77
instance.setState({y: 2});
78
expect(instance.state.x).toBe(0);
@@ -105,7 +105,7 @@ describe('ReactUpdates', () => {
105
expect(instance.props.x).toBe(0);
106
expect(instance.state.y).toBe(0);
107
108
- ReactUpdates.batchedUpdates(function() {
108
+ ReactDOM.unstable_batchedUpdates(function() {
109
ReactDOM.render(<Component x={1} />, container);
110
instance.setState({y: 2});
111
expect(instance.props.x).toBe(0);
@@ -152,7 +152,7 @@ describe('ReactUpdates', () => {
152
expect(instance.state.x).toBe(0);
153
expect(child.state.y).toBe(0);
154
155
- ReactUpdates.batchedUpdates(function() {
155
+ ReactDOM.unstable_batchedUpdates(function() {
156
instance.setState({x: 1});
157
child.setState({y: 2});
158
expect(instance.state.x).toBe(0);
@@ -201,7 +201,7 @@ describe('ReactUpdates', () => {
201
expect(instance.state.x).toBe(0);
202
expect(child.state.y).toBe(0);
203
204
- ReactUpdates.batchedUpdates(function() {
204
+ ReactDOM.unstable_batchedUpdates(function() {
205
child.setState({y: 2});
206
instance.setState({x: 1});
207
expect(instance.state.x).toBe(0);
@@ -237,7 +237,7 @@ describe('ReactUpdates', () => {
237
expect(instance.state.x).toBe(0);
238
239
var innerCallbackRun = false;
240
- ReactUpdates.batchedUpdates(function() {
240
+ ReactDOM.unstable_batchedUpdates(function() {
241
instance.setState({x: 1}, function() {
242
instance.setState({x: 2}, function() {
243
expect(this).toBe(instance);
@@ -281,7 +281,7 @@ describe('ReactUpdates', () => {
281
expect(instance.state.x).toBe(0);
282
283
var callbacksRun = 0;
284
- ReactUpdates.batchedUpdates(function() {
284
+ ReactDOM.unstable_batchedUpdates(function() {
285
instance.setState({x: 1}, function() {
286
callbacksRun++;
287
});
@@ -330,14 +330,14 @@ describe('ReactUpdates', () => {
330
expect(parentRenderCount).toBe(1);
331
expect(childRenderCount).toBe(1);
332
333
- ReactUpdates.batchedUpdates(function() {
333
+ ReactDOM.unstable_batchedUpdates(function() {
334
instance.setState({x: 1});
335
});
336
337
expect(parentRenderCount).toBe(1);
338
expect(childRenderCount).toBe(1);
339
340
- ReactUpdates.batchedUpdates(function() {
340
+ ReactDOM.unstable_batchedUpdates(function() {
341
instance.refs.child.setState({x: 1});
342
});
343
@@ -465,7 +465,7 @@ describe('ReactUpdates', () => {
465
function testUpdates(components, desiredWillUpdates, desiredDidUpdates) {
466
var i;
467
468
- ReactUpdates.batchedUpdates(function() {
468
+ ReactDOM.unstable_batchedUpdates(function() {
469
for (i = 0; i < components.length; i++) {
470
triggerUpdate(components[i]);
471
}
@@ -475,7 +475,7 @@ describe('ReactUpdates', () => {
475
476
// Try them in reverse order
477
478
- ReactUpdates.batchedUpdates(function() {
478
+ ReactDOM.unstable_batchedUpdates(function() {
479
for (i = components.length - 1; i >= 0; i--) {
480
triggerUpdate(components[i]);
481
}
@@ -519,7 +519,7 @@ describe('ReactUpdates', () => {
519
var containerB = document.createElement('div');
520
521
// Initial renders aren't batched together yet...
522
- ReactUpdates.batchedUpdates(function() {
522
+ ReactDOM.unstable_batchedUpdates(function() {
523
ReactDOM.render(<Component text="A1" />, containerA);
524
ReactDOM.render(<Component text="B1" />, containerB);
525
});
@@ -527,7 +527,7 @@ describe('ReactUpdates', () => {
527
528
// ...but updates are! Here only one more transaction is used, which means
529
// we only have to initialize and close the wrappers once.
530
- ReactUpdates.batchedUpdates(function() {
530
+ ReactDOM.unstable_batchedUpdates(function() {
531
ReactDOM.render(<Component text="A2" />, containerA);
532
ReactDOM.render(<Component text="B2" />, containerB);
533
});
@@ -568,7 +568,7 @@ describe('ReactUpdates', () => {
568
a = ReactTestUtils.renderIntoDocument(<A />);
569
b = ReactTestUtils.renderIntoDocument(<B />);
570
571
- ReactUpdates.batchedUpdates(function() {
571
+ ReactDOM.unstable_batchedUpdates(function() {
572
a.setState({x: 1});
573
b.setState({x: 1});
574
});
@@ -679,7 +679,7 @@ describe('ReactUpdates', () => {
679
680
expect(updates).toEqual([0, 1, 2]);
681
682
- ReactUpdates.batchedUpdates(function() {
682
+ ReactDOM.unstable_batchedUpdates(function() {
683
// Simulate update on each component from top to bottom.
684
instances.forEach(function(instance) {
685
instance.forceUpdate();
@@ -771,7 +771,7 @@ describe('ReactUpdates', () => {
771
}
772
}
773
774
- ReactUpdates.batchedUpdates(function() {
774
+ ReactDOM.unstable_batchedUpdates(function() {
775
ReactTestUtils.renderIntoDocument(
776
<div>
777
<A />
@@ -837,7 +837,7 @@ describe('ReactUpdates', () => {
837
838
var component = ReactTestUtils.renderIntoDocument(<A />);
839
840
- ReactUpdates.batchedUpdates(function() {
840
+ ReactDOM.unstable_batchedUpdates(function() {
841
// B will have scheduled an update but the batching should ensure that its
842
// update never fires.
843
componentB.setState({updates: 1});