Skip to content

Commit 03ca38e

Browse files
authored
[DevTools] Check suspense child node presence in parentSuspense.children before removing (facebook#35775)
Currently, this silently removes the last child in the list, which doesn't contain the `id`.
1 parent 6066c78 commit 03ca38e

File tree

1 file changed

+7
-0
lines changed
  • packages/react-devtools-shared/src/devtools

1 file changed

+7
-0
lines changed

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,13 @@ export default class Store extends EventEmitter<{
18731873
}
18741874

18751875
const index = parentSuspense.children.indexOf(id);
1876+
if (index === -1) {
1877+
this._throwAndEmitError(
1878+
Error(
1879+
`Cannot remove suspense node "${id}" from parent "${parentID}" because it is not a child of the parent.`,
1880+
),
1881+
);
1882+
}
18761883
parentSuspense.children.splice(index, 1);
18771884
}
18781885
}

0 commit comments

Comments
 (0)