Skip to content

Commit 88cf30a

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Add backgroundImage prop diffing to View (facebook#54042)
Summary: Pull Request resolved: facebook#54042 Update the View component props to diff the `backgroundImage` property and assign the value to `experimental_backgroundImage` which maps to the `backgroundImage` property on the Android `ReactViewManager`. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D83788008 fbshipit-source-id: 5f9d93403af483c9494d2782aedad604cbb7cbbc
1 parent d9d3b3e commit 88cf30a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
663663
result["filter"] = toDynamic(filter);
664664
}
665665

666+
if (backgroundImage != oldProps->backgroundImage) {
667+
result["experimental_backgroundImage"] = toDynamic(backgroundImage);
668+
}
669+
666670
if (mixBlendMode != oldProps->mixBlendMode) {
667671
result["mixBlendMode"] = toString(mixBlendMode);
668672
}

packages/react-native/ReactCommon/react/renderer/graphics/BackgroundImage.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,15 @@ namespace facebook::react {
1616

1717
using BackgroundImage = std::variant<LinearGradient, RadialGradient>;
1818

19+
#ifdef RN_SERIALIZABLE_STATE
20+
inline folly::dynamic toDynamic(const BackgroundImage& backgroundImage) {
21+
if (std::holds_alternative<LinearGradient>(backgroundImage)) {
22+
return std::get<LinearGradient>(backgroundImage).toDynamic();
23+
} else if (std::holds_alternative<RadialGradient>(backgroundImage)) {
24+
return std::get<RadialGradient>(backgroundImage).toDynamic();
25+
}
26+
return folly::dynamic(nullptr);
27+
}
28+
#endif
29+
1930
}; // namespace facebook::react

0 commit comments

Comments
 (0)