diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index 436469733d4..6e21e30fe85 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -42,6 +42,13 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ArrayPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentViewProps(); + const ArrayPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -83,6 +90,13 @@ BooleanPropNativeComponentViewProps::BooleanPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic BooleanPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentViewProps(); + const BooleanPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -123,6 +137,13 @@ ColorPropNativeComponentViewProps::ColorPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ColorPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentViewProps(); + const ColorPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -164,6 +185,13 @@ DimensionPropNativeComponentViewProps::DimensionPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic DimensionPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentViewProps(); + const DimensionPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -204,6 +232,13 @@ EdgeInsetsPropNativeComponentViewProps::EdgeInsetsPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EdgeInsetsPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EdgeInsetsPropNativeComponentViewProps(); + const EdgeInsetsPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -245,6 +280,13 @@ EnumPropNativeComponentViewProps::EnumPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EnumPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EnumPropNativeComponentViewProps(); + const EnumPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -285,6 +327,13 @@ EventNestedObjectPropsNativeComponentViewProps::EventNestedObjectPropsNativeComp #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventNestedObjectPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventNestedObjectPropsNativeComponentViewProps(); + const EventNestedObjectPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -325,6 +374,13 @@ EventPropsNativeComponentViewProps::EventPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventPropsNativeComponentViewProps(); + const EventPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -371,6 +427,13 @@ FloatPropsNativeComponentViewProps::FloatPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic FloatPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = FloatPropsNativeComponentViewProps(); + const FloatPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -412,6 +475,13 @@ ImagePropNativeComponentViewProps::ImagePropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ImagePropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentViewProps(); + const ImagePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -454,6 +524,13 @@ IntegerPropNativeComponentViewProps::IntegerPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic IntegerPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentViewProps(); + const IntegerPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -494,6 +571,13 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic InterfaceOnlyNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyNativeComponentViewProps(); + const InterfaceOnlyNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -535,6 +619,13 @@ MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MixedPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentViewProps(); + const MixedPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -579,6 +670,13 @@ MultiNativePropNativeComponentViewProps::MultiNativePropNativeComponentViewProps #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiNativePropNativeComponentViewProps(); + const MultiNativePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -619,6 +717,13 @@ NoPropsNoEventsNativeComponentViewProps::NoPropsNoEventsNativeComponentViewProps #ifdef RN_SERIALIZABLE_STATE folly::dynamic NoPropsNoEventsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsNativeComponentViewProps(); + const NoPropsNoEventsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -662,6 +767,13 @@ ObjectPropsNativeComponentProps::ObjectPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ObjectPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ObjectPropsNativeComponentProps(); + const ObjectPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -702,6 +814,13 @@ PointPropNativeComponentViewProps::PointPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic PointPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentViewProps(); + const PointPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -743,6 +862,13 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic StringPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = StringPropNativeComponentViewProps(); + const StringPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index d3344cc3953..312b07e492e 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -42,6 +42,13 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ArrayPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentViewProps(); + const ArrayPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -83,6 +90,13 @@ BooleanPropNativeComponentViewProps::BooleanPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic BooleanPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentViewProps(); + const BooleanPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -123,6 +137,13 @@ ColorPropNativeComponentViewProps::ColorPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ColorPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentViewProps(); + const ColorPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -164,6 +185,13 @@ DimensionPropNativeComponentViewProps::DimensionPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic DimensionPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentViewProps(); + const DimensionPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -204,6 +232,13 @@ EdgeInsetsPropNativeComponentViewProps::EdgeInsetsPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EdgeInsetsPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EdgeInsetsPropNativeComponentViewProps(); + const EdgeInsetsPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -245,6 +280,13 @@ EnumPropNativeComponentViewProps::EnumPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EnumPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EnumPropNativeComponentViewProps(); + const EnumPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -285,6 +327,13 @@ EventNestedObjectPropsNativeComponentViewProps::EventNestedObjectPropsNativeComp #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventNestedObjectPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventNestedObjectPropsNativeComponentViewProps(); + const EventNestedObjectPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -325,6 +374,13 @@ EventPropsNativeComponentViewProps::EventPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventPropsNativeComponentViewProps(); + const EventPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -371,6 +427,13 @@ FloatPropsNativeComponentViewProps::FloatPropsNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic FloatPropsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = FloatPropsNativeComponentViewProps(); + const FloatPropsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -412,6 +475,13 @@ ImagePropNativeComponentViewProps::ImagePropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ImagePropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentViewProps(); + const ImagePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -454,6 +524,13 @@ IntegerPropNativeComponentViewProps::IntegerPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic IntegerPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentViewProps(); + const IntegerPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -494,6 +571,13 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic InterfaceOnlyNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyNativeComponentViewProps(); + const InterfaceOnlyNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -535,6 +619,13 @@ MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MixedPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentViewProps(); + const MixedPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -579,6 +670,13 @@ MultiNativePropNativeComponentViewProps::MultiNativePropNativeComponentViewProps #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiNativePropNativeComponentViewProps(); + const MultiNativePropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -619,6 +717,13 @@ NoPropsNoEventsNativeComponentViewProps::NoPropsNoEventsNativeComponentViewProps #ifdef RN_SERIALIZABLE_STATE folly::dynamic NoPropsNoEventsNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsNativeComponentViewProps(); + const NoPropsNoEventsNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -662,6 +767,13 @@ ObjectPropsNativeComponentProps::ObjectPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ObjectPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ObjectPropsNativeComponentProps(); + const ObjectPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -702,6 +814,13 @@ PointPropNativeComponentViewProps::PointPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic PointPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentViewProps(); + const PointPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -743,6 +862,13 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic StringPropNativeComponentViewProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = StringPropNativeComponentViewProps(); + const StringPropNativeComponentViewProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index bfa926c905d..337dad22f61 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -82,6 +82,13 @@ function generatePropsDiffString( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ${className}::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ${className}(); + const ${className}* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index 962a6feedb7..7fcc53e37ad 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -42,6 +42,13 @@ ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ArrayPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentProps(); + const ArrayPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -82,6 +89,13 @@ ArrayPropsNativeComponentProps::ArrayPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ArrayPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ArrayPropsNativeComponentProps(); + const ArrayPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -122,6 +136,13 @@ BooleanPropNativeComponentProps::BooleanPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic BooleanPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = BooleanPropNativeComponentProps(); + const BooleanPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -162,6 +183,13 @@ ColorPropNativeComponentProps::ColorPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ColorPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ColorPropNativeComponentProps(); + const ColorPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -202,6 +230,13 @@ CommandNativeComponentProps::CommandNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic CommandNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = CommandNativeComponentProps(); + const CommandNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -242,6 +277,13 @@ CommandNativeComponentProps::CommandNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic CommandNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = CommandNativeComponentProps(); + const CommandNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -283,6 +325,13 @@ DimensionPropNativeComponentProps::DimensionPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic DimensionPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = DimensionPropNativeComponentProps(); + const DimensionPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -328,6 +377,13 @@ DoublePropNativeComponentProps::DoublePropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic DoublePropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = DoublePropNativeComponentProps(); + const DoublePropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -368,6 +424,13 @@ EventsNestedObjectNativeComponentProps::EventsNestedObjectNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventsNestedObjectNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventsNestedObjectNativeComponentProps(); + const EventsNestedObjectNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -408,6 +471,13 @@ EventsNativeComponentProps::EventsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic EventsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = EventsNativeComponentProps(); + const EventsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -448,6 +518,13 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic InterfaceOnlyComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyComponentProps(); + const InterfaceOnlyComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -488,6 +565,13 @@ ExcludedAndroidComponentProps::ExcludedAndroidComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ExcludedAndroidComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ExcludedAndroidComponentProps(); + const ExcludedAndroidComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -528,6 +612,13 @@ ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ExcludedAndroidIosComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ExcludedAndroidIosComponentProps(); + const ExcludedAndroidIosComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -568,6 +659,13 @@ ExcludedIosComponentProps::ExcludedIosComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ExcludedIosComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ExcludedIosComponentProps(); + const ExcludedIosComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -584,6 +682,13 @@ MultiFileIncludedNativeComponentProps::MultiFileIncludedNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiFileIncludedNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiFileIncludedNativeComponentProps(); + const MultiFileIncludedNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -629,6 +734,13 @@ FloatPropNativeComponentProps::FloatPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic FloatPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = FloatPropNativeComponentProps(); + const FloatPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -670,6 +782,13 @@ ImagePropNativeComponentProps::ImagePropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ImagePropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ImagePropNativeComponentProps(); + const ImagePropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -710,6 +829,13 @@ InsetsPropNativeComponentProps::InsetsPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic InsetsPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = InsetsPropNativeComponentProps(); + const InsetsPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -750,6 +876,13 @@ Int32EnumPropsNativeComponentProps::Int32EnumPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic Int32EnumPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = Int32EnumPropsNativeComponentProps(); + const Int32EnumPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -792,6 +925,13 @@ IntegerPropNativeComponentProps::IntegerPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic IntegerPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = IntegerPropNativeComponentProps(); + const IntegerPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -832,6 +972,13 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic InterfaceOnlyComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = InterfaceOnlyComponentProps(); + const InterfaceOnlyComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -873,6 +1020,13 @@ MixedPropNativeComponentProps::MixedPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MixedPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MixedPropNativeComponentProps(); + const MixedPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -917,6 +1071,13 @@ ImageColorPropNativeComponentProps::ImageColorPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ImageColorPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ImageColorPropNativeComponentProps(); + const ImageColorPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -957,6 +1118,13 @@ NoPropsNoEventsComponentProps::NoPropsNoEventsComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic NoPropsNoEventsComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = NoPropsNoEventsComponentProps(); + const NoPropsNoEventsComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -998,6 +1166,13 @@ ObjectPropsProps::ObjectPropsProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic ObjectPropsProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = ObjectPropsProps(); + const ObjectPropsProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1038,6 +1213,13 @@ PointPropNativeComponentProps::PointPropNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic PointPropNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = PointPropNativeComponentProps(); + const PointPropNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1078,6 +1260,13 @@ StringEnumPropsNativeComponentProps::StringEnumPropsNativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic StringEnumPropsNativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = StringEnumPropsNativeComponentProps(); + const StringEnumPropsNativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1119,6 +1308,13 @@ StringPropComponentProps::StringPropComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic StringPropComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = StringPropComponentProps(); + const StringPropComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1159,6 +1355,13 @@ MultiFile1NativeComponentProps::MultiFile1NativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiFile1NativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiFile1NativeComponentProps(); + const MultiFile1NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1175,6 +1378,13 @@ MultiFile2NativeComponentProps::MultiFile2NativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiFile2NativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiFile2NativeComponentProps(); + const MultiFile2NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1215,6 +1425,13 @@ MultiComponent1NativeComponentProps::MultiComponent1NativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiComponent1NativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiComponent1NativeComponentProps(); + const MultiComponent1NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps @@ -1231,6 +1448,13 @@ MultiComponent2NativeComponentProps::MultiComponent2NativeComponentProps( #ifdef RN_SERIALIZABLE_STATE folly::dynamic MultiComponent2NativeComponentProps::getDiffProps( const Props* prevProps) const { + static const auto defaultProps = MultiComponent2NativeComponentProps(); + const MultiComponent2NativeComponentProps* oldProps = prevProps == nullptr + ? &defaultProps + : static_cast(prevProps); + if (this == oldProps) { + return folly::dynamic::object(); + } folly::dynamic result = HostPlatformViewProps::getDiffProps(prevProps); // TODO: Implement diffProps