Skip to content

Commit c660868

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Mark prop diffing availability for codegen props (#52246)
Summary: Pull Request resolved: #52246 This diff adds the required override to codegen props to make the `FabricMountingManager` aware of the availability of a prop diffing implementation for native components using codegen props. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D77234066 fbshipit-source-id: 8e95628348f491c5ee08609bc7d7b3d30bc7151b
1 parent 53ce247 commit c660868

8 files changed

Lines changed: 414 additions & 0 deletions

File tree

packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps(
4040
arrayOfMixed(convertRawProp(context, rawProps, \\"arrayOfMixed\\", sourceProps.arrayOfMixed, {})) {}
4141
4242
#ifdef RN_SERIALIZABLE_STATE
43+
ComponentName ArrayPropsNativeComponentViewProps::getDiffPropsImplementationTarget() const {
44+
return \\"ArrayPropsNativeComponentView\\";
45+
}
46+
4347
folly::dynamic ArrayPropsNativeComponentViewProps::getDiffProps(
4448
const Props* prevProps) const {
4549
static const auto defaultProps = ArrayPropsNativeComponentViewProps();
@@ -138,6 +142,10 @@ BooleanPropNativeComponentViewProps::BooleanPropNativeComponentViewProps(
138142
disabledNullable(convertRawProp(context, rawProps, \\"disabledNullable\\", sourceProps.disabledNullable, {})) {}
139143
140144
#ifdef RN_SERIALIZABLE_STATE
145+
ComponentName BooleanPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
146+
return \\"BooleanPropNativeComponentView\\";
147+
}
148+
141149
folly::dynamic BooleanPropNativeComponentViewProps::getDiffProps(
142150
const Props* prevProps) const {
143151
static const auto defaultProps = BooleanPropNativeComponentViewProps();
@@ -191,6 +199,10 @@ ColorPropNativeComponentViewProps::ColorPropNativeComponentViewProps(
191199
tintColor(convertRawProp(context, rawProps, \\"tintColor\\", sourceProps.tintColor, {})) {}
192200
193201
#ifdef RN_SERIALIZABLE_STATE
202+
ComponentName ColorPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
203+
return \\"ColorPropNativeComponentView\\";
204+
}
205+
194206
folly::dynamic ColorPropNativeComponentViewProps::getDiffProps(
195207
const Props* prevProps) const {
196208
static const auto defaultProps = ColorPropNativeComponentViewProps();
@@ -241,6 +253,10 @@ DimensionPropNativeComponentViewProps::DimensionPropNativeComponentViewProps(
241253
marginBack(convertRawProp(context, rawProps, \\"marginBack\\", sourceProps.marginBack, {})) {}
242254
243255
#ifdef RN_SERIALIZABLE_STATE
256+
ComponentName DimensionPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
257+
return \\"DimensionPropNativeComponentView\\";
258+
}
259+
244260
folly::dynamic DimensionPropNativeComponentViewProps::getDiffProps(
245261
const Props* prevProps) const {
246262
static const auto defaultProps = DimensionPropNativeComponentViewProps();
@@ -290,6 +306,10 @@ EdgeInsetsPropNativeComponentViewProps::EdgeInsetsPropNativeComponentViewProps(
290306
{}
291307
292308
#ifdef RN_SERIALIZABLE_STATE
309+
ComponentName EdgeInsetsPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
310+
return \\"EdgeInsetsPropNativeComponentView\\";
311+
}
312+
293313
folly::dynamic EdgeInsetsPropNativeComponentViewProps::getDiffProps(
294314
const Props* prevProps) const {
295315
static const auto defaultProps = EdgeInsetsPropNativeComponentViewProps();
@@ -337,6 +357,10 @@ EnumPropNativeComponentViewProps::EnumPropNativeComponentViewProps(
337357
intervals(convertRawProp(context, rawProps, \\"intervals\\", sourceProps.intervals, {EnumPropNativeComponentViewIntervals::Intervals0})) {}
338358
339359
#ifdef RN_SERIALIZABLE_STATE
360+
ComponentName EnumPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
361+
return \\"EnumPropNativeComponentView\\";
362+
}
363+
340364
folly::dynamic EnumPropNativeComponentViewProps::getDiffProps(
341365
const Props* prevProps) const {
342366
static const auto defaultProps = EnumPropNativeComponentViewProps();
@@ -390,6 +414,10 @@ EventNestedObjectPropsNativeComponentViewProps::EventNestedObjectPropsNativeComp
390414
disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {}
391415
392416
#ifdef RN_SERIALIZABLE_STATE
417+
ComponentName EventNestedObjectPropsNativeComponentViewProps::getDiffPropsImplementationTarget() const {
418+
return \\"EventNestedObjectPropsNativeComponentView\\";
419+
}
420+
393421
folly::dynamic EventNestedObjectPropsNativeComponentViewProps::getDiffProps(
394422
const Props* prevProps) const {
395423
static const auto defaultProps = EventNestedObjectPropsNativeComponentViewProps();
@@ -439,6 +467,10 @@ EventPropsNativeComponentViewProps::EventPropsNativeComponentViewProps(
439467
disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {false})) {}
440468
441469
#ifdef RN_SERIALIZABLE_STATE
470+
ComponentName EventPropsNativeComponentViewProps::getDiffPropsImplementationTarget() const {
471+
return \\"EventPropsNativeComponentView\\";
472+
}
473+
442474
folly::dynamic EventPropsNativeComponentViewProps::getDiffProps(
443475
const Props* prevProps) const {
444476
static const auto defaultProps = EventPropsNativeComponentViewProps();
@@ -494,6 +526,10 @@ FloatPropsNativeComponentViewProps::FloatPropsNativeComponentViewProps(
494526
blurRadiusNullable(convertRawProp(context, rawProps, \\"blurRadiusNullable\\", sourceProps.blurRadiusNullable, {})) {}
495527
496528
#ifdef RN_SERIALIZABLE_STATE
529+
ComponentName FloatPropsNativeComponentViewProps::getDiffPropsImplementationTarget() const {
530+
return \\"FloatPropsNativeComponentView\\";
531+
}
532+
497533
folly::dynamic FloatPropsNativeComponentViewProps::getDiffProps(
498534
const Props* prevProps) const {
499535
static const auto defaultProps = FloatPropsNativeComponentViewProps();
@@ -568,6 +604,10 @@ ImagePropNativeComponentViewProps::ImagePropNativeComponentViewProps(
568604
thumbImage(convertRawProp(context, rawProps, \\"thumbImage\\", sourceProps.thumbImage, {})) {}
569605
570606
#ifdef RN_SERIALIZABLE_STATE
607+
ComponentName ImagePropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
608+
return \\"ImagePropNativeComponentView\\";
609+
}
610+
571611
folly::dynamic ImagePropNativeComponentViewProps::getDiffProps(
572612
const Props* prevProps) const {
573613
static const auto defaultProps = ImagePropNativeComponentViewProps();
@@ -619,6 +659,10 @@ IntegerPropNativeComponentViewProps::IntegerPropNativeComponentViewProps(
619659
progress3(convertRawProp(context, rawProps, \\"progress3\\", sourceProps.progress3, {10})) {}
620660
621661
#ifdef RN_SERIALIZABLE_STATE
662+
ComponentName IntegerPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
663+
return \\"IntegerPropNativeComponentView\\";
664+
}
665+
622666
folly::dynamic IntegerPropNativeComponentViewProps::getDiffProps(
623667
const Props* prevProps) const {
624668
static const auto defaultProps = IntegerPropNativeComponentViewProps();
@@ -676,6 +720,10 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps(
676720
title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) {}
677721
678722
#ifdef RN_SERIALIZABLE_STATE
723+
ComponentName InterfaceOnlyNativeComponentViewProps::getDiffPropsImplementationTarget() const {
724+
return \\"InterfaceOnlyNativeComponentView\\";
725+
}
726+
679727
folly::dynamic InterfaceOnlyNativeComponentViewProps::getDiffProps(
680728
const Props* prevProps) const {
681729
static const auto defaultProps = InterfaceOnlyNativeComponentViewProps();
@@ -726,6 +774,10 @@ MixedPropNativeComponentViewProps::MixedPropNativeComponentViewProps(
726774
mixedProp(convertRawProp(context, rawProps, \\"mixedProp\\", sourceProps.mixedProp, {})) {}
727775
728776
#ifdef RN_SERIALIZABLE_STATE
777+
ComponentName MixedPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
778+
return \\"MixedPropNativeComponentView\\";
779+
}
780+
729781
folly::dynamic MixedPropNativeComponentViewProps::getDiffProps(
730782
const Props* prevProps) const {
731783
static const auto defaultProps = MixedPropNativeComponentViewProps();
@@ -779,6 +831,10 @@ MultiNativePropNativeComponentViewProps::MultiNativePropNativeComponentViewProps
779831
point(convertRawProp(context, rawProps, \\"point\\", sourceProps.point, {})) {}
780832
781833
#ifdef RN_SERIALIZABLE_STATE
834+
ComponentName MultiNativePropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
835+
return \\"MultiNativePropNativeComponentView\\";
836+
}
837+
782838
folly::dynamic MultiNativePropNativeComponentViewProps::getDiffProps(
783839
const Props* prevProps) const {
784840
static const auto defaultProps = MultiNativePropNativeComponentViewProps();
@@ -840,6 +896,10 @@ NoPropsNoEventsNativeComponentViewProps::NoPropsNoEventsNativeComponentViewProps
840896
{}
841897
842898
#ifdef RN_SERIALIZABLE_STATE
899+
ComponentName NoPropsNoEventsNativeComponentViewProps::getDiffPropsImplementationTarget() const {
900+
return \\"NoPropsNoEventsNativeComponentView\\";
901+
}
902+
843903
folly::dynamic NoPropsNoEventsNativeComponentViewProps::getDiffProps(
844904
const Props* prevProps) const {
845905
static const auto defaultProps = NoPropsNoEventsNativeComponentViewProps();
@@ -889,6 +949,10 @@ ObjectPropsNativeComponentProps::ObjectPropsNativeComponentProps(
889949
objectPrimitiveRequiredProp(convertRawProp(context, rawProps, \\"objectPrimitiveRequiredProp\\", sourceProps.objectPrimitiveRequiredProp, {})) {}
890950
891951
#ifdef RN_SERIALIZABLE_STATE
952+
ComponentName ObjectPropsNativeComponentProps::getDiffPropsImplementationTarget() const {
953+
return \\"ObjectPropsNativeComponent\\";
954+
}
955+
892956
folly::dynamic ObjectPropsNativeComponentProps::getDiffProps(
893957
const Props* prevProps) const {
894958
static const auto defaultProps = ObjectPropsNativeComponentProps();
@@ -946,6 +1010,10 @@ PointPropNativeComponentViewProps::PointPropNativeComponentViewProps(
9461010
startPoint(convertRawProp(context, rawProps, \\"startPoint\\", sourceProps.startPoint, {})) {}
9471011
9481012
#ifdef RN_SERIALIZABLE_STATE
1013+
ComponentName PointPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
1014+
return \\"PointPropNativeComponentView\\";
1015+
}
1016+
9491017
folly::dynamic PointPropNativeComponentViewProps::getDiffProps(
9501018
const Props* prevProps) const {
9511019
static const auto defaultProps = PointPropNativeComponentViewProps();
@@ -996,6 +1064,10 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps(
9961064
defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) {}
9971065
9981066
#ifdef RN_SERIALIZABLE_STATE
1067+
ComponentName StringPropNativeComponentViewProps::getDiffPropsImplementationTarget() const {
1068+
return \\"StringPropNativeComponentView\\";
1069+
}
1070+
9991071
folly::dynamic StringPropNativeComponentViewProps::getDiffProps(
10001072
const Props* prevProps) const {
10011073
static const auto defaultProps = StringPropNativeComponentViewProps();

packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ class ArrayPropsNativeComponentViewProps final : public ViewProps {
199199
std::vector<folly::dynamic> arrayOfMixed{};
200200
201201
#ifdef RN_SERIALIZABLE_STATE
202+
ComponentName getDiffPropsImplementationTarget() const override;
203+
202204
folly::dynamic getDiffProps(const Props* prevProps) const override;
203205
#endif
204206
};
@@ -237,6 +239,8 @@ class BooleanPropNativeComponentViewProps final : public ViewProps {
237239
bool disabledNullable{};
238240
239241
#ifdef RN_SERIALIZABLE_STATE
242+
ComponentName getDiffPropsImplementationTarget() const override;
243+
240244
folly::dynamic getDiffProps(const Props* prevProps) const override;
241245
#endif
242246
};
@@ -275,6 +279,8 @@ class ColorPropNativeComponentViewProps final : public ViewProps {
275279
SharedColor tintColor{};
276280
277281
#ifdef RN_SERIALIZABLE_STATE
282+
ComponentName getDiffPropsImplementationTarget() const override;
283+
278284
folly::dynamic getDiffProps(const Props* prevProps) const override;
279285
#endif
280286
};
@@ -314,6 +320,8 @@ class DimensionPropNativeComponentViewProps final : public ViewProps {
314320
YGValue marginBack{};
315321
316322
#ifdef RN_SERIALIZABLE_STATE
323+
ComponentName getDiffPropsImplementationTarget() const override;
324+
317325
folly::dynamic getDiffProps(const Props* prevProps) const override;
318326
#endif
319327
};
@@ -351,6 +359,8 @@ class EdgeInsetsPropNativeComponentViewProps final : public ViewProps {
351359
352360
353361
#ifdef RN_SERIALIZABLE_STATE
362+
ComponentName getDiffPropsImplementationTarget() const override;
363+
354364
folly::dynamic getDiffProps(const Props* prevProps) const override;
355365
#endif
356366
};
@@ -454,6 +464,8 @@ class EnumPropNativeComponentViewProps final : public ViewProps {
454464
EnumPropNativeComponentViewIntervals intervals{EnumPropNativeComponentViewIntervals::Intervals0};
455465
456466
#ifdef RN_SERIALIZABLE_STATE
467+
ComponentName getDiffPropsImplementationTarget() const override;
468+
457469
folly::dynamic getDiffProps(const Props* prevProps) const override;
458470
#endif
459471
};
@@ -491,6 +503,8 @@ class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps {
491503
bool disabled{false};
492504
493505
#ifdef RN_SERIALIZABLE_STATE
506+
ComponentName getDiffPropsImplementationTarget() const override;
507+
494508
folly::dynamic getDiffProps(const Props* prevProps) const override;
495509
#endif
496510
};
@@ -528,6 +542,8 @@ class EventPropsNativeComponentViewProps final : public ViewProps {
528542
bool disabled{false};
529543
530544
#ifdef RN_SERIALIZABLE_STATE
545+
ComponentName getDiffPropsImplementationTarget() const override;
546+
531547
folly::dynamic getDiffProps(const Props* prevProps) const override;
532548
#endif
533549
};
@@ -571,6 +587,8 @@ class FloatPropsNativeComponentViewProps final : public ViewProps {
571587
Float blurRadiusNullable{};
572588
573589
#ifdef RN_SERIALIZABLE_STATE
590+
ComponentName getDiffPropsImplementationTarget() const override;
591+
574592
folly::dynamic getDiffProps(const Props* prevProps) const override;
575593
#endif
576594
};
@@ -609,6 +627,8 @@ class ImagePropNativeComponentViewProps final : public ViewProps {
609627
ImageSource thumbImage{};
610628
611629
#ifdef RN_SERIALIZABLE_STATE
630+
ComponentName getDiffPropsImplementationTarget() const override;
631+
612632
folly::dynamic getDiffProps(const Props* prevProps) const override;
613633
#endif
614634
};
@@ -648,6 +668,8 @@ class IntegerPropNativeComponentViewProps final : public ViewProps {
648668
int progress3{10};
649669
650670
#ifdef RN_SERIALIZABLE_STATE
671+
ComponentName getDiffPropsImplementationTarget() const override;
672+
651673
folly::dynamic getDiffProps(const Props* prevProps) const override;
652674
#endif
653675
};
@@ -685,6 +707,8 @@ class InterfaceOnlyNativeComponentViewProps final : public ViewProps {
685707
std::string title{\\"\\"};
686708
687709
#ifdef RN_SERIALIZABLE_STATE
710+
ComponentName getDiffPropsImplementationTarget() const override;
711+
688712
folly::dynamic getDiffProps(const Props* prevProps) const override;
689713
#endif
690714
};
@@ -722,6 +746,8 @@ class MixedPropNativeComponentViewProps final : public ViewProps {
722746
folly::dynamic mixedProp{};
723747
724748
#ifdef RN_SERIALIZABLE_STATE
749+
ComponentName getDiffPropsImplementationTarget() const override;
750+
725751
folly::dynamic getDiffProps(const Props* prevProps) const override;
726752
#endif
727753
};
@@ -765,6 +791,8 @@ class MultiNativePropNativeComponentViewProps final : public ViewProps {
765791
Point point{};
766792
767793
#ifdef RN_SERIALIZABLE_STATE
794+
ComponentName getDiffPropsImplementationTarget() const override;
795+
768796
folly::dynamic getDiffProps(const Props* prevProps) const override;
769797
#endif
770798
};
@@ -802,6 +830,8 @@ class NoPropsNoEventsNativeComponentViewProps final : public ViewProps {
802830
803831
804832
#ifdef RN_SERIALIZABLE_STATE
833+
ComponentName getDiffPropsImplementationTarget() const override;
834+
805835
folly::dynamic getDiffProps(const Props* prevProps) const override;
806836
#endif
807837
};
@@ -1039,6 +1069,8 @@ class ObjectPropsNativeComponentProps final : public ViewProps {
10391069
ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct objectPrimitiveRequiredProp{};
10401070
10411071
#ifdef RN_SERIALIZABLE_STATE
1072+
ComponentName getDiffPropsImplementationTarget() const override;
1073+
10421074
folly::dynamic getDiffProps(const Props* prevProps) const override;
10431075
#endif
10441076
};
@@ -1077,6 +1109,8 @@ class PointPropNativeComponentViewProps final : public ViewProps {
10771109
Point startPoint{};
10781110
10791111
#ifdef RN_SERIALIZABLE_STATE
1112+
ComponentName getDiffPropsImplementationTarget() const override;
1113+
10801114
folly::dynamic getDiffProps(const Props* prevProps) const override;
10811115
#endif
10821116
};
@@ -1115,6 +1149,8 @@ class StringPropNativeComponentViewProps final : public ViewProps {
11151149
std::string defaultValue{};
11161150
11171151
#ifdef RN_SERIALIZABLE_STATE
1152+
ComponentName getDiffPropsImplementationTarget() const override;
1153+
11181154
folly::dynamic getDiffProps(const Props* prevProps) const override;
11191155
#endif
11201156
};

0 commit comments

Comments
 (0)