Skip to content

Commit 70890e7

Browse files
eps1lonhoxyq
andauthored
Consistent handling of work tags for rename, delete, and overriding state (#35740)
Co-authored-by: Ruslan Lesiutin <28902667+hoxyq@users.noreply.github.com>
1 parent f23aa1d commit 70890e7

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

  • packages/react-devtools-shared/src/backend/fiber

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6859,6 +6859,8 @@ export function attach(
68596859
68606860
// TODO Show custom UI for Cache like we do for Suspense
68616861
// For now, just hide state data entirely since it's not meant to be inspected.
6862+
// Make sure delete, rename, and override of state handles all tags for which
6863+
// we show state.
68626864
const showState =
68636865
tag === ClassComponent || tag === IncompleteClassComponent;
68646866
@@ -7815,8 +7817,13 @@ export function attach(
78157817
}
78167818
break;
78177819
case 'state':
7818-
deletePathInObject(instance.state, path);
7819-
instance.forceUpdate();
7820+
switch (fiber.tag) {
7821+
case ClassComponent:
7822+
case IncompleteClassComponent:
7823+
deletePathInObject(instance.state, path);
7824+
instance.forceUpdate();
7825+
break;
7826+
}
78207827
break;
78217828
}
78227829
}
@@ -7893,8 +7900,13 @@ export function attach(
78937900
}
78947901
break;
78957902
case 'state':
7896-
renamePathInObject(instance.state, oldPath, newPath);
7897-
instance.forceUpdate();
7903+
switch (fiber.tag) {
7904+
case ClassComponent:
7905+
case IncompleteClassComponent:
7906+
renamePathInObject(instance.state, oldPath, newPath);
7907+
instance.forceUpdate();
7908+
break;
7909+
}
78987910
break;
78997911
}
79007912
}
@@ -7964,6 +7976,7 @@ export function attach(
79647976
case 'state':
79657977
switch (fiber.tag) {
79667978
case ClassComponent:
7979+
case IncompleteClassComponent:
79677980
setInObject(instance.state, path, value);
79687981
instance.forceUpdate();
79697982
break;

0 commit comments

Comments
 (0)