Skip to content

Commit a3656d7

Browse files
committed
Invert so the one with the warning is the default one
To make Seb happy
1 parent 67e8bc8 commit a3656d7

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
batchedUpdates,
2525
discreteUpdates,
2626
flushSync,
27-
flushSyncWithWarningIfAlreadyRendering,
27+
flushSyncWithoutWarningIfAlreadyRendering,
2828
flushControlled,
2929
injectIntoDevTools,
3030
attemptSynchronousHydration,
@@ -97,7 +97,11 @@ if (__DEV__) {
9797
}
9898

9999
setRestoreImplementation(restoreControlledState);
100-
setBatchingImplementation(batchedUpdates, discreteUpdates, flushSync);
100+
setBatchingImplementation(
101+
batchedUpdates,
102+
discreteUpdates,
103+
flushSyncWithoutWarningIfAlreadyRendering,
104+
);
101105

102106
function createPortal(
103107
children: ReactNodeList,
@@ -162,7 +166,7 @@ const Internals = {
162166
export {
163167
createPortal,
164168
batchedUpdates as unstable_batchedUpdates,
165-
flushSyncWithWarningIfAlreadyRendering as flushSync,
169+
flushSync,
166170
Internals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
167171
ReactVersion as version,
168172
// Disabled behind disableLegacyReactDOMAPIs

packages/react-noop-renderer/src/createReactNoop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
916916
},
917917

918918
flushSync(fn: () => mixed) {
919-
NoopRenderer.flushSyncWithWarningIfAlreadyRendering(fn);
919+
NoopRenderer.flushSync(fn);
920920
},
921921

922922
flushPassiveEffects: NoopRenderer.flushPassiveEffects,

packages/react-reconciler/src/ReactFiberReconciler.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
discreteUpdates as discreteUpdates_old,
2424
flushControlled as flushControlled_old,
2525
flushSync as flushSync_old,
26-
flushSyncWithWarningIfAlreadyRendering as flushSyncWithWarningIfAlreadyRendering_old,
26+
flushSyncWithoutWarningIfAlreadyRendering as flushSyncWithoutWarningIfAlreadyRendering_old,
2727
flushPassiveEffects as flushPassiveEffects_old,
2828
getPublicRootInstance as getPublicRootInstance_old,
2929
attemptSynchronousHydration as attemptSynchronousHydration_old,
@@ -61,7 +61,7 @@ import {
6161
discreteUpdates as discreteUpdates_new,
6262
flushControlled as flushControlled_new,
6363
flushSync as flushSync_new,
64-
flushSyncWithWarningIfAlreadyRendering as flushSyncWithWarningIfAlreadyRendering_new,
64+
flushSyncWithoutWarningIfAlreadyRendering as flushSyncWithoutWarningIfAlreadyRendering_new,
6565
flushPassiveEffects as flushPassiveEffects_new,
6666
getPublicRootInstance as getPublicRootInstance_new,
6767
attemptSynchronousHydration as attemptSynchronousHydration_new,
@@ -112,9 +112,9 @@ export const flushControlled = enableNewReconciler
112112
? flushControlled_new
113113
: flushControlled_old;
114114
export const flushSync = enableNewReconciler ? flushSync_new : flushSync_old;
115-
export const flushSyncWithWarningIfAlreadyRendering = enableNewReconciler
116-
? flushSyncWithWarningIfAlreadyRendering_new
117-
: flushSyncWithWarningIfAlreadyRendering_old;
115+
export const flushSyncWithoutWarningIfAlreadyRendering = enableNewReconciler
116+
? flushSyncWithoutWarningIfAlreadyRendering_new
117+
: flushSyncWithoutWarningIfAlreadyRendering_old;
118118
export const flushPassiveEffects = enableNewReconciler
119119
? flushPassiveEffects_new
120120
: flushPassiveEffects_old;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
flushControlled,
5858
deferredUpdates,
5959
discreteUpdates,
60-
flushSyncWithWarningIfAlreadyRendering,
60+
flushSyncWithoutWarningIfAlreadyRendering,
6161
flushPassiveEffects,
6262
} from './ReactFiberWorkLoop.new';
6363
import {
@@ -332,7 +332,7 @@ export {
332332
discreteUpdates,
333333
flushControlled,
334334
flushSync,
335-
flushSyncWithWarningIfAlreadyRendering,
335+
flushSyncWithoutWarningIfAlreadyRendering,
336336
flushPassiveEffects,
337337
};
338338

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,10 @@ export function unbatchedUpdates<A, R>(fn: (a: A) => R, a: A): R {
11141114
}
11151115
}
11161116

1117-
export function flushSync<A, R>(fn: A => R, a: A): R {
1117+
export function flushSyncWithoutWarningIfAlreadyRendering<A, R>(
1118+
fn: A => R,
1119+
a: A,
1120+
): R {
11181121
const prevExecutionContext = executionContext;
11191122
executionContext |= BatchedContext;
11201123

@@ -1141,10 +1144,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
11411144
}
11421145
}
11431146

1144-
export function flushSyncWithWarningIfAlreadyRendering<A, R>(
1145-
fn: A => R,
1146-
a: A,
1147-
): R {
1147+
export function flushSync<A, R>(fn: A => R, a: A): R {
11481148
if (__DEV__) {
11491149
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
11501150
console.error(
@@ -1154,7 +1154,7 @@ export function flushSyncWithWarningIfAlreadyRendering<A, R>(
11541154
);
11551155
}
11561156
}
1157-
return flushSync(fn, a);
1157+
return flushSyncWithoutWarningIfAlreadyRendering(fn, a);
11581158
}
11591159

11601160
export function flushControlled(fn: () => mixed): void {

packages/react-test-renderer/src/ReactTestRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
getPublicRootInstance,
1919
createContainer,
2020
updateContainer,
21-
flushSyncWithWarningIfAlreadyRendering,
21+
flushSync,
2222
injectIntoDevTools,
2323
batchedUpdates,
2424
} from 'react-reconciler/src/ReactFiberReconciler';
@@ -543,7 +543,7 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
543543
},
544544

545545
unstable_flushSync<T>(fn: () => T): T {
546-
return flushSyncWithWarningIfAlreadyRendering(fn);
546+
return flushSync(fn);
547547
},
548548
};
549549

0 commit comments

Comments
 (0)