Skip to content

Commit 376183e

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Fix ImageProps default values (#54545)
Summary: Pull Request resolved: #54545 Changelog: [Internal] Currently these default values https://reactnative.dev/docs/image#resizemethod-android https://reactnative.dev/docs/image#resizemultiplier-android are not correctly treated in C++ code as parsing bails out here: https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/renderer/core/propsConversions.h#L176-L177 By setting default values in the struct, we can fix it Reviewed By: sbuggay Differential Revision: D87083023 fbshipit-source-id: b8e16d0f6732392bafee01848c1c516e91ab806b
1 parent 5d9cb80 commit 376183e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ImageProps::ImageProps(
9898
rawProps,
9999
"resizeMethod",
100100
sourceProps.resizeMethod,
101-
{})),
101+
{"auto"})),
102102
resizeMultiplier(
103103
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
104104
? sourceProps.resizeMultiplier
@@ -107,7 +107,7 @@ ImageProps::ImageProps(
107107
rawProps,
108108
"resizeMultiplier",
109109
sourceProps.resizeMultiplier,
110-
{})),
110+
1)),
111111
shouldNotifyLoadEvents(
112112
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
113113
? sourceProps.shouldNotifyLoadEvents

packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ImageProps final : public ViewProps {
3333
EdgeInsets capInsets{};
3434
SharedColor tintColor{};
3535
std::string internal_analyticTag{};
36-
std::string resizeMethod{};
37-
Float resizeMultiplier{};
36+
std::string resizeMethod{"auto"};
37+
Float resizeMultiplier{1.f};
3838
bool shouldNotifyLoadEvents{};
3939
SharedColor overlayColor{};
4040
Float fadeDuration{};

0 commit comments

Comments
 (0)