Skip to content

Commit

Permalink
Lift dynamic prop merging to ConcreteComponentDescriptor (#48939)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Jan 27, 2025
1 parent 04f647f commit 7f9a459
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <react/renderer/core/ShadowNodeFragment.h>
#include <react/renderer/core/State.h>
#include <react/renderer/graphics/Float.h>
#include "DynamicPropsUtilities.h"

namespace facebook::react {

Expand Down Expand Up @@ -112,6 +113,16 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
ShadowNodeT::filterRawProps(rawProps);
}

#ifdef ANDROID
if (ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
auto& oldDynamicProps = props->dynamicProps;
auto newDynamicProps = rawProps.toDynamic();
auto mergedDynamicProps = mergeDynamicProps(
oldDynamicProps, newDynamicProps, NullValueStrategy::Override);
rawProps = RawProps{mergedDynamicProps};
}
#endif

rawProps.parse(rawPropsParser_);

auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
Expand Down
11 changes: 1 addition & 10 deletions packages/react-native/ReactCommon/react/renderer/core/Props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <react/renderer/core/propsConversions.h>

#include <react/featureflags/ReactNativeFeatureFlags.h>
#include "DynamicPropsUtilities.h"

namespace facebook::react {

Expand All @@ -32,15 +31,7 @@ void Props::initialize(
? sourceProps.nativeId
: convertRawProp(context, rawProps, "nativeID", sourceProps.nativeId, {});
#ifdef ANDROID
if (ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
auto& oldDynamicProps = sourceProps.dynamicProps;
auto newDynamicProps = rawProps.toDynamic(filterObjectKeys);
auto mergedDynamicProps = mergeDynamicProps(
oldDynamicProps, newDynamicProps, NullValueStrategy::Override);
this->dynamicProps = mergedDynamicProps;
} else {
this->dynamicProps = rawProps.toDynamic(filterObjectKeys);
}
this->dynamicProps = rawProps.toDynamic(filterObjectKeys);
#endif
}

Expand Down

0 comments on commit 7f9a459

Please sign in to comment.