Skip to content

[Fiber] Avoid return value from commitBeforeMutationEffects #31922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,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() {
Expand Down
6 changes: 2 additions & 4 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ import {
} from './ReactFiberThrow';
import {
commitBeforeMutationEffects,
shouldFireAfterActiveInstanceBlur,
commitLayoutEffects,
commitMutationEffects,
commitPassiveMountEffects,
Expand Down Expand Up @@ -3361,10 +3362,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);
Expand Down
Loading