Skip to content

Commit

Permalink
Fix C++ prop type for the Image.defaultSource
Browse files Browse the repository at this point in the history
Summary:
`defaultSource` is defined as a single `ImageSource` in docs (https://reactnative.dev/docs/next/image#defaultsource) but its type is a vector of `ImageSource`s in `ImageProps.h`.

This diff changes its C++ type to just `ImageSource`.

Technically, this is a breaking change, however I don't think folks should directly access `ImageProps` outside of `RCTImageComponentView.mm`
Moreover, this prop is actually not implemented in Fabric, so this change should have no practical effect.

Changelog: [Internal]

Facebook
T208171435 - [RN][Fabric][iOS] Implement defaultSource support for Image

Differential Revision: D65821570
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Nov 19, 2024
1 parent 1f146a5 commit 8e43b44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ ImageProps::ImageProps(
"source",
sourceProps.sources,
{})),
defaultSources(
defaultSource(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.defaultSources
? sourceProps.defaultSource
: convertRawProp(
context,
rawProps,
"defaultSource",
sourceProps.defaultSources,
sourceProps.defaultSource,
{})),
resizeMode(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
Expand Down Expand Up @@ -95,7 +95,7 @@ void ImageProps::setProp(

switch (hash) {
RAW_SET_PROP_SWITCH_CASE(sources, "source");
RAW_SET_PROP_SWITCH_CASE(defaultSources, "defaultSource");
RAW_SET_PROP_SWITCH_CASE(defaultSource, "defaultSource");
RAW_SET_PROP_SWITCH_CASE_BASIC(resizeMode);
RAW_SET_PROP_SWITCH_CASE_BASIC(blurRadius);
RAW_SET_PROP_SWITCH_CASE_BASIC(capInsets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ImageProps final : public ViewProps {
#pragma mark - Props

ImageSources sources{};
ImageSources defaultSources{};
ImageSource defaultSource{};
ImageResizeMode resizeMode{ImageResizeMode::Stretch};
Float blurRadius{};
EdgeInsets capInsets{};
Expand Down

0 comments on commit 8e43b44

Please sign in to comment.