Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C++ prop type for the Image.defaultSource #47713

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/react-native/Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
width: undefined,
height: undefined,
};
const defaultSource = resolveAssetSource(props.defaultSource);
const loadingIndicatorSource = resolveAssetSource(
props.loadingIndicatorSource,
);
Expand Down Expand Up @@ -179,7 +178,6 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
* when making Flow check .android.js files. */
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
defaultSrc: defaultSource ? defaultSource.uri : null,
loadingIndicatorSrc: loadingIndicatorSource
? loadingIndicatorSource.uri
: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
},
validAttributes: {
blurRadius: true,
defaultSource: {
process: require('./resolveAssetSource'),
},
internal_analyticTag: true,
resizeMethod: true,
resizeMode: true,
Expand All @@ -100,7 +103,6 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
borderRadius: true,
headers: true,
shouldNotifyLoadEvents: true,
defaultSrc: true,
overlayColor: {
process: require('../StyleSheet/processColor').default,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public constructor(
}
}

// In JS this is Image.props.defaultSource
@ReactProp(name = "defaultSrc")
@ReactProp(name = "defaultSource")
public fun setDefaultSource(view: ReactImageView, source: String?) {
view.setDefaultSource(source)
}
Expand Down
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
Loading