Remove old CM exports (#18710)
Sebastian Markbåge committed
May 4, 2020 at 21:39 UTC
cd4a96035fc262334e96e7ca2547b086d8a00dab
13 files changed
+38
-139
packages/react-dom/index.classic.fb.js
-2
@@ -30,8 +30,6 @@ export {
30
unmountComponentAtNode,
31
createRoot,
32
createBlockingRoot,
33
- unstable_discreteUpdates,
34
- unstable_flushDiscreteUpdates,
33
unstable_flushControlled,
34
unstable_scheduleHydration,
35
unstable_renderSubtreeIntoContainer,
packages/react-dom/index.experimental.js
-2
@@ -21,8 +21,6 @@ export {
21
// exposeConcurrentModeAPIs
22
createRoot,
23
createBlockingRoot,
24
- unstable_discreteUpdates,
25
- unstable_flushDiscreteUpdates,
24
unstable_flushControlled,
25
unstable_scheduleHydration,
26
// Disabled behind disableUnstableRenderSubtreeIntoContainer
packages/react-dom/index.modern.fb.js
-2
@@ -15,8 +15,6 @@ export {
15
version,
16
createRoot,
17
createBlockingRoot,
18
- unstable_discreteUpdates,
19
- unstable_flushDiscreteUpdates,
18
unstable_flushControlled,
19
unstable_scheduleHydration,
20
} from './src/client/ReactDOM';
packages/react-dom/src/client/ReactDOM.js
-2
@@ -200,8 +200,6 @@ export {
200
// exposeConcurrentModeAPIs
201
createRoot,
202
createBlockingRoot,
203
- discreteUpdates as unstable_discreteUpdates,
204
- flushDiscreteUpdates as unstable_flushDiscreteUpdates,
203
flushControlled as unstable_flushControlled,
204
scheduleHydration as unstable_scheduleHydration,
205
// Disabled behind disableUnstableRenderSubtreeIntoContainer
packages/react-interactions/events/src/dom/__tests__/MixedResponders-test-internal.js
-70
@@ -104,76 +104,6 @@ describe('mixing responders with the heritage event system', () => {
104
document.body.removeChild(newContainer);
105
});
106
107
- // @gate experimental
108
- it('should properly flush sync when the event systems are mixed with unstable_flushDiscreteUpdates', () => {
109
- const useTap = require('react-interactions/events/tap').useTap;
110
- const ref = React.createRef();
111
- let renderCounts = 0;
112
-
113
- function MyComponent() {
114
- const [, updateCounter] = React.useState(0);
115
- renderCounts++;
116
-
117
- function handleTap() {
118
- updateCounter(count => count + 1);
119
- }
120
-
121
- const listener = useTap({
122
- onTapEnd: handleTap,
123
- });
124
-
125
- return (
126
- <div>
127
- <button
128
- ref={ref}
129
- DEPRECATED_flareListeners={listener}
130
- onClick={() => {
131
- // This should flush synchronously
132
- ReactDOM.unstable_flushDiscreteUpdates();
133
- updateCounter(count => count + 1);
134
- }}>
135
- Press me
136
- </button>
137
- </div>
138
- );
139
- }
140
-
141
- const newContainer = document.createElement('div');
142
- const root = ReactDOM.createRoot(newContainer);
143
- document.body.appendChild(newContainer);
144
- root.render(<MyComponent />);
145
- Scheduler.unstable_flushAll();
146
-
147
- const target = createEventTarget(ref.current);
148
- target.pointerdown({timeStamp: 100});
149
- target.pointerup({timeStamp: 100});
150
-
151
- if (__DEV__) {
152
- expect(renderCounts).toBe(4);
153
- } else {
154
- expect(renderCounts).toBe(2);
155
- }
156
- Scheduler.unstable_flushAll();
157
- if (__DEV__) {
158
- expect(renderCounts).toBe(6);
159
- } else {
160
- expect(renderCounts).toBe(3);
161
- }
162
-
163
- target.pointerdown({timeStamp: 100});
164
- // Ensure the timeStamp logic works
165
- target.pointerup({timeStamp: 101});
166
-
167
- if (__DEV__) {
168
- expect(renderCounts).toBe(8);
169
- } else {
170
- expect(renderCounts).toBe(4);
171
- }
172
-
173
- Scheduler.unstable_flushAll();
174
- document.body.removeChild(newContainer);
175
- });
176
-
107
// @gate experimental
108
it(
109
'should only flush before outermost discrete event handler when mixing ' +
packages/react-reconciler/src/ReactFiberHotReloading.new.js
+2
-2
@@ -18,7 +18,7 @@ import {
18
scheduleUpdateOnFiber,
19
flushPassiveEffects,
20
} from './ReactFiberWorkLoop.new';
21
-import {updateContainer, syncUpdates} from './ReactFiberReconciler.new';
21
+import {updateContainer} from './ReactFiberReconciler.new';
22
import {emptyContextObject} from './ReactFiberContext.new';
23
import {SyncLane} from './ReactFiberLane';
24
import {
@@ -258,7 +258,7 @@ export const scheduleRoot: ScheduleRoot = (
258
return;
259
}
260
flushPassiveEffects();
261
- syncUpdates(() => {
261
+ flushSync(() => {
262
updateContainer(element, root, null, null);
263
});
264
}
packages/react-reconciler/src/ReactFiberHotReloading.old.js
+2
-2
@@ -18,7 +18,7 @@ import {
18
scheduleUpdateOnFiber,
19
flushPassiveEffects,
20
} from './ReactFiberWorkLoop.old';
21
-import {updateContainer, syncUpdates} from './ReactFiberReconciler.old';
21
+import {updateContainer} from './ReactFiberReconciler.old';
22
import {emptyContextObject} from './ReactFiberContext.old';
23
import {Sync} from './ReactFiberExpirationTime.old';
24
import {
@@ -258,7 +258,7 @@ export const scheduleRoot: ScheduleRoot = (
258
return;
259
}
260
flushPassiveEffects();
261
- syncUpdates(() => {
261
+ flushSync(() => {
262
updateContainer(element, root, null, null);
263
});
264
}
packages/react-reconciler/src/ReactFiberReconciler.js
-5
@@ -21,7 +21,6 @@ import {
21
batchedUpdates as batchedUpdates_old,
22
unbatchedUpdates as unbatchedUpdates_old,
23
deferredUpdates as deferredUpdates_old,
24
- syncUpdates as syncUpdates_old,
24
discreteUpdates as discreteUpdates_old,
25
flushDiscreteUpdates as flushDiscreteUpdates_old,
26
flushControlled as flushControlled_old,
@@ -49,7 +48,6 @@ import {
48
batchedUpdates as batchedUpdates_new,
49
unbatchedUpdates as unbatchedUpdates_new,
50
deferredUpdates as deferredUpdates_new,
52
- syncUpdates as syncUpdates_new,
51
discreteUpdates as discreteUpdates_new,
52
flushDiscreteUpdates as flushDiscreteUpdates_new,
53
flushControlled as flushControlled_new,
@@ -88,9 +86,6 @@ export const unbatchedUpdates = enableNewReconciler
86
export const deferredUpdates = enableNewReconciler
87
? deferredUpdates_new
88
: deferredUpdates_old;
91
-export const syncUpdates = enableNewReconciler
92
- ? syncUpdates_new
93
- : syncUpdates_old;
89
export const discreteUpdates = enableNewReconciler
90
? discreteUpdates_new
91
: discreteUpdates_old;
packages/react-reconciler/src/ReactFiberReconciler.new.js
-2
@@ -56,7 +56,6 @@ import {
56
flushSync,
57
flushControlled,
58
deferredUpdates,
59
- syncUpdates,
59
discreteUpdates,
60
flushDiscreteUpdates,
61
flushPassiveEffects,
@@ -306,7 +305,6 @@ export {
305
batchedUpdates,
306
unbatchedUpdates,
307
deferredUpdates,
309
- syncUpdates,
308
discreteUpdates,
309
flushDiscreteUpdates,
310
flushControlled,
packages/react-reconciler/src/ReactFiberReconciler.old.js
-2
@@ -56,7 +56,6 @@ import {
56
flushSync,
57
flushControlled,
58
deferredUpdates,
59
- syncUpdates,
59
discreteUpdates,
60
flushDiscreteUpdates,
61
flushPassiveEffects,
@@ -308,7 +307,6 @@ export {
307
batchedUpdates,
308
unbatchedUpdates,
309
deferredUpdates,
311
- syncUpdates,
310
discreteUpdates,
311
flushDiscreteUpdates,
312
flushControlled,
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+5
-10
@@ -1008,15 +1008,6 @@ export function deferredUpdates<A>(fn: () => A): A {
1008
return runWithPriority(NormalSchedulerPriority, fn);
1009
}
1010
1011
-export function syncUpdates<A, B, C, R>(
1012
- fn: (A, B, C) => R,
1013
- a: A,
1014
- b: B,
1015
- c: C,
1016
-): R {
1017
- return runWithPriority(ImmediateSchedulerPriority, fn.bind(null, a, b, c));
1018
-}
1019
-
1011
function flushPendingDiscreteUpdates() {
1012
if (rootsWithPendingDiscreteUpdates !== null) {
1013
// For each root with pending discrete updates, schedule a callback to
@@ -1113,7 +1104,11 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
1104
}
1105
executionContext |= BatchedContext;
1106
try {
1116
- return runWithPriority(ImmediateSchedulerPriority, fn.bind(null, a));
1107
+ if (fn) {
1108
+ return runWithPriority(ImmediateSchedulerPriority, fn.bind(null, a));
1109
+ } else {
1110
+ return (undefined: $FlowFixMe);
1111
+ }
1112
} finally {
1113
executionContext = prevExecutionContext;
1114
// Flush the immediate callbacks that were scheduled during this batch.
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+5
-10
@@ -1065,15 +1065,6 @@ export function deferredUpdates<A>(fn: () => A): A {
1065
return runWithPriority(NormalPriority, fn);
1066
}
1067
1068
-export function syncUpdates<A, B, C, R>(
1069
- fn: (A, B, C) => R,
1070
- a: A,
1071
- b: B,
1072
- c: C,
1073
-): R {
1074
- return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
1075
-}
1076
-
1068
function flushPendingDiscreteUpdates() {
1069
if (rootsWithPendingDiscreteUpdates !== null) {
1070
// For each root with pending discrete updates, schedule a callback to
@@ -1167,7 +1158,11 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
1158
}
1159
executionContext |= BatchedContext;
1160
try {
1170
- return runWithPriority(ImmediatePriority, fn.bind(null, a));
1161
+ if (fn) {
1162
+ return runWithPriority(ImmediatePriority, fn.bind(null, a));
1163
+ } else {
1164
+ return (undefined: $FlowFixMe);
1165
+ }
1166
} finally {
1167
executionContext = prevExecutionContext;
1168
// Flush the immediate callbacks that were scheduled during this batch.
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+24
-28
@@ -1656,7 +1656,7 @@ describe('ReactHooksWithNoopRenderer', () => {
1656
});
1657
});
1658
1659
- it('flushes passive effects when flushing discrete updates', () => {
1659
+ it('does not flush non-discrete passive effects when flushing sync', () => {
1660
let _updateCount;
1661
function Counter(props) {
1662
const [count, updateCount] = useState(0);
@@ -1678,28 +1678,28 @@ describe('ReactHooksWithNoopRenderer', () => {
1678
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1679
}).toErrorDev(['An update to Counter ran an effect']);
1680
1681
- // A discrete event forces the passive effect to be flushed --
1682
- // updateCount(1) happens first, so 2 wins.
1683
- ReactNoop.flushDiscreteUpdates();
1684
- ReactNoop.discreteUpdates(() => {
1685
- // (use batchedUpdates to silence the act() warning)
1686
- ReactNoop.batchedUpdates(() => {
1681
+ // A flush sync doesn't cause the passive effects to fire.
1682
+ // So we haven't added the other update yet.
1683
+ act(() => {
1684
+ ReactNoop.flushSync(() => {
1685
_updateCount(2);
1686
});
1687
});
1690
- expect(Scheduler).toHaveYielded(['Will set count to 1']);
1691
- expect(() => {
1692
- expect(Scheduler).toFlushAndYield(['Count: 2']);
1693
- }).toErrorDev([
1694
- 'An update to Counter ran an effect',
1695
- 'An update to Counter ran an effect',
1688
+
1689
+ // As a result we, somewhat surprisingly, commit them in the opposite order.
1690
+ // This should be fine because any non-discrete set of work doesn't guarantee order
1691
+ // and easily could've happened slightly later too.
1692
+ expect(Scheduler).toHaveYielded([
1693
+ 'Will set count to 1',
1694
+ 'Count: 2',
1695
+ 'Count: 1',
1696
]);
1697
1698
- expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
1698
+ expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1699
});
1700
1701
// @gate enableSchedulerTracing
1702
- it('flushes passive effects when flushing discrete updates (with tracing)', () => {
1702
+ it('does not flush non-discrete passive effects when flushing sync (with tracing)', () => {
1703
const onInteractionScheduledWorkCompleted = jest.fn();
1704
const onWorkCanceled = jest.fn();
1705
SchedulerTracing.unstable_subscribe({
@@ -1744,24 +1744,20 @@ describe('ReactHooksWithNoopRenderer', () => {
1744
1745
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);
1746
1747
- // A discrete event forces the passive effect to be flushed --
1748
- // updateCount(1) happens first, so 2 wins.
1749
- ReactNoop.flushDiscreteUpdates();
1750
- ReactNoop.discreteUpdates(() => {
1751
- // (use batchedUpdates to silence the act() warning)
1752
- ReactNoop.batchedUpdates(() => {
1747
+ // A flush sync doesn't cause the passive effects to fire.
1748
+ act(() => {
1749
+ ReactNoop.flushSync(() => {
1750
_updateCount(2);
1751
});
1752
});
1756
- expect(Scheduler).toHaveYielded(['Will set count to 1']);
1757
- expect(() => {
1758
- expect(Scheduler).toFlushAndYield(['Count: 2']);
1759
- }).toErrorDev([
1760
- 'An update to Counter ran an effect',
1761
- 'An update to Counter ran an effect',
1753
+
1754
+ expect(Scheduler).toHaveYielded([
1755
+ 'Will set count to 1',
1756
+ 'Count: 2',
1757
+ 'Count: 1',
1758
]);
1759
1764
- expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
1760
+ expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1761
1762
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
1763
expect(onWorkCanceled).toHaveBeenCalledTimes(0);