Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN 0.78] Changes to experimental_layoutConformance #245

Open
NickGerleman opened this issue Dec 10, 2024 · 1 comment
Open

[RN 0.78] Changes to experimental_layoutConformance #245

NickGerleman opened this issue Dec 10, 2024 · 1 comment

Comments

@NickGerleman
Copy link

NickGerleman commented Dec 10, 2024

PR: facebook/react-native#48188
Phabricator Diff (with more product context): https://www.internalfb.com/diff/D66910054

The gist

I am looking to replace React Native's context-setting experimental_layoutConformance View property with a new LayoutConformance context-like component, imported as experimental_LayoutConformance.

Impact to React Strict DOM

createStrictDOMComponent sets experimental_layoutConformance="strict" for every View component.

Introducing a new context-like component for every Strict DOM component would add overhead, and RSD setting contexts for mixed RN component trees underneath it is not super understandable. I think we should remove the usage from RSD, but encourage apps who want the behavior to add a LayoutConformance component to their root (we do this for Meta apps code-sharing aleady).

Context

React Native currently exposes a configurable "layout conformance" flag to let users pick which subtrees are laid out with preference to W3C/correct layout, as compared to buggy "compatibility mode". This helps us continue to ship new features and fixes to Yoga as we evolve the engine, delivering less surprises when code-sharing between RN and Web.

The original desired API for layout contexts was a StrictLayout context-like component, inspired by React.StrictMode. This was hard to do at the time, so we added a new (context-setting) property on View, experimental_layoutConformance="strict|classic".

With recent support or display: contents, we can achieve the original goal, of a context-like component, which introduces contexts into the ShadowTree, without creating a layout box.

Before

import {View} from 'react-native';

// Root of the app
<View {...props} experimental_layoutConformance="strict">
  {content}
</View>

After

import {View, experimental_LayoutConformance as LayoutConformance} from 'react-native';

// Root of the app
<LayoutConformance mode="strict">
  <View {...props}>
    {content}
  </View>
</LayoutConformance>

Meta Internal

React Technologies Workplace Thread

Diff (with extra context)

@necolas
Copy link
Contributor

necolas commented Dec 10, 2024

Ok no problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants