GeezerVison is showing github.com — Enable eager listeners in open source (#19716) · react/react@b754caa
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMFiber-test.js +13-5Lines changed: 13 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1097,6 +1097,8 @@ describe('ReactDOMFiber', () => { | 1097 | 1097 | }); | 1098 | 1098 |
| 1099 | 1099 | it('should not update event handlers until commit', () => { | | 1100 | + spyOnDev(console, 'error'); | | 1101 | + | 1100 | 1102 | let ops = []; | 1101 | 1103 | const handlerA = () => ops.push('A'); | 1102 | 1104 | const handlerB = () => ops.push('B'); | @@ -1129,11 +1131,7 @@ describe('ReactDOMFiber', () => { | 1129 | 1131 | class Click extends React.Component { | 1130 | 1132 | constructor() { | 1131 | 1133 | super(); | 1132 | | - expect(() => { | 1133 | | - node.click(); | 1134 | | - }).toErrorDev( | 1135 | | - 'Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.', | 1136 | | - ); | | 1134 | + node.click(); | 1137 | 1135 | } | 1138 | 1136 | render() { | 1139 | 1137 | return null; | @@ -1183,6 +1181,16 @@ describe('ReactDOMFiber', () => { | 1183 | 1181 | // Any click that happens after commit, should invoke A. | 1184 | 1182 | click(); | 1185 | 1183 | expect(ops).toEqual(['A']); | | 1184 | + | | 1185 | + if (__DEV__) { | | 1186 | + // TODO: this warning shouldn't be firing in the first place if user didn't call it. | | 1187 | + const errorCalls = console.error.calls.count(); | | 1188 | + for (let i = 0; i < errorCalls; i++) { | | 1189 | + expect(console.error.calls.argsFor(i)[0]).toMatch( | | 1190 | + 'unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.', | | 1191 | + ); | | 1192 | + } | | 1193 | + } | 1186 | 1194 | }); | 1187 | 1195 |
| 1188 | 1196 | it('should not crash encountering low-priority tree', () => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/ReactFeatureFlags.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -137,4 +137,4 @@ export const enableDiscreteEventFlushingChange = false; | 137 | 137 | export const enablePassiveEventIntervention = true; | 138 | 138 | export const disableOnScrollBubbling = true; | 139 | 139 |
| 140 | | -export const enableEagerRootListeners = false; | | 140 | +export const enableEagerRootListeners = true; |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-fb.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 51 | 51 | export const decoupleUpdatePriorityFromScheduler = false; | 52 | 52 | export const enableDiscreteEventFlushingChange = false; | 53 | 53 | export const enablePassiveEventIntervention = true; | 54 | | -export const enableEagerRootListeners = false; | | 54 | +export const enableEagerRootListeners = true; | 55 | 55 |
| 56 | 56 | // Flow magic to verify the exports of this file match the original version. | 57 | 57 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-oss.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 50 | 50 | export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = false; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | | -export const enableEagerRootListeners = false; | | 53 | +export const enableEagerRootListeners = true; | 54 | 54 |
| 55 | 55 | // Flow magic to verify the exports of this file match the original version. | 56 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 50 | 50 | export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = false; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | | -export const enableEagerRootListeners = false; | | 53 | +export const enableEagerRootListeners = true; | 54 | 54 |
| 55 | 55 | // Flow magic to verify the exports of this file match the original version. | 56 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 49 | 49 | export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | | -export const enableEagerRootListeners = false; | | 52 | +export const enableEagerRootListeners = true; | 53 | 53 |
| 54 | 54 | // Flow magic to verify the exports of this file match the original version. | 55 | 55 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 50 | 50 | export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = false; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | | -export const enableEagerRootListeners = false; | | 53 | +export const enableEagerRootListeners = true; | 54 | 54 |
| 55 | 55 | // Flow magic to verify the exports of this file match the original version. | 56 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.testing.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 50 | 50 | export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = false; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | | -export const enableEagerRootListeners = false; | | 53 | +export const enableEagerRootListeners = true; | 54 | 54 |
| 55 | 55 | // Flow magic to verify the exports of this file match the original version. | 56 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.testing.www.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true; | 50 | 50 | export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = true; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | | -export const enableEagerRootListeners = false; | | 53 | +export const enableEagerRootListeners = true; | 54 | 54 |
| 55 | 55 | // Flow magic to verify the exports of this file match the original version. | 56 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.www-dynamic.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,7 @@ export const decoupleUpdatePriorityFromScheduler = __VARIANT__; | 21 | 21 | export const skipUnmountedBoundaries = __VARIANT__; | 22 | 22 | export const enablePassiveEventIntervention = __VARIANT__; | 23 | 23 | export const disableOnScrollBubbling = __VARIANT__; | 24 | | -export const enableEagerRootListeners = __VARIANT__; | | 24 | +export const enableEagerRootListeners = !__VARIANT__; | 25 | 25 |
| 26 | 26 | // Enable this flag to help with concurrent mode debugging. | 27 | 27 | // It logs information to the console about React scheduling, rendering, and commit phases. | |
|