Skip to content

Commit f47082b

Browse files
RSNarafacebook-github-bot
authored andcommitted
Generate Props C++ structs on all platforms
Summary: The props generator assumes that Props are used only on iOS. (i.e: the generator doesn't generate the props code if the iOS platform is excluded). However, Props are also used on Android. So, this diff makes us generate Props for all platforms. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D34559900 fbshipit-source-id: 0c25835dd57aa55a094152c147a9f952b9bc6850
1 parent 922219a commit f47082b

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js

-7
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ module.exports = {
126126
}
127127

128128
return Object.keys(components)
129-
.filter(componentName => {
130-
const component = components[componentName];
131-
return !(
132-
component.excludedPlatforms &&
133-
component.excludedPlatforms.includes('iOS')
134-
);
135-
})
136129
.map(componentName => {
137130
const component = components[componentName];
138131
const newName = `${componentName}Props`;

packages/react-native-codegen/src/generators/components/GeneratePropsH.js

-7
Original file line numberDiff line numberDiff line change
@@ -860,13 +860,6 @@ module.exports = {
860860
}
861861

862862
return Object.keys(components)
863-
.filter(componentName => {
864-
const component = components[componentName];
865-
return !(
866-
component.excludedPlatforms &&
867-
component.excludedPlatforms.includes('iOS')
868-
);
869-
})
870863
.map(componentName => {
871864
const component = components[componentName];
872865

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap

+6
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,13 @@ Map {
398398
namespace facebook {
399399
namespace react {
400400
401+
ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps(
402+
const PropsParserContext &context,
403+
const ExcludedAndroidIosComponentProps &sourceProps,
404+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps)
401405
406+
407+
{}
402408
403409
} // namespace react
404410
} // namespace facebook

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap

+10-1
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,21 @@ Map {
626626
*/
627627
#pragma once
628628
629-
629+
#include <react/renderer/components/view/ViewProps.h>
630+
#include <react/renderer/core/PropsParserContext.h>
630631
631632
namespace facebook {
632633
namespace react {
633634
635+
class ExcludedAndroidIosComponentProps final : public ViewProps {
636+
public:
637+
ExcludedAndroidIosComponentProps() = default;
638+
ExcludedAndroidIosComponentProps(const PropsParserContext& context, const ExcludedAndroidIosComponentProps &sourceProps, const RawProps &rawProps);
639+
640+
#pragma mark - Props
634641
642+
643+
};
635644
636645
} // namespace react
637646
} // namespace facebook

0 commit comments

Comments
 (0)