[DevTools] Check suspense child node presence in parentSuspense.children before removing#509
[DevTools] Check suspense child node presence in parentSuspense.children before removing#509everettbu wants to merge 1 commit into
Conversation
…ren before removing
Greptile OverviewGreptile SummaryAdds a defensive check before removing a suspense child node from its parent's
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: cce34d3 |
| if (index === -1) { | ||
| this._throwAndEmitError( | ||
| Error( | ||
| `Cannot remove suspense node "${id}" from parent "${parentID}" because it is not a child of the parent.`, | ||
| ), | ||
| ); | ||
| } |
There was a problem hiding this comment.
Analogous check missing for non-suspense nodes
This guard is a good fix. Note that the same unguarded indexOf + splice pattern exists for the non-suspense element removal path at line 1619-1620:
const index = parentElement.children.indexOf(id);
parentElement.children.splice(index, 1);That path has the same silent-last-child-removal bug. It might be worth adding a similar check there for consistency. Not blocking this PR, but flagging for awareness.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/store.js
Line: 1876:1882
Comment:
**Analogous check missing for non-suspense nodes**
This guard is a good fix. Note that the same unguarded `indexOf` + `splice` pattern exists for the non-suspense element removal path at line 1619-1620:
```js
const index = parentElement.children.indexOf(id);
parentElement.children.splice(index, 1);
```
That path has the same silent-last-child-removal bug. It might be worth adding a similar check there for consistency. Not blocking this PR, but flagging for awareness.
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35775
Original author: hoxyq
Currently, this silently removes the last child in the list, which doesn't contain the
id.