mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[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:
+3
-6
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user