Skip to content

Commit 97690b6

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Lift dynamic prop merging to ConcreteComponentDescriptor (facebook#48939)
Summary: The `enableAccumulatedUpdatesInRawPropsAndroid` experiment needs additional context for finer setup. Specifically it needs to be conditionally enabled based on a component name. This information is not accessible form the `Props` constructor. This diff moves the experimental logic to `ConcreteComponentDescriptor`. Changelog: [Internal] Differential Revision: D68633985
1 parent 1d3d927 commit 97690b6

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <react/debug/react_native_assert.h>
1414
#include <react/featureflags/ReactNativeFeatureFlags.h>
1515
#include <react/renderer/core/ComponentDescriptor.h>
16+
#include <react/renderer/core/DynamicPropsUtilities.h>
1617
#include <react/renderer/core/EventDispatcher.h>
1718
#include <react/renderer/core/Props.h>
1819
#include <react/renderer/core/PropsParserContext.h>
@@ -114,6 +115,16 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
114115

115116
rawProps.parse(rawPropsParser_);
116117

118+
#ifdef ANDROID
119+
if (ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
120+
auto& oldDynamicProps = props->rawProps;
121+
auto newDynamicProps = rawProps.toDynamic();
122+
auto mergedDynamicProps = mergeDynamicProps(
123+
oldDynamicProps, newDynamicProps, NullValueStrategy::Override);
124+
rawProps = RawProps{mergedDynamicProps};
125+
}
126+
#endif
127+
117128
auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
118129
// Use the new-style iterator
119130
// Note that we just check if `Props` has this flag set, no matter

packages/react-native/ReactCommon/react/renderer/core/Props.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <react/renderer/core/propsConversions.h>
1111

1212
#include <react/featureflags/ReactNativeFeatureFlags.h>
13-
#include "DynamicPropsUtilities.h"
1413

1514
namespace facebook::react {
1615

@@ -32,15 +31,7 @@ void Props::initialize(
3231
? sourceProps.nativeId
3332
: convertRawProp(context, rawProps, "nativeID", sourceProps.nativeId, {});
3433
#ifdef ANDROID
35-
if (ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
36-
auto& oldRawProps = sourceProps.rawProps;
37-
auto newRawProps = rawProps.toDynamic(filterObjectKeys);
38-
auto mergedRawProps = mergeDynamicProps(
39-
oldRawProps, newRawProps, NullValueStrategy::Override);
40-
this->rawProps = mergedRawProps;
41-
} else {
42-
this->rawProps = rawProps.toDynamic(filterObjectKeys);
43-
}
34+
this->rawProps = rawProps.toDynamic(filterObjectKeys);
4435
#endif
4536
}
4637

0 commit comments

Comments
 (0)