[react-interactions] Move Flare event registration to commit phase (#17518)
Dominic Gannaway committed
Dec 4, 2019 at 02:08 UTC
6d105ad3f6814e6d44e8141d9524097f166b5ae9
2 files changed
+5
-19
packages/react-reconciler/src/ReactFiberCommitWork.js
+2
-2
@@ -1352,7 +1352,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1352
if (enableFlareAPI) {
1353
const prevListeners = oldProps.DEPRECATED_flareListeners;
1354
const nextListeners = newProps.DEPRECATED_flareListeners;
1355
- if (prevListeners !== nextListeners) {
1355
+ if (prevListeners !== nextListeners || current === null) {
1356
updateLegacyEventListeners(nextListeners, finishedWork, null);
1357
}
1358
}
@@ -1417,7 +1417,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
1417
const oldProps = current !== null ? current.memoizedProps : newProps;
1418
const prevListeners = oldProps.DEPRECATED_flareListeners;
1419
const nextListeners = newProps.DEPRECATED_flareListeners;
1420
- if (prevListeners !== nextListeners) {
1420
+ if (prevListeners !== nextListeners || current === null) {
1421
updateLegacyEventListeners(nextListeners, finishedWork, null);
1422
}
1423
}
packages/react-reconciler/src/ReactFiberCompleteWork.js
+3
-17
@@ -128,7 +128,6 @@ import {
128
import {createFundamentalStateInstance} from './ReactFiberFundamental';
129
import {Never} from './ReactFiberExpirationTime';
130
import {resetChildFibers} from './ReactChildFiber';
131
-import {updateLegacyEventListeners} from './ReactFiberEvents';
131
import {createScopeMethods} from './ReactFiberScope';
132
133
function markUpdate(workInProgress: Fiber) {
@@ -730,11 +729,7 @@ function completeWork(
729
if (enableFlareAPI) {
730
const listeners = newProps.DEPRECATED_flareListeners;
731
if (listeners != null) {
733
- updateLegacyEventListeners(
734
- listeners,
735
- workInProgress,
736
- rootContainerInstance,
737
- );
732
+ markUpdate(workInProgress);
733
}
734
}
735
} else {
@@ -754,11 +749,7 @@ function completeWork(
749
if (enableFlareAPI) {
750
const listeners = newProps.DEPRECATED_flareListeners;
751
if (listeners != null) {
757
- updateLegacyEventListeners(
758
- listeners,
759
- workInProgress,
760
- rootContainerInstance,
761
- );
752
+ markUpdate(workInProgress);
753
}
754
}
755
@@ -1264,12 +1255,7 @@ function completeWork(
1255
if (enableFlareAPI) {
1256
const listeners = newProps.DEPRECATED_flareListeners;
1257
if (listeners != null) {
1267
- const rootContainerInstance = getRootHostContainer();
1268
- updateLegacyEventListeners(
1269
- listeners,
1270
- workInProgress,
1271
- rootContainerInstance,
1272
- );
1258
+ markUpdate(workInProgress);
1259
}
1260
}
1261
if (workInProgress.ref !== null) {