[Fiber] Avoid return value from commitBeforeMutationEffects (#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.
This commit is contained in:
Sebastian Markbåge
2025-01-02 14:34:26 -05:00
committed by GitHub
parent 6ca7fbe884
commit d8b903f49e
2 changed files with 5 additions and 10 deletions
+3 -6
View File
@@ -236,23 +236,20 @@ let inProgressLanes: Lanes | null = null;
let inProgressRoot: FiberRoot | null = null;
let focusedInstanceHandle: null | Fiber = null;
let shouldFireAfterActiveInstanceBlur: boolean = false;
export let shouldFireAfterActiveInstanceBlur: boolean = false;
export function commitBeforeMutationEffects(
root: FiberRoot,
firstChild: Fiber,
): boolean {
): void {
focusedInstanceHandle = prepareForCommit(root.containerInfo);
shouldFireAfterActiveInstanceBlur = false;
nextEffect = firstChild;
commitBeforeMutationEffects_begin();
// We no longer need to track the active instance fiber
const shouldFire = shouldFireAfterActiveInstanceBlur;
shouldFireAfterActiveInstanceBlur = false;
focusedInstanceHandle = null;
return shouldFire;
}
function commitBeforeMutationEffects_begin() {
+2 -4
View File
@@ -198,6 +198,7 @@ import {
} from './ReactFiberThrow';
import {
commitBeforeMutationEffects,
shouldFireAfterActiveInstanceBlur,
commitLayoutEffects,
commitMutationEffects,
commitPassiveMountEffects,
@@ -3384,10 +3385,7 @@ function commitRootImpl(
// The first phase a "before mutation" phase. We use this phase to read the
// state of the host tree right before we mutate it. This is where
// getSnapshotBeforeUpdate is called.
const shouldFireAfterActiveInstanceBlur = commitBeforeMutationEffects(
root,
finishedWork,
);
commitBeforeMutationEffects(root, finishedWork);
// The next phase is the mutation phase, where we mutate the host tree.
commitMutationEffects(root, finishedWork, lanes);