Skip to content

Commit f3e132b

Browse files
rshestfacebook-github-bot
authored andcommitted
Correctly pass Image.source attribute to the C++ side (#43129)
Summary: Pull Request resolved: #43129 ## Changelog: [Internal] - C++ side expects "source" property to be an up to date, correctly resolved Image source inside `ImageProps`. Incidentally, it wasn't the case when: * we build for an Android platform * the asset is a "packager asset", i.e. bundled by Metro and included in APK It hasn't been an issue in the case of "pure" Android platform, as it instead uses "src" prop, instead of source on the Java implementation side, ignoring "source" completely, so the fact that "source" wasn't propagated correctly to C++ in some cases didn't affect Android. However, there are some new use cases where we'd like to have correct "source" value in C++ as well (and ultimately align this between all the platforms, so it's "source" everywhere, but this is a matter of a separate discussion). Differential Revision: D54000899 fbshipit-source-id: 9bfb9e7c157cf19ddf396c141b03b75f3b2022e8
1 parent ee2bc59 commit f3e132b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/react-native/Libraries/Image/Image.android.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
171171
...restProps,
172172
style,
173173
shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd || onError),
174+
// Both iOS and C++ sides expect to have "source" prop, whereas on Android it's "src"
175+
// (for historical reasons). So in the latter case we populate both "src" and "source",
176+
// in order to have a better alignment between platforms in the future.
174177
src: sources,
178+
source: sources,
175179
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
176180
* when making Flow check .android.js files. */
177181
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),

0 commit comments

Comments
 (0)