Skip to content

Commit 455c49c

Browse files
javachemeta-codesync[bot]
authored andcommitted
Cleanup fixImageSrcDimensionPropagation and remove duplicate setting of src and source (#56108)
Summary: Pull Request resolved: #56108 Feature flag was just added for gating while rolling out, no regressions found. Also removing duplicate setting of `src` prop, which was introduced in D54000899. Changelog: [Internal] Reviewed By: alanleedev Differential Revision: D96727336 fbshipit-source-id: 964faf5c4019f3c86a36d67d58bf34aef3910436
1 parent 0b7f031 commit 455c49c

4 files changed

Lines changed: 24 additions & 71 deletions

File tree

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

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import type {HostInstance} from '../../src/private/types/HostInstance';
1212
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
1313
import type {RootTag} from '../Types/RootTagTypes';
1414
import type {ImageProps} from './ImageProps';
15-
import type {ImageSourceHeaders} from './ImageSourceUtils';
1615
import type {AbstractImageAndroid, ImageAndroid} from './ImageTypes.flow';
1716

18-
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
1917
import flattenStyle from '../StyleSheet/flattenStyle';
2018
import StyleSheet from '../StyleSheet/StyleSheet';
2119
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
@@ -196,55 +194,37 @@ let BaseImage: AbstractImageAndroid = ({
196194
);
197195
}
198196

199-
let style_: ImageStyleProp;
200-
let sources_;
201-
let headers_: ?ImageSourceHeaders;
197+
const nativeProps = restProps as {
198+
...React.PropsOf<ImageViewNativeComponent>,
199+
};
200+
202201
if (Array.isArray(source_)) {
203202
const {
204203
headers: sourceHeaders,
205204
width: sourceWidth,
206205
height: sourceHeight,
207206
} = source_[0];
208-
headers_ = sourceHeaders;
209-
// Default to the first source's width and height if only one is provided
210-
if (ReactNativeFeatureFlags.fixImageSrcDimensionPropagation()) {
211-
style_ = [
212-
source_.length === 1 && {width: sourceWidth, height: sourceHeight},
213-
styles.base,
214-
style,
215-
];
216-
} else {
217-
style_ = [styles.base, style];
207+
if (sourceHeaders != null) {
208+
nativeProps.headers = sourceHeaders;
218209
}
219-
sources_ = source_;
210+
// Default to the first source's width and height if only one is provided
211+
nativeProps.style = [
212+
source_.length === 1 && {width: sourceWidth, height: sourceHeight},
213+
styles.base,
214+
style,
215+
];
216+
nativeProps.source = source_;
220217
} else {
221218
const {uri, width: sourceWidth, height: sourceHeight} = source_;
222219
if (uri === '') {
223220
console.warn('source.uri should not be an empty string');
224221
}
225-
style_ = [
222+
nativeProps.style = [
226223
{width: sourceWidth ?? width, height: sourceHeight ?? height},
227224
styles.base,
228225
style,
229226
];
230-
sources_ = [source_];
231-
}
232-
233-
const nativeProps = restProps as {
234-
...React.PropsOf<ImageViewNativeComponent>,
235-
};
236-
237-
// Both iOS and C++ sides expect to have "source" prop, whereas on Android it's "src"
238-
// (for historical reasons). So in the latter case we populate both "src" and "source",
239-
// in order to have a better alignment between platforms in the future.
240-
// TODO: `src` should be eventually removed from the API on Android.
241-
nativeProps.src = sources_;
242-
nativeProps.source = sources_;
243-
244-
nativeProps.style = style_;
245-
246-
if (headers_ != null) {
247-
nativeProps.headers = headers_;
227+
nativeProps.source = [source_];
248228
}
249229

250230
if (onLoadStart != null) {

packages/react-native/Libraries/Image/__tests__/Image-itest.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @flow strict-local
8-
* @fantom_flags fixImageSrcDimensionPropagation:*
98
* @format
109
*/
1110

1211
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1312

1413
import type {AccessibilityProps, HostInstance} from 'react-native';
1514

16-
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
1715
import * as Fantom from '@react-native/fantom';
1816
import * as React from 'react';
1917
import {createRef} from 'react';
@@ -477,23 +475,14 @@ describe('<Image>', () => {
477475
.getRenderedOutput({props: ['source', 'width', 'height']})
478476
.toJSX(),
479477
).toEqual(
480-
ReactNativeFeatureFlags.fixImageSrcDimensionPropagation() ? (
481-
<rn-image
482-
source-scale="1"
483-
source-type="remote"
484-
source-size="{40, 40}"
485-
source-uri="https://reactnative.dev/img/tiny_logo.png"
486-
width="40"
487-
height="40"
488-
/>
489-
) : (
490-
<rn-image
491-
source-scale="1"
492-
source-type="remote"
493-
source-size="{40, 40}"
494-
source-uri="https://reactnative.dev/img/tiny_logo.png"
495-
/>
496-
),
478+
<rn-image
479+
source-scale="1"
480+
source-type="remote"
481+
source-size="{40, 40}"
482+
source-uri="https://reactnative.dev/img/tiny_logo.png"
483+
width="40"
484+
height="40"
485+
/>,
497486
);
498487
});
499488
});

packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,16 +1076,6 @@ const definitions: FeatureFlagDefinitions = {
10761076
},
10771077
ossReleaseStage: 'none',
10781078
},
1079-
fixImageSrcDimensionPropagation: {
1080-
defaultValue: true,
1081-
metadata: {
1082-
description:
1083-
'Fix image dimensions not being passed through when src is used',
1084-
expectedReleaseValue: true,
1085-
purpose: 'release',
1086-
},
1087-
ossReleaseStage: 'none',
1088-
},
10891079
fixVirtualizeListCollapseWindowSize: {
10901080
defaultValue: false,
10911081
metadata: {

packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<8c2aa180526563dbaaeb91f1428e0c77>>
7+
* @generated SignedSource<<d929e85924c23746edd258449cdb2d42>>
88
* @flow strict
99
* @noformat
1010
*/
@@ -34,7 +34,6 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
3434
deferFlatListFocusChangeRenderUpdate: Getter<boolean>,
3535
disableMaintainVisibleContentPosition: Getter<boolean>,
3636
externalElementInspectionEnabled: Getter<boolean>,
37-
fixImageSrcDimensionPropagation: Getter<boolean>,
3837
fixVirtualizeListCollapseWindowSize: Getter<boolean>,
3938
isLayoutAnimationEnabled: Getter<boolean>,
4039
shouldUseAnimatedObjectForTransform: Getter<boolean>,
@@ -170,11 +169,6 @@ export const disableMaintainVisibleContentPosition: Getter<boolean> = createJava
170169
*/
171170
export const externalElementInspectionEnabled: Getter<boolean> = createJavaScriptFlagGetter('externalElementInspectionEnabled', true);
172171

173-
/**
174-
* Fix image dimensions not being passed through when src is used
175-
*/
176-
export const fixImageSrcDimensionPropagation: Getter<boolean> = createJavaScriptFlagGetter('fixImageSrcDimensionPropagation', true);
177-
178172
/**
179173
* Fixing an edge case where the current window size is not properly calculated with fast scrolling. Window size collapsed to 1 element even if windowSize more than the current amount of elements
180174
*/

0 commit comments

Comments
 (0)