Skip to content

Commit bc61bd5

Browse files
committed
updaters
1 parent 6b83e93 commit bc61bd5

File tree

1 file changed

+22
-20
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+22
-20
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

+22-20
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,25 @@ export function attach(
28912891
}
28922892
}
28932893
}
2894+
2895+
// If this Fiber was in the set of memoizedUpdaters we need to record
2896+
// it to be included in the description of the commit.
2897+
const fiberRoot: FiberRoot = currentRoot.data.stateNode;
2898+
const updaters = fiberRoot.memoizedUpdaters;
2899+
if (
2900+
updaters != null &&
2901+
(updaters.has(fiber) ||
2902+
// We check the alternate here because we're matching identity and
2903+
// prevFiber might be same as fiber.
2904+
(fiber.alternate !== null && updaters.has(fiber.alternate)))
2905+
) {
2906+
const metadata =
2907+
((currentCommitProfilingMetadata: any): CommitProfilingData);
2908+
if (metadata.updaters === null) {
2909+
metadata.updaters = [];
2910+
}
2911+
metadata.updaters.push(instanceToSerializedElement(fiberInstance));
2912+
}
28942913
}
28952914
}
28962915

@@ -3591,35 +3610,20 @@ export function attach(
35913610
commitTime: getCurrentTime() - profilingStartTime,
35923611
maxActualDuration: 0,
35933612
priorityLevel: null,
3594-
updaters: getUpdatersList(root),
3613+
updaters: null,
35953614
effectDuration: null,
35963615
passiveEffectDuration: null,
35973616
};
35983617
}
35993618

36003619
mountFiberRecursively(root.current, false);
3620+
36013621
flushPendingEvents(root);
36023622
currentRoot = (null: any);
36033623
});
36043624
}
36053625
}
36063626

3607-
function getUpdatersList(root: any): Array<SerializedElement> | null {
3608-
const updaters = root.memoizedUpdaters;
3609-
if (updaters == null) {
3610-
return null;
3611-
}
3612-
const result = [];
3613-
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
3614-
for (const updater of updaters) {
3615-
const inst = getFiberInstanceUnsafe(updater);
3616-
if (inst !== null) {
3617-
result.push(instanceToSerializedElement(inst));
3618-
}
3619-
}
3620-
return result;
3621-
}
3622-
36233627
function handleCommitFiberUnmount(fiber: any) {
36243628
// This Hook is no longer used. After having shipped DevTools everywhere it is
36253629
// safe to stop calling it from Fiber.
@@ -3684,9 +3688,7 @@ export function attach(
36843688
maxActualDuration: 0,
36853689
priorityLevel:
36863690
priorityLevel == null ? null : formatPriorityLevel(priorityLevel),
3687-
3688-
updaters: getUpdatersList(root),
3689-
3691+
updaters: null,
36903692
// Initialize to null; if new enough React version is running,
36913693
// these values will be read during separate handlePostCommitFiberRoot() call.
36923694
effectDuration: null,

0 commit comments

Comments
 (0)