Skip to content

Commit c7cc125

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
fix props merging for Android (#51877)
Summary: Pull Request resolved: #51877 changelog: [internal] handle rawProps manually until props 2.0 is finished. Reviewed By: rubennorte, zeyap Differential Revision: D76127899 fbshipit-source-id: 42b18bb7eec401ca1289ed042c06839fd09c184d
1 parent a8db9c2 commit c7cc125

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

packages/react-native/ReactCxxPlatform/react/renderer/animated/AnimatedMountingOverrideDelegate.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
1111
#include <react/renderer/components/view/ViewProps.h>
12+
#include <react/renderer/core/DynamicPropsUtilities.h>
1213
#include <react/renderer/scheduler/Scheduler.h>
1314
#include <react/renderer/uimanager/UIManagerBinding.h>
1415

@@ -53,6 +54,7 @@ AnimatedMountingOverrideDelegate::pullTransaction(
5354
}
5455

5556
ShadowViewMutation::List filteredMutations;
57+
filteredMutations.reserve(mutations.size());
5658
for (const auto& mutation : mutations) {
5759
folly::dynamic modifiedProps = folly::dynamic::object();
5860
if (mutation.type == ShadowViewMutation::Update) {
@@ -62,7 +64,7 @@ AnimatedMountingOverrideDelegate::pullTransaction(
6264
}
6365
}
6466
if (modifiedProps.empty()) {
65-
filteredMutations.emplace_back(mutation);
67+
filteredMutations.push_back(mutation);
6668
} else {
6769
if (const auto* componentDescriptor =
6870
scheduler_
@@ -75,7 +77,19 @@ AnimatedMountingOverrideDelegate::pullTransaction(
7577
modifiedNewChildShadowView.props = componentDescriptor->cloneProps(
7678
propsParserContext,
7779
mutation.newChildShadowView.props,
78-
RawProps(std::move(modifiedProps)));
80+
RawProps(modifiedProps));
81+
#ifdef RN_SERIALIZABLE_STATE
82+
// Until Props 2.0 is shipped, android uses rawProps.
83+
// RawProps must be kept synced with C++ Animated as well
84+
// as props object.
85+
auto& castedProps =
86+
const_cast<Props&>(*modifiedNewChildShadowView.props);
87+
castedProps.rawProps = mergeDynamicProps(
88+
mutation.newChildShadowView.props->rawProps,
89+
modifiedProps,
90+
NullValueStrategy::Override);
91+
#endif
92+
7993
filteredMutations.emplace_back(ShadowViewMutation::UpdateMutation(
8094
mutation.oldChildShadowView,
8195
std::move(modifiedNewChildShadowView),

0 commit comments

Comments
 (0)