Skip to content

Commit 1f146a5

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Unify defaultSource and defaultSrc ImageProp (facebook#47710)
Summary: 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] Differential Revision: D65819218
1 parent bdf01be commit 1f146a5

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
133133
width: undefined,
134134
height: undefined,
135135
};
136-
const defaultSource = resolveAssetSource(props.defaultSource);
137136
const loadingIndicatorSource = resolveAssetSource(
138137
props.loadingIndicatorSource,
139138
);
@@ -179,7 +178,6 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
179178
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
180179
* when making Flow check .android.js files. */
181180
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
182-
defaultSrc: defaultSource ? defaultSource.uri : null,
183181
loadingIndicatorSrc: loadingIndicatorSource
184182
? loadingIndicatorSource.uri
185183
: null,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
8282
},
8383
validAttributes: {
8484
blurRadius: true,
85+
defaultSource: {
86+
process: require('./resolveAssetSource'),
87+
},
8588
internal_analyticTag: true,
8689
resizeMethod: true,
8790
resizeMode: true,
@@ -100,7 +103,6 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
100103
borderRadius: true,
101104
headers: true,
102105
shouldNotifyLoadEvents: true,
103-
defaultSrc: true,
104106
overlayColor: {
105107
process: require('../StyleSheet/processColor').default,
106108
},

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ public constructor(
124124
}
125125
}
126126

127-
// In JS this is Image.props.defaultSource
128-
@ReactProp(name = "defaultSrc")
127+
@ReactProp(name = "defaultSource")
129128
public fun setDefaultSource(view: ReactImageView, source: String?) {
130129
view.setDefaultSource(source)
131130
}

0 commit comments

Comments
 (0)