Skip to content

Commit 34d6e25

Browse files
committed
Noop unstable_batchedUpdates
1 parent c98cac9 commit 34d6e25

File tree

7 files changed

+34
-6
lines changed

7 files changed

+34
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export {
2727
hydrate,
2828
render,
2929
unmountComponentAtNode,
30-
unstable_batchedUpdates,
3130
unstable_createEventHandle,
3231
unstable_renderSubtreeIntoContainer,
3332
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
@@ -42,4 +41,6 @@ export {
4241
version,
4342
} from './src/client/ReactDOM';
4443

44+
export {unstable_batchedUpdates} from './src/client/ReactDOMLegacy';
45+
4546
export {Internals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export {
1313
createRoot,
1414
hydrateRoot,
1515
flushSync,
16-
unstable_batchedUpdates,
1716
unstable_createEventHandle,
1817
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
1918
useFormStatus,
@@ -26,3 +25,5 @@ export {
2625
preinitModule,
2726
version,
2827
} from './src/client/ReactDOM';
28+
29+
export {unstable_batchedUpdates} from './src/client/ReactDOMLegacy';

packages/react-dom/src/ReactDOMSharedInternals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {HostDispatcher} from './shared/ReactDOMTypes';
1111

1212
type InternalsType = {
1313
usingClientEntryPoint: boolean,
14-
Events: [any, any, any, any, any, any],
14+
Events: [any, any, any, any, any],
1515
Dispatcher: {
1616
current: null | HostDispatcher,
1717
},

packages/react-dom/src/__tests__/ReactLegacyMount-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ describe('ReactMount', () => {
277277
expect(calls).toBe(5);
278278
});
279279

280+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
281+
// @gate www && !experimental
280282
it('initial mount of legacy root is sync inside batchedUpdates, as if it were wrapped in flushSync', () => {
281283
const container1 = document.createElement('div');
282284
const container2 = document.createElement('div');
@@ -295,6 +297,7 @@ describe('ReactMount', () => {
295297

296298
ReactDOM.render(<div>1</div>, container1);
297299

300+
console.log(ReactDOM.unstable_batchedUpdates.toString());
298301
ReactDOM.unstable_batchedUpdates(() => {
299302
// Update. Does not flush yet.
300303
ReactDOM.render(<div>2</div>, container1);

packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ describe('ReactLegacyUpdates', () => {
3131
assertLog = InternalTestUtils.assertLog;
3232
});
3333

34+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
35+
// @gate www && !experimental
3436
it('should batch state when updating state twice', () => {
3537
let updateCount = 0;
3638

@@ -60,6 +62,8 @@ describe('ReactLegacyUpdates', () => {
6062
expect(updateCount).toBe(1);
6163
});
6264

65+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
66+
// @gate www && !experimental
6367
it('should batch state when updating two different state keys', () => {
6468
let updateCount = 0;
6569

@@ -92,6 +96,8 @@ describe('ReactLegacyUpdates', () => {
9296
expect(updateCount).toBe(1);
9397
});
9498

99+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
100+
// @gate www && !experimental
95101
it('should batch state and props together', () => {
96102
let updateCount = 0;
97103

@@ -125,6 +131,8 @@ describe('ReactLegacyUpdates', () => {
125131
expect(updateCount).toBe(1);
126132
});
127133

134+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
135+
// @gate www && !experimental
128136
it('should batch parent/child state updates together', () => {
129137
let parentUpdateCount = 0;
130138

@@ -179,6 +187,8 @@ describe('ReactLegacyUpdates', () => {
179187
expect(childUpdateCount).toBe(1);
180188
});
181189

190+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
191+
// @gate www && !experimental
182192
it('should batch child/parent state updates together', () => {
183193
let parentUpdateCount = 0;
184194

@@ -235,6 +245,8 @@ describe('ReactLegacyUpdates', () => {
235245
expect(childUpdateCount).toBe(1);
236246
});
237247

248+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
249+
// @gate www && !experimental
238250
it('should support chained state updates', () => {
239251
let updateCount = 0;
240252

@@ -274,6 +286,8 @@ describe('ReactLegacyUpdates', () => {
274286
expect(updateCount).toBe(2);
275287
});
276288

289+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
290+
// @gate www && !experimental
277291
it('should batch forceUpdate together', () => {
278292
let shouldUpdateCount = 0;
279293
let updateCount = 0;
@@ -530,6 +544,8 @@ describe('ReactLegacyUpdates', () => {
530544
);
531545
});
532546

547+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
548+
// @gate www && !experimental
533549
it('should queue mount-ready handlers across different roots', () => {
534550
// We'll define two components A and B, then update both of them. When A's
535551
// componentDidUpdate handlers is called, B's DOM should already have been
@@ -817,6 +833,8 @@ describe('ReactLegacyUpdates', () => {
817833
expect(callbackCount).toBe(1);
818834
});
819835

836+
// TODO: www-modern doesn't use the correct entry points in tests (#21505)
837+
// @gate www && !experimental
820838
it('does not call render after a component as been deleted', () => {
821839
let renderCount = 0;
822840
let componentB = null;

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
import {createEventHandle} from 'react-dom-bindings/src/client/ReactDOMEventHandle';
3434

3535
import {
36-
batchedUpdates,
3736
flushSync as flushSyncWithoutWarningIfAlreadyRendering,
3837
isAlreadyRendering,
3938
injectIntoDevTools,
@@ -165,9 +164,13 @@ function flushSync<R>(fn: (() => R) | void): R | void {
165164
return flushSyncWithoutWarningIfAlreadyRendering(fn);
166165
}
167166

167+
function unstable_batchedUpdates<A, R>(fn: (a: A) => R, a: A): R {
168+
return fn(a);
169+
}
170+
168171
export {
169172
createPortal,
170-
batchedUpdates as unstable_batchedUpdates,
173+
unstable_batchedUpdates,
171174
flushSync,
172175
ReactVersion as version,
173176
// Disabled behind disableLegacyReactDOMAPIs
@@ -195,7 +198,6 @@ Internals.Events = [
195198
getFiberCurrentPropsFromNode,
196199
enqueueStateRestore,
197200
restoreStateIfNeeded,
198-
batchedUpdates,
199201
];
200202

201203
const foundDevTools = injectIntoDevTools({

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
} from 'react-dom-bindings/src/client/HTMLNodeType';
3131

3232
import {
33+
batchedUpdates,
3334
createContainer,
3435
createHydrationContainer,
3536
findHostInstanceWithNoPortals,
@@ -442,3 +443,5 @@ export function unmountComponentAtNode(container: Container): boolean {
442443
return false;
443444
}
444445
}
446+
447+
export {batchedUpdates as unstable_batchedUpdates};

0 commit comments

Comments
 (0)