Enable eager listeners in open source (#19716)
* Enable eager listeners in open source * Fix tests * Enable in all places
Dan Abramov committed
Aug 28, 2020 at 12:23 UTC
b754caaaf23a070de281dcd0a9d32846470e1907
10 files changed
+22
-14
packages/react-dom/src/__tests__/ReactDOMFiber-test.js
+13
-5
@@ -1097,6 +1097,8 @@ describe('ReactDOMFiber', () => {
1097
});
1098
1099
it('should not update event handlers until commit', () => {
1100
+ spyOnDev(console, 'error');
1101
+
1102
let ops = [];
1103
const handlerA = () => ops.push('A');
1104
const handlerB = () => ops.push('B');
@@ -1129,11 +1131,7 @@ describe('ReactDOMFiber', () => {
1131
class Click extends React.Component {
1132
constructor() {
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();
1135
}
1136
render() {
1137
return null;
@@ -1183,6 +1181,16 @@ describe('ReactDOMFiber', () => {
1181
// Any click that happens after commit, should invoke A.
1182
click();
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
+ }
1194
});
1195
1196
it('should not crash encountering low-priority tree', () => {
packages/shared/ReactFeatureFlags.js
+1
-1
@@ -137,4 +137,4 @@ export const enableDiscreteEventFlushingChange = false;
137
export const enablePassiveEventIntervention = true;
138
export const disableOnScrollBubbling = true;
139
140
-export const enableEagerRootListeners = false;
140
+export const enableEagerRootListeners = true;
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
-1
@@ -51,7 +51,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
51
export const decoupleUpdatePriorityFromScheduler = false;
52
export const enableDiscreteEventFlushingChange = false;
53
export const enablePassiveEventIntervention = true;
54
-export const enableEagerRootListeners = false;
54
+export const enableEagerRootListeners = true;
55
56
// Flow magic to verify the exports of this file match the original version.
57
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1
-1
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
50
export const decoupleUpdatePriorityFromScheduler = false;
51
export const enableDiscreteEventFlushingChange = false;
52
export const enablePassiveEventIntervention = true;
53
-export const enableEagerRootListeners = false;
53
+export const enableEagerRootListeners = true;
54
55
// Flow magic to verify the exports of this file match the original version.
56
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1
-1
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
50
export const decoupleUpdatePriorityFromScheduler = false;
51
export const enableDiscreteEventFlushingChange = false;
52
export const enablePassiveEventIntervention = true;
53
-export const enableEagerRootListeners = false;
53
+export const enableEagerRootListeners = true;
54
55
// Flow magic to verify the exports of this file match the original version.
56
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
+1
-1
@@ -49,7 +49,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
49
export const decoupleUpdatePriorityFromScheduler = false;
50
export const enableDiscreteEventFlushingChange = false;
51
export const enablePassiveEventIntervention = true;
52
-export const enableEagerRootListeners = false;
52
+export const enableEagerRootListeners = true;
53
54
// Flow magic to verify the exports of this file match the original version.
55
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
-1
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
50
export const decoupleUpdatePriorityFromScheduler = false;
51
export const enableDiscreteEventFlushingChange = false;
52
export const enablePassiveEventIntervention = true;
53
-export const enableEagerRootListeners = false;
53
+export const enableEagerRootListeners = true;
54
55
// Flow magic to verify the exports of this file match the original version.
56
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.testing.js
+1
-1
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
50
export const decoupleUpdatePriorityFromScheduler = false;
51
export const enableDiscreteEventFlushingChange = false;
52
export const enablePassiveEventIntervention = true;
53
-export const enableEagerRootListeners = false;
53
+export const enableEagerRootListeners = true;
54
55
// Flow magic to verify the exports of this file match the original version.
56
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.testing.www.js
+1
-1
@@ -50,7 +50,7 @@ export const deferRenderPhaseUpdateToNextBatch = true;
50
export const decoupleUpdatePriorityFromScheduler = false;
51
export const enableDiscreteEventFlushingChange = true;
52
export const enablePassiveEventIntervention = true;
53
-export const enableEagerRootListeners = false;
53
+export const enableEagerRootListeners = true;
54
55
// Flow magic to verify the exports of this file match the original version.
56
// eslint-disable-next-line no-unused-vars
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
+1
-1
@@ -21,7 +21,7 @@ export const decoupleUpdatePriorityFromScheduler = __VARIANT__;
21
export const skipUnmountedBoundaries = __VARIANT__;
22
export const enablePassiveEventIntervention = __VARIANT__;
23
export const disableOnScrollBubbling = __VARIANT__;
24
-export const enableEagerRootListeners = __VARIANT__;
24
+export const enableEagerRootListeners = !__VARIANT__;
25
26
// Enable this flag to help with concurrent mode debugging.
27
// It logs information to the console about React scheduling, rendering, and commit phases.