Skip to content

Commit

Permalink
Lift dynamic prop merging to ConcreteComponentDescriptor
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 24, 2025
1 parent b29912c commit 54cb5c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 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(nullptr);
auto mergedDynamicProps = mergeDynamicProps(
oldDynamicProps, newDynamicProps, NullValueStrategy::Override);
rawProps = RawProps{mergedDynamicProps};
}
#endif

rawProps.parse(rawPropsParser_);

auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
Expand Down
12 changes: 0 additions & 12 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 @@ -31,17 +30,6 @@ void Props::initialize(
nativeId = ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? 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);
}
#endif
}

void Props::setProp(
Expand Down

0 comments on commit 54cb5c2

Please sign in to comment.