Skip to content

Commit

Permalink
Merge pull request #819 from replayio/bugfix/FE-1711-react-fiber-alte…
Browse files Browse the repository at this point in the history
…rnates
  • Loading branch information
markerikson committed Jul 15, 2023
2 parents 9fb0f2b + ef0f0ae commit 810fe79
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2951,6 +2951,7 @@ const char* gReactDevtoolsScript = R""""(
const stubFiberRoots = {};
const unmountedFibersByRenderer = {};
const unmountedFiberAlternatesByRenderer = {};
const stubHook = {
isStub: true,
Expand Down Expand Up @@ -2979,6 +2980,14 @@ function getUnmountedFibersSetForRenderer(rendererID) {
return unmountedFibersByRenderer[rendererID];
}
function getUnmountedFiberAlternatesForRenderer(rendererID) {
if (!unmountedFiberAlternatesByRenderer[rendererID]) {
unmountedFiberAlternatesByRenderer[rendererID] = new Map();
}
return unmountedFiberAlternatesByRenderer[rendererID];
}
window.__REACT_DEVTOOLS_SAVED_RENDERERS__ = [];
window.__REACT_DEVTOOLS_STUB_FIBER_ROOTS = stubFiberRoots;
Expand Down Expand Up @@ -3011,6 +3020,12 @@ function onCommitFiberUnmount(rendererID, fiber) {
const unmountedFibersSet = getUnmountedFibersSetForRenderer(rendererID);
unmountedFibersSet.add(fiber);
let unmountedFiberAlternates;
if (fiber.alternate) {
unmountedFiberAlternates = getUnmountedFiberAlternatesForRenderer(rendererID);
unmountedFiberAlternates.set(fiber, fiber.alternate);
}
window.__RECORD_REPLAY_ANNOTATION_HOOK__("react-devtools-hook:v1:" + annotationType, "");
}
Expand All @@ -3035,9 +3050,13 @@ function onCommitFiberRoot(rendererID, root, priorityLevel) {
// Get these so it's in scope in the routine eval, and we can clear it after the annotation
const unmountedFibersSet = getUnmountedFibersSetForRenderer(rendererID);
const unmountedFiberAlternates = getUnmountedFiberAlternatesForRenderer(rendererID);
window.__RECORD_REPLAY_ANNOTATION_HOOK__("react-devtools-hook:v1:" + annotationType, "");
for (const fiber of unmountedFibersSet) {
unmountedFiberAlternates.delete(fiber);
}
unmountedFibersSet.clear();
}
Expand Down

0 comments on commit 810fe79

Please sign in to comment.