Skip to content

Commit 6d105ad

Browse files
authored
[react-interactions] Move Flare event registration to commit phase (facebook#17518)
1 parent dc18b8b commit 6d105ad

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
13521352
if (enableFlareAPI) {
13531353
const prevListeners = oldProps.DEPRECATED_flareListeners;
13541354
const nextListeners = newProps.DEPRECATED_flareListeners;
1355-
if (prevListeners !== nextListeners) {
1355+
if (prevListeners !== nextListeners || current === null) {
13561356
updateLegacyEventListeners(nextListeners, finishedWork, null);
13571357
}
13581358
}
@@ -1417,7 +1417,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
14171417
const oldProps = current !== null ? current.memoizedProps : newProps;
14181418
const prevListeners = oldProps.DEPRECATED_flareListeners;
14191419
const nextListeners = newProps.DEPRECATED_flareListeners;
1420-
if (prevListeners !== nextListeners) {
1420+
if (prevListeners !== nextListeners || current === null) {
14211421
updateLegacyEventListeners(nextListeners, finishedWork, null);
14221422
}
14231423
}

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ import {
128128
import {createFundamentalStateInstance} from './ReactFiberFundamental';
129129
import {Never} from './ReactFiberExpirationTime';
130130
import {resetChildFibers} from './ReactChildFiber';
131-
import {updateLegacyEventListeners} from './ReactFiberEvents';
132131
import {createScopeMethods} from './ReactFiberScope';
133132

134133
function markUpdate(workInProgress: Fiber) {
@@ -730,11 +729,7 @@ function completeWork(
730729
if (enableFlareAPI) {
731730
const listeners = newProps.DEPRECATED_flareListeners;
732731
if (listeners != null) {
733-
updateLegacyEventListeners(
734-
listeners,
735-
workInProgress,
736-
rootContainerInstance,
737-
);
732+
markUpdate(workInProgress);
738733
}
739734
}
740735
} else {
@@ -754,11 +749,7 @@ function completeWork(
754749
if (enableFlareAPI) {
755750
const listeners = newProps.DEPRECATED_flareListeners;
756751
if (listeners != null) {
757-
updateLegacyEventListeners(
758-
listeners,
759-
workInProgress,
760-
rootContainerInstance,
761-
);
752+
markUpdate(workInProgress);
762753
}
763754
}
764755

@@ -1264,12 +1255,7 @@ function completeWork(
12641255
if (enableFlareAPI) {
12651256
const listeners = newProps.DEPRECATED_flareListeners;
12661257
if (listeners != null) {
1267-
const rootContainerInstance = getRootHostContainer();
1268-
updateLegacyEventListeners(
1269-
listeners,
1270-
workInProgress,
1271-
rootContainerInstance,
1272-
);
1258+
markUpdate(workInProgress);
12731259
}
12741260
}
12751261
if (workInProgress.ref !== null) {

0 commit comments

Comments
 (0)