Skip to content

Commit

Permalink
[react-interactions] Move Flare event registration to commit phase (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Dec 4, 2019
1 parent dc18b8b commit 6d105ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
if (enableFlareAPI) {
const prevListeners = oldProps.DEPRECATED_flareListeners;
const nextListeners = newProps.DEPRECATED_flareListeners;
if (prevListeners !== nextListeners) {
if (prevListeners !== nextListeners || current === null) {
updateLegacyEventListeners(nextListeners, finishedWork, null);
}
}
Expand Down Expand Up @@ -1417,7 +1417,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
const oldProps = current !== null ? current.memoizedProps : newProps;
const prevListeners = oldProps.DEPRECATED_flareListeners;
const nextListeners = newProps.DEPRECATED_flareListeners;
if (prevListeners !== nextListeners) {
if (prevListeners !== nextListeners || current === null) {
updateLegacyEventListeners(nextListeners, finishedWork, null);
}
}
Expand Down
20 changes: 3 additions & 17 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ import {
import {createFundamentalStateInstance} from './ReactFiberFundamental';
import {Never} from './ReactFiberExpirationTime';
import {resetChildFibers} from './ReactChildFiber';
import {updateLegacyEventListeners} from './ReactFiberEvents';
import {createScopeMethods} from './ReactFiberScope';

function markUpdate(workInProgress: Fiber) {
Expand Down Expand Up @@ -730,11 +729,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}
} else {
Expand All @@ -754,11 +749,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}

Expand Down Expand Up @@ -1264,12 +1255,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
const rootContainerInstance = getRootHostContainer();
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}
if (workInProgress.ref !== null) {
Expand Down

0 comments on commit 6d105ad

Please sign in to comment.