Skip to content

Commit

Permalink
Unify defaultSource and defaultSrc ImageProp (facebook#47710)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#47710

There is Android code that supports remapping `defaultSrc` -> `defaultSource` for `ImageNativeComponent`.
The docs reference this prop as `defaultSource`: https://reactnative.dev/docs/next/image#defaultsource
It is not referenced as `defaultSrc` anywhere. Let's unify it as `defaultSource` across both platforms.
Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65819218

fbshipit-source-id: 0f468e2327ad07285a45e4c9f5e33d74da411c74
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Nov 19, 2024
1 parent 6f1cf00 commit abeee15
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
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

0 comments on commit abeee15

Please sign in to comment.