GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "Fix: flushSync changes priority inside effect (#21122)" · react/react@e7e0a90

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-reconciler/src
    • ReactFiberWorkLoop.new.js
    • ReactFiberWorkLoop.old.js
    • __tests__
      • ReactFlushSync-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,16 @@ export function unbatchedUpdates<A, R>(fn: (a: A) => R, a: A): R {
11421142

11431143
export function flushSync<A, R>(fn: A => R, a: A): R {
11441144
const prevExecutionContext = executionContext;
1145+
if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
1146+
if (__DEV__) {
1147+
console.error(
1148+
'flushSync was called from inside a lifecycle method. React cannot ' +
1149+
'flush when React is already rendering. Consider moving this call to ' +
1150+
'a scheduler task or micro task.',
1151+
);
1152+
}
1153+
return fn(a);
1154+
}
11451155
executionContext |= BatchedContext;
11461156

11471157
const previousPriority = getCurrentUpdatePriority();
@@ -1158,17 +1168,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
11581168
// Flush the immediate callbacks that were scheduled during this batch.
11591169
// Note that this will happen even if batchedUpdates is higher up
11601170
// the stack.
1161-
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
1162-
flushSyncCallbacks();
1163-
} else {
1164-
if (__DEV__) {
1165-
console.error(
1166-
'flushSync was called from inside a lifecycle method. React cannot ' +
1167-
'flush when React is already rendering. Consider moving this call to ' +
1168-
'a scheduler task or micro task.',
1169-
);
1170-
}
1171-
}
1171+
flushSyncCallbacks();
11721172
}
11731173
}
11741174

Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,16 @@ export function unbatchedUpdates<A, R>(fn: (a: A) => R, a: A): R {
11421142

11431143
export function flushSync<A, R>(fn: A => R, a: A): R {
11441144
const prevExecutionContext = executionContext;
1145+
if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
1146+
if (__DEV__) {
1147+
console.error(
1148+
'flushSync was called from inside a lifecycle method. React cannot ' +
1149+
'flush when React is already rendering. Consider moving this call to ' +
1150+
'a scheduler task or micro task.',
1151+
);
1152+
}
1153+
return fn(a);
1154+
}
11451155
executionContext |= BatchedContext;
11461156

11471157
const previousPriority = getCurrentUpdatePriority();
@@ -1158,17 +1168,7 @@ export function flushSync<A, R>(fn: A => R, a: A): R {
11581168
// Flush the immediate callbacks that were scheduled during this batch.
11591169
// Note that this will happen even if batchedUpdates is higher up
11601170
// the stack.
1161-
if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
1162-
flushSyncCallbacks();
1163-
} else {
1164-
if (__DEV__) {
1165-
console.error(
1166-
'flushSync was called from inside a lifecycle method. React cannot ' +
1167-
'flush when React is already rendering. Consider moving this call to ' +
1168-
'a scheduler task or micro task.',
1169-
);
1170-
}
1171-
}
1171+
flushSyncCallbacks();
11721172
}
11731173
}
11741174

Collapse file

‎packages/react-reconciler/src/__tests__/ReactFlushSync-test.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/ReactFlushSync-test.js
-64Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.