Files
react-native/packages/react-native/Libraries/ReactNative
Andrew CoatesandFacebook GitHub Bot dbdd4da14f Add ability to override the ViewStyle of the root View component (#44665)
Summary:
In order to host a ReactNative surface whose size is controlled by the RN content rather than the size of the surface, we need the ability to remove  the flex:1 style on the root View component.

`SurfaceHandler` has layout functions which take a `LayoutConstraint` (so min/max size).   The root View component in `AppContainer` has a hardcoded `flex:1` style.  This view is above the `WrapperComponent`, which we can currently override.  But I dont see anyway to avoid the root View having that flex style.  This flex style means that the rootview will always be the maxheight passed into the layout functions on `SurfaceHandler`.  Which prevents allowing RN surfaces that can size themselves based on their content.

This change adds a `setRootViewStyleProvider` method to `AppRegistry`, which works similar to `setWrapperComponentProvider` but allows apps to override the style property on the root View component.  In particular, this allows apps to remove the flex:1 style, which is required to enable react surfaces which are sized based on their contents.

## Changelog:

Pick one each for the category and type tags:

[GENERAL] [ADDED] - Added AppRegistry.setRootViewStyleProvider

Pull Request resolved: https://github.com/facebook/react-native/pull/44665

Test Plan: Will be including this change into react-native-windows to enable scenarios with content sized surfaces within Microsoft Office to work with the new architecture.  Would like signoff on this direction before I go and integrate it there.

Reviewed By: javache

Differential Revision: D58138443

Pulled By: hoxyq

fbshipit-source-id: 95ab4842aa7f827867788d8787527f9675cf4fcc
2024-06-07 03:19:43 -07:00
..
2023-10-11 11:21:19 -07:00