Skip to content

Commit 3ea4972

Browse files
committed
Avoid return value from commitBeforeMutationEffects
This is an unusual flag that doesn't serve a special return value. 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 97d7949 commit 3ea4972

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

packages/react-reconciler/src/ReactFiberCommitWork.js

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

234234
let focusedInstanceHandle: null | Fiber = null;
235-
let shouldFireAfterActiveInstanceBlur: boolean = false;
235+
export let shouldFireAfterActiveInstanceBlur: boolean = false;
236236

237237
export function commitBeforeMutationEffects(
238238
root: FiberRoot,
239239
firstChild: Fiber,
240-
): boolean {
240+
): void {
241241
focusedInstanceHandle = prepareForCommit(root.containerInfo);
242+
shouldFireAfterActiveInstanceBlur = false;
242243

243244
nextEffect = firstChild;
244245
commitBeforeMutationEffects_begin();
245246

246247
// We no longer need to track the active instance fiber
247-
const shouldFire = shouldFireAfterActiveInstanceBlur;
248-
shouldFireAfterActiveInstanceBlur = false;
249248
focusedInstanceHandle = null;
250-
251-
return shouldFire;
252249
}
253250

254251
function commitBeforeMutationEffects_begin() {

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ import {
197197
} from './ReactFiberThrow';
198198
import {
199199
commitBeforeMutationEffects,
200+
shouldFireAfterActiveInstanceBlur,
200201
commitLayoutEffects,
201202
commitMutationEffects,
202203
commitPassiveMountEffects,
@@ -3361,10 +3362,7 @@ function commitRootImpl(
33613362
// The first phase a "before mutation" phase. We use this phase to read the
33623363
// state of the host tree right before we mutate it. This is where
33633364
// getSnapshotBeforeUpdate is called.
3364-
const shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects(
3365-
root,
3366-
finishedWork,
3367-
);
3365+
commitBeforeMutationEffects(root, finishedWork);
33683366

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

0 commit comments

Comments
 (0)