Skip to content

Commit d8b903f

Browse files
authored
[Fiber] Avoid return value from commitBeforeMutationEffects (facebook#31922)
This is behind an unusual flag (enableCreateEventHandleAPI) that doesn't serve a special return value. I'll be collecting other flags from this phase too. We can just use the global flag and reset it before the next mutation phase. Unlike focusedInstanceHandle this doesn't leak any memory in the meantime.
1 parent 6ca7fbe commit d8b903f

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,23 +236,20 @@ let inProgressLanes: Lanes | null = null;
236236
let inProgressRoot: FiberRoot | null = null;
237237

238238
let focusedInstanceHandle: null | Fiber = null;
239-
let shouldFireAfterActiveInstanceBlur: boolean = false;
239+
export let shouldFireAfterActiveInstanceBlur: boolean = false;
240240

241241
export function commitBeforeMutationEffects(
242242
root: FiberRoot,
243243
firstChild: Fiber,
244-
): boolean {
244+
): void {
245245
focusedInstanceHandle = prepareForCommit(root.containerInfo);
246+
shouldFireAfterActiveInstanceBlur = false;
246247

247248
nextEffect = firstChild;
248249
commitBeforeMutationEffects_begin();
249250

250251
// We no longer need to track the active instance fiber
251-
const shouldFire = shouldFireAfterActiveInstanceBlur;
252-
shouldFireAfterActiveInstanceBlur = false;
253252
focusedInstanceHandle = null;
254-
255-
return shouldFire;
256253
}
257254

258255
function commitBeforeMutationEffects_begin() {

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ import {
198198
} from './ReactFiberThrow';
199199
import {
200200
commitBeforeMutationEffects,
201+
shouldFireAfterActiveInstanceBlur,
201202
commitLayoutEffects,
202203
commitMutationEffects,
203204
commitPassiveMountEffects,
@@ -3384,10 +3385,7 @@ function commitRootImpl(
33843385
// The first phase a "before mutation" phase. We use this phase to read the
33853386
// state of the host tree right before we mutate it. This is where
33863387
// getSnapshotBeforeUpdate is called.
3387-
const shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects(
3388-
root,
3389-
finishedWork,
3390-
);
3388+
commitBeforeMutationEffects(root, finishedWork);
33913389

33923390
// The next phase is the mutation phase, where we mutate the host tree.
33933391
commitMutationEffects(root, finishedWork, lanes);

0 commit comments

Comments
 (0)