Skip to content

Commit cd4a960

Browse files
authored
Remove old CM exports (facebook#18710)
1 parent 9751935 commit cd4a960

13 files changed

+38
-139
lines changed

packages/react-dom/index.classic.fb.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export {
3030
unmountComponentAtNode,
3131
createRoot,
3232
createBlockingRoot,
33-
unstable_discreteUpdates,
34-
unstable_flushDiscreteUpdates,
3533
unstable_flushControlled,
3634
unstable_scheduleHydration,
3735
unstable_renderSubtreeIntoContainer,

packages/react-dom/index.experimental.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export {
2121
// exposeConcurrentModeAPIs
2222
createRoot,
2323
createBlockingRoot,
24-
unstable_discreteUpdates,
25-
unstable_flushDiscreteUpdates,
2624
unstable_flushControlled,
2725
unstable_scheduleHydration,
2826
// Disabled behind disableUnstableRenderSubtreeIntoContainer

packages/react-dom/index.modern.fb.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export {
1515
version,
1616
createRoot,
1717
createBlockingRoot,
18-
unstable_discreteUpdates,
19-
unstable_flushDiscreteUpdates,
2018
unstable_flushControlled,
2119
unstable_scheduleHydration,
2220
} from './src/client/ReactDOM';

packages/react-dom/src/client/ReactDOM.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ export {
200200
// exposeConcurrentModeAPIs
201201
createRoot,
202202
createBlockingRoot,
203-
discreteUpdates as unstable_discreteUpdates,
204-
flushDiscreteUpdates as unstable_flushDiscreteUpdates,
205203
flushControlled as unstable_flushControlled,
206204
scheduleHydration as unstable_scheduleHydration,
207205
// Disabled behind disableUnstableRenderSubtreeIntoContainer

packages/react-interactions/events/src/dom/__tests__/MixedResponders-test-internal.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -104,76 +104,6 @@ describe('mixing responders with the heritage event system', () => {
104104
document.body.removeChild(newContainer);
105105
});
106106

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-
177107
// @gate experimental
178108
it(
179109
'should only flush before outermost discrete event handler when mixing ' +

packages/react-reconciler/src/ReactFiberHotReloading.new.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
scheduleUpdateOnFiber,
1919
flushPassiveEffects,
2020
} from './ReactFiberWorkLoop.new';
21-
import {updateContainer, syncUpdates} from './ReactFiberReconciler.new';
21+
import {updateContainer} from './ReactFiberReconciler.new';
2222
import {emptyContextObject} from './ReactFiberContext.new';
2323
import {SyncLane} from './ReactFiberLane';
2424
import {
@@ -258,7 +258,7 @@ export const scheduleRoot: ScheduleRoot = (
258258
return;
259259
}
260260
flushPassiveEffects();
261-
syncUpdates(() => {
261+
flushSync(() => {
262262
updateContainer(element, root, null, null);
263263
});
264264
}

packages/react-reconciler/src/ReactFiberHotReloading.old.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
scheduleUpdateOnFiber,
1919
flushPassiveEffects,
2020
} from './ReactFiberWorkLoop.old';
21-
import {updateContainer, syncUpdates} from './ReactFiberReconciler.old';
21+
import {updateContainer} from './ReactFiberReconciler.old';
2222
import {emptyContextObject} from './ReactFiberContext.old';
2323
import {Sync} from './ReactFiberExpirationTime.old';
2424
import {
@@ -258,7 +258,7 @@ export const scheduleRoot: ScheduleRoot = (
258258
return;
259259
}
260260
flushPassiveEffects();
261-
syncUpdates(() => {
261+
flushSync(() => {
262262
updateContainer(element, root, null, null);
263263
});
264264
}

packages/react-reconciler/src/ReactFiberReconciler.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
batchedUpdates as batchedUpdates_old,
2222
unbatchedUpdates as unbatchedUpdates_old,
2323
deferredUpdates as deferredUpdates_old,
24-
syncUpdates as syncUpdates_old,
2524
discreteUpdates as discreteUpdates_old,
2625
flushDiscreteUpdates as flushDiscreteUpdates_old,
2726
flushControlled as flushControlled_old,
@@ -49,7 +48,6 @@ import {
4948
batchedUpdates as batchedUpdates_new,
5049
unbatchedUpdates as unbatchedUpdates_new,
5150
deferredUpdates as deferredUpdates_new,
52-
syncUpdates as syncUpdates_new,
5351
discreteUpdates as discreteUpdates_new,
5452
flushDiscreteUpdates as flushDiscreteUpdates_new,
5553
flushControlled as flushControlled_new,
@@ -88,9 +86,6 @@ export const unbatchedUpdates = enableNewReconciler
8886
export const deferredUpdates = enableNewReconciler
8987
? deferredUpdates_new
9088
: deferredUpdates_old;
91-
export const syncUpdates = enableNewReconciler
92-
? syncUpdates_new
93-
: syncUpdates_old;
9489
export const discreteUpdates = enableNewReconciler
9590
? discreteUpdates_new
9691
: discreteUpdates_old;

packages/react-reconciler/src/ReactFiberReconciler.new.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import {
5656
flushSync,
5757
flushControlled,
5858
deferredUpdates,
59-
syncUpdates,
6059
discreteUpdates,
6160
flushDiscreteUpdates,
6261
flushPassiveEffects,
@@ -306,7 +305,6 @@ export {
306305
batchedUpdates,
307306
unbatchedUpdates,
308307
deferredUpdates,
309-
syncUpdates,
310308
discreteUpdates,
311309
flushDiscreteUpdates,
312310
flushControlled,

packages/react-reconciler/src/ReactFiberReconciler.old.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ import {
5656
flushSync,
5757
flushControlled,
5858
deferredUpdates,
59-
syncUpdates,
6059
discreteUpdates,
6160
flushDiscreteUpdates,
6261
flushPassiveEffects,
@@ -308,7 +307,6 @@ export {
308307
batchedUpdates,
309308
unbatchedUpdates,
310309
deferredUpdates,
311-
syncUpdates,
312310
discreteUpdates,
313311
flushDiscreteUpdates,
314312
flushControlled,

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,6 @@ export function deferredUpdates<A>(fn: () => A): A {
10081008
return runWithPriority(NormalSchedulerPriority, fn);
10091009
}
10101010

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-
10201011
function flushPendingDiscreteUpdates() {
10211012
if (rootsWithPendingDiscreteUpdates !== null) {
10221013
// 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 {
11131104
}
11141105
executionContext |= BatchedContext;
11151106
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+
}
11171112
} finally {
11181113
executionContext = prevExecutionContext;
11191114
// Flush the immediate callbacks that were scheduled during this batch.

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,15 +1065,6 @@ export function deferredUpdates<A>(fn: () => A): A {
10651065
return runWithPriority(NormalPriority, fn);
10661066
}
10671067

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-
10771068
function flushPendingDiscreteUpdates() {
10781069
if (rootsWithPendingDiscreteUpdates !== null) {
10791070
// 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 {
11671158
}
11681159
executionContext |= BatchedContext;
11691160
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+
}
11711166
} finally {
11721167
executionContext = prevExecutionContext;
11731168
// Flush the immediate callbacks that were scheduled during this batch.

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ describe('ReactHooksWithNoopRenderer', () => {
16561656
});
16571657
});
16581658

1659-
it('flushes passive effects when flushing discrete updates', () => {
1659+
it('does not flush non-discrete passive effects when flushing sync', () => {
16601660
let _updateCount;
16611661
function Counter(props) {
16621662
const [count, updateCount] = useState(0);
@@ -1678,28 +1678,28 @@ describe('ReactHooksWithNoopRenderer', () => {
16781678
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
16791679
}).toErrorDev(['An update to Counter ran an effect']);
16801680

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(() => {
16871685
_updateCount(2);
16881686
});
16891687
});
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',
16961696
]);
16971697

1698-
expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
1698+
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
16991699
});
17001700

17011701
// @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)', () => {
17031703
const onInteractionScheduledWorkCompleted = jest.fn();
17041704
const onWorkCanceled = jest.fn();
17051705
SchedulerTracing.unstable_subscribe({
@@ -1744,24 +1744,20 @@ describe('ReactHooksWithNoopRenderer', () => {
17441744

17451745
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);
17461746

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(() => {
17531750
_updateCount(2);
17541751
});
17551752
});
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',
17621758
]);
17631759

1764-
expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
1760+
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
17651761

17661762
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
17671763
expect(onWorkCanceled).toHaveBeenCalledTimes(0);

0 commit comments

Comments
 (0)