facebook / react-strict-dom

React Strict DOM (RSD) is a subset of React DOM, imperative DOM, and CSS that supports web and native targets
MIT License
2.97k stars 149 forks source link

Support for css.include for Native #111

Closed efoken closed 4 weeks ago

efoken commented 4 weeks ago

Describe the feature request

I don't know if stylex.include is an official StyleX API? But with react-strict-dom the css.include works on Web, but not for Native.

Example:

import { typography } './globals.stylex';

export const styles = css.create({
  root: {
    color: '#000',
  },
  large: {
    ...css.include(typography.bodyLarge),
  },
});

For Native I tried to use normal object spread, and it worked:

import { typography } './globals.stylex';

export const styles = css.create({
  // ...
  large: {
    ...typography.bodyLarge,
  },
});
necolas commented 4 weeks ago

stylex.include is not a StyleX API we expect to keep. We don't use it internally

efoken commented 4 weeks ago

Good to know, thanks 🙏 But how is it possible to use object spreading?

nmn commented 3 weeks ago

But how is it possible to use object spreading?

This happens due to how StyleX is implemented as a runtime lib for RN. This will likely change in the future and is not safe to depend on.

efoken commented 3 weeks ago

Yeah I know @nmn 😉 I meant, what is the recommended way to handle this case when I want to include typography style into another style? What can I use instead of css.include?

necolas commented 3 weeks ago

You just add the style into the array of styles passed as a prop - it's the default way that styles are composed in RN and StyleX