Skip to content

Commit

Permalink
Lift dynamic prop merging to ConcreteComponentDescriptor (facebook#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 1d3d927 commit 97690b6
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 @@ -13,6 +13,7 @@
#include <react/debug/react_native_assert.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/DynamicPropsUtilities.h>
#include <react/renderer/core/EventDispatcher.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/PropsParserContext.h>
Expand Down Expand Up @@ -114,6 +115,16 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {

rawProps.parse(rawPropsParser_);

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

auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
// Use the new-style iterator
// Note that we just check if `Props` has this flag set, no matter
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& oldRawProps = sourceProps.rawProps;
auto newRawProps = rawProps.toDynamic(filterObjectKeys);
auto mergedRawProps = mergeDynamicProps(
oldRawProps, newRawProps, NullValueStrategy::Override);
this->rawProps = mergedRawProps;
} else {
this->rawProps = rawProps.toDynamic(filterObjectKeys);
}
this->rawProps = rawProps.toDynamic(filterObjectKeys);
#endif
}

Expand Down

0 comments on commit 97690b6

Please sign in to comment.