Skip to content

Make removeClippedSubviews toggle-resilient (#56211)#56211

Open
javache wants to merge 1 commit intofacebook:mainfrom
javache:export-D97971845
Open

Make removeClippedSubviews toggle-resilient (#56211)#56211
javache wants to merge 1 commit intofacebook:mainfrom
javache:export-D97971845

Conversation

@javache
Copy link
Member

@javache javache commented Mar 24, 2026

Summary:

The removeClippedSubviews prop toggle path in RCTViewComponentView did not
handle being turned off: children that were clipped (removed from superview)
remained invisible, and _reactSubviews became stale.

This diff:

  • Adds _updateRemoveClippedSubviewsState helper that ensures consistent state
    when toggling. On toggle-off, re-mounts all children from _reactSubviews in
    the correct order and clears the tracking array.
  • Makes the unmount path resilient by cleaning up _reactSubviews even when
    removeClippedSubviews is off.
  • Splits the unmount assert into two distinct messages: "not mounted" vs
    "mounted inside a different view".
  • Adds unit tests covering toggle-off re-mounting, ordering, cleanup, and
    unmount-after-toggle scenarios.

Changelog: [iOS][Fixed] Fixes crash when changing the value of removeClippedSubviews

Differential Revision: D97971845

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 24, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 24, 2026

@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D97971845.

@meta-codesync meta-codesync bot changed the title Make removeClippedSubviews toggle-resilient Make removeClippedSubviews toggle-resilient (#56211) Mar 24, 2026
javache added a commit to javache/react-native that referenced this pull request Mar 24, 2026
Summary:

The `removeClippedSubviews` prop toggle path in `RCTViewComponentView` did not
handle being turned off: children that were clipped (removed from superview)
remained invisible, and `_reactSubviews` became stale.

This diff:
- Adds `_updateRemoveClippedSubviewsState` helper that ensures consistent state
  when toggling. On toggle-off, re-mounts all children from `_reactSubviews` in
  the correct order and clears the tracking array.
- Makes the unmount path resilient by cleaning up `_reactSubviews` even when
  `removeClippedSubviews` is off.
- Splits the unmount assert into two distinct messages: "not mounted" vs
  "mounted inside a different view".
- Adds unit tests covering toggle-off re-mounting, ordering, cleanup, and
  unmount-after-toggle scenarios.

Changelog: [iOS][Fixed] Fixes crash when changing the value of `removeClippedSubviews`

Differential Revision: D97971845
Summary:
Pull Request resolved: facebook#56211

The `removeClippedSubviews` prop toggle path in `RCTViewComponentView` did not
handle being turned off: children that were clipped (removed from superview)
remained invisible, and `_reactSubviews` became stale.

This diff:
- Adds `_updateRemoveClippedSubviewsState` helper that ensures consistent state
  when toggling. On toggle-off, re-mounts all children from `_reactSubviews` in
  the correct order and clears the tracking array.
- Makes the unmount path resilient by cleaning up `_reactSubviews` even when
  `removeClippedSubviews` is off.
- Splits the unmount assert into two distinct messages: "not mounted" vs
  "mounted inside a different view".
- Adds unit tests covering toggle-off re-mounting, ordering, cleanup, and
  unmount-after-toggle scenarios.

Changelog: [iOS][Fixed] Fixes crash when changing the value of `removeClippedSubviews`

Differential Revision: D97971845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant