Repository navigation
Commit e83e491
Fix LegacyViewManagerInterop unmounting the wrong child of a legacy view
Summary:
`RCTLegacyViewManagerInteropComponentView` removed a child of the hosted legacy (Paper) view with
`removeReactSubview:reactSubviews[index]`, using the Fabric index of the child as a position in the Paper view's
`reactSubviews`. The two differ while a mount is queued in `_viewsToBeMounted`, so the wrong child was removed (a child that
should be gone stayed attached, "ghost view") and the child named by the mutation was left attached.
When the removal was deferred instead (`index >= reactSubviews.count`), it only ran in `finalizeUpdates:`, after the same
transaction had already deleted the child. The deleted view was recycled while it still had a superview, which fails
`RCTAssert(view.superview == nil, "Attempt to recycle a mounted view")` in debug builds. It also queued the interop
wrapper rather than the content view that `mountChildComponentView:index:` inserted, so a child that is itself an interop view
was never removed.
The child named by the mutation is now looked up: a child whose mount is still queued is dropped from the queue, any other is
removed from the Paper view immediately (as the view that was inserted), so it has no superview when the transaction deletes it.
Changelog:
[IOS] [FIXED] - LegacyViewManagerInterop removes the child named by the unmount mutation, not the one at its index in the legacy view
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>1 parent 1c6e0c7 commit e83e491
1 file changed
Lines changed: 23 additions & 3 deletions
File tree
- packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
200 | 220 | | |
201 | | - | |
| 221 | + | |
202 | 222 | | |
203 | 223 | | |
204 | 224 | | |
| |||
0 commit comments