From 07a6486dd18e56da1f29e6914f7c5dee208cba83 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 25 Jun 2026 08:43:12 -0700 Subject: [PATCH] Move `nativeId` parsing into the `Props` ctor initializer list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Every Props subclass parses its fields in its 3-arg ctor's initializer list, but `Props` was the odd one out — its 3-arg ctor had an empty initializer list and a body that called a separate `Props::initialize` method, which then assigned `nativeId` and (on Android) ran `initializeDynamicProps`. Fold the `nativeId` parse back into the initializer list and inline the Android `initializeDynamicProps` call into the ctor body, matching the subclass pattern. This removes the only remaining external caller of `Props::initialize`: `YogaStylableProps`'s ctor was constructing its `Props` subobject via `Props()` and then calling `initialize(...)` from its body. Replace with the standard `Props(ctx, sourceProps, rawProps, filterObjectKeys)` initializer-list chain. With both call sites gone, delete `Props::initialize` outright. Behaviour is unchanged: the work that `initialize` did still runs on the same construction path, just via the ctor itself. Changelog: [Internal] Differential Revision: D109691981 --- .../components/view/YogaStylableProps.cpp | 12 ++++------ .../ReactCommon/react/renderer/core/Props.cpp | 23 ++++++++----------- .../ReactCommon/react/renderer/core/Props.h | 12 ---------- .../api-snapshots/ReactAndroidDebugCxx.api | 1 - .../api-snapshots/ReactAndroidNewarchCxx.api | 1 - .../api-snapshots/ReactAndroidReleaseCxx.api | 1 - .../api-snapshots/ReactAppleDebugCxx.api | 1 - .../api-snapshots/ReactAppleNewarchCxx.api | 1 - .../api-snapshots/ReactAppleReleaseCxx.api | 1 - .../api-snapshots/ReactCommonDebugCxx.api | 1 - .../api-snapshots/ReactCommonNewarchCxx.api | 1 - .../api-snapshots/ReactCommonReleaseCxx.api | 1 - 12 files changed, 15 insertions(+), 41 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp index ae2da15fc0a4..d740d4a153bd 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp @@ -24,13 +24,11 @@ YogaStylableProps::YogaStylableProps( const YogaStylableProps& sourceProps, const RawProps& rawProps, const std::function& filterObjectKeys) - : Props() { - initialize(context, sourceProps, rawProps, filterObjectKeys); - - yogaStyle = ReactNativeFeatureFlags::enableCppPropsIteratorSetter() - ? sourceProps.yogaStyle - : convertRawProp(context, rawProps, sourceProps.yogaStyle); - + : Props(context, sourceProps, rawProps, filterObjectKeys), + yogaStyle( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.yogaStyle + : convertRawProp(context, rawProps, sourceProps.yogaStyle)) { if (!ReactNativeFeatureFlags::enableCppPropsIteratorSetter()) { convertRawPropAliases(context, sourceProps, rawProps); } diff --git a/packages/react-native/ReactCommon/react/renderer/core/Props.cpp b/packages/react-native/ReactCommon/react/renderer/core/Props.cpp index f5553a117c6a..aca087d296e4 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/Props.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/Props.cpp @@ -16,23 +16,20 @@ namespace facebook::react { Props::Props( - const PropsParserContext& context, - const Props& sourceProps, - const RawProps& rawProps, - const std::function& filterObjectKeys) { - initialize(context, sourceProps, rawProps, filterObjectKeys); -} - -void Props::initialize( const PropsParserContext& context, const Props& sourceProps, const RawProps& rawProps, [[maybe_unused]] const std::function& - filterObjectKeys) { - nativeId = ReactNativeFeatureFlags::enableCppPropsIteratorSetter() - ? sourceProps.nativeId - : convertRawProp(context, rawProps, "nativeID", sourceProps.nativeId, {}); - + filterObjectKeys) + : nativeId( + ReactNativeFeatureFlags::enableCppPropsIteratorSetter() + ? sourceProps.nativeId + : convertRawProp( + context, + rawProps, + "nativeID", + sourceProps.nativeId, + {})) { #ifdef RN_SERIALIZABLE_STATE if (!ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid()) { initializeDynamicProps(sourceProps, rawProps, filterObjectKeys); diff --git a/packages/react-native/ReactCommon/react/renderer/core/Props.h b/packages/react-native/ReactCommon/react/renderer/core/Props.h index 2dadef6b6e6f..ad3e264d31e2 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/Props.h +++ b/packages/react-native/ReactCommon/react/renderer/core/Props.h @@ -82,18 +82,6 @@ class Props : public virtual Sealable, public virtual DebugStringConvertible { SharedDebugStringConvertibleList getDebugProps() const override; #endif - - protected: - /** Initialize member variables of Props instance */ - void initialize( - const PropsParserContext &context, - const Props &sourceProps, - const RawProps &rawProps, - /** - * Filter object keys to be excluded when converting the RawProps to - * folly::dynamic (android only) - */ - const std::function &filterObjectKeys = nullptr); }; } // namespace facebook::react diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api index 205202f898f6..4a5ea93ebca9 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api @@ -4125,7 +4125,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api index 59443fbd585d..6e821b751f6d 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api @@ -3979,7 +3979,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api index 0f5f39b20abf..77a90677d4cf 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api @@ -4122,7 +4122,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index cc3c6c0e38da..cb3c73c37a16 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -6312,7 +6312,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api index bcd1ef1969f3..87d6ca7aa0d8 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api @@ -6194,7 +6194,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index baa00077d2b5..cff79303f844 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -6309,7 +6309,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api index 575079ae0c35..87aaa9ae2891 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api @@ -2730,7 +2730,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api index 81906b49e192..ed97d3fdcb84 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonNewarchCxx.api @@ -2624,7 +2624,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); diff --git a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api index ccc6128c0ef7..9a6ba873336c 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonReleaseCxx.api @@ -2727,7 +2727,6 @@ class facebook::react::PreparedTextCacheKey { } class facebook::react::Props : public virtual facebook::react::Sealable, public virtual facebook::react::DebugStringConvertible { - protected void initialize(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr); public Props() = default; public Props(const facebook::react::Props& other) = delete; public Props(const facebook::react::PropsParserContext& context, const facebook::react::Props& sourceProps, const facebook::react::RawProps& rawProps, const std::function& filterObjectKeys = nullptr);