Files
react-native/packages
Samuel SuslaandFacebook GitHub Bot 7dda5512ff introduce opt out mechanism for View Culling (#51657)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51657

changelog: [internal]

Introduce a new ShadowNodeTraits: `Unstable_uncullableView` and `Unstable_uncullableTrace`. As the name suggests, this is not stable API yet.

When a shadow node sets this trait, it will be opted out of view culling together with its ancestors all the way to the root.

The trait is propagated to its parent in 4 different places:
1. When node is first created.
2. When node is cloned.
3. When child is appended.
4. When child is replaced.

we can safely do it only in those places because React constructs nodes from bottom up. We are leveraging this implementation detail here but if that changes in the future, a traversal will be required.

Alternative solution considered here was a traversal of shadow tree during commit phase to propagate `Unstable_uncullable` trait. This could be done in a separate traversal or as part of layout phase where layout information is copied out of Yoga tree. Leveraging the fact that React is cloning bottom up makes the implementation simpler.

If React changes its cloning approach in the future, this will be caught by tests.

Reviewed By: lenaic

Differential Revision: D75476847

fbshipit-source-id: f1e98804565c140c64945662af0247b1bd0e1882
2025-05-28 06:25:41 -07:00
..
2025-05-26 07:04:40 -07:00
2025-05-26 07:04:40 -07:00
2025-04-17 09:49:03 -07:00