[react-native] Disable styles as props#28217
Conversation
a2338a5 to
7be8646
Compare
|
Yup, looks good, thanks! This will probably lead to breakage for some people, but unfortunately there’s not much we can do about that. |
|
I'm not against this change, it is totally correct. But I can't understand why is this published as I think this should be published as |
|
@vovkasm This change brings the TS typings inline with the canonical Flow ones |
|
Understand and this is valid position. But still think, that we could wait to follow versioning rules more strictly. But may be this rules only in my head? )))) Only couple of notes:
|
There isn’t really any versioning rules that apply here afaict 😄 If we’re talking semantic versioning then things are allowed to break with any version < v1 and even if we wanted to do semantic versioning of just the typings then there’s no way currently to do that with DefinitelyTyped. So yeah, not ideal but that’s what it is 🤷♂️
Really?? Wow, how can that be?
Can you expand on this? At Artsy we’re still on an older version so this doesn’t ring a bell for me. |
Just one sample for DefinitelyTyped/types/react-native/index.d.ts Line 3744 in 7be8646
I can create native extension (subclass of Definition would be: This will be passed by typescript without any problems now, but before it was error because transform was already in ViewProps. And it will run without any problems (Before experiment on RN 0.56 I thought, that this will be corrupted value on native side or js error in validation of transform style prop, but no... actually style props validation occurred before mix of props and style props). This will not work however: Style prop will be ignored (it relatively hard and need more time to find code that controls this behaviour, so I can't be sure about priority for now... may be it always stable, may be in some cases style prop will have priority). In any case before this pull request programmers was warned about props vs style props conflicts. Now they will not... Again, I don't really think that this should be motivation to revert anything... But for future changes it would be good to specify versioning scheme for typings explicitly... Yes we can't use semantic versioning here... but we can use half-part of it... we can stand for ex: "Major and Minor version of typings directly link to specific RN version. But patch version - is our feature + bugfix number" This will work, because we known that RN uses patch version number only for bugfix changes. |
|
Hmm, I see, thanks for the detailed explanation 🙏 At least now it will be documented in a logical place for people to find. Regarding the future, I’m not sure I fully understand still. We don’t really control the versions of these DT packages. We can only specify what major+minor version of the package the types apply to. The patch segment of the version is in control of DT and is auto-increased for each merged DT PR. Are you saying, as previously, that we delay making changes like these until a minor version of RN gets released? |
If that turns out to be an issue after fabric, we can make these fields as |
Yes, it would be better in my opinion, but of course it needs more wide consensus ) |
|
@brunolemos If we do this, poor react-native-linear-gradient will be broken again :D |
Partially reverts #25735 and #25083
React Native is internally moving to Fabric, and as part of that migration they are deprecating the usage of styles as props (e.g.
<View flex={1} />instead of<View style={{ flex: 1 }} />).Use a meaningful title for the pull request. Include the name of the package modified.
Test the change in your own code. (Compile and run.)
Add or edit tests to reflect the change. (Run with
npm test.)Follow the advice from the readme.
Avoid common mistakes.
Run
npm run lint package-name(ortscif notslint.jsonis present).Provide a URL to documentation or source code which provides context for the suggested changes: [GENERAL] [BUGFIX] [Image] Fix props width, height and tintColor facebook/react-native#19281 (comment)
Increase the version number in the header if appropriate.
If you are making substantial changes, consider adding a
tslint.jsoncontaining{ "extends": "dtslint/dt.json" }.