Skip to content

Commit

Permalink
[react-interactions] Move Flare event registration to commit phase (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Dec 4, 2019
1 parent 5bb7348 commit 61f9d01
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 @@ -1360,7 +1360,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 @@ -1432,7 +1432,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 @@ -129,7 +129,6 @@ import {
import {createFundamentalStateInstance} from './ReactFiberFundamental';
import {Never} from './ReactFiberExpirationTime';
import {resetChildFibers} from './ReactChildFiber';
import {updateLegacyEventListeners} from './ReactFiberDeprecatedFlareEvents';
import {createScopeMethods} from './ReactFiberScope';
import {reconcileListeners} from './ReactFiberListenerEvents';

Expand Down Expand Up @@ -739,11 +738,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}
if (enableListenerAPI) {
Expand Down Expand Up @@ -773,11 +768,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}
if (enableListenerAPI) {
Expand Down Expand Up @@ -1293,12 +1284,7 @@ function completeWork(
if (enableFlareAPI) {
const listeners = newProps.DEPRECATED_flareListeners;
if (listeners != null) {
const rootContainerInstance = getRootHostContainer();
updateLegacyEventListeners(
listeners,
workInProgress,
rootContainerInstance,
);
markUpdate(workInProgress);
}
}
if (enableListenerAPI) {
Expand Down

0 comments on commit 61f9d01

Please sign in to comment.