mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Revert D96727336 (#56142)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56142 reverting Changelog: [Internal] --- Reviewed By: fkgozali Differential Revision: D97213707 fbshipit-source-id: 1fc070d0399535bddf8ec3b5aeb060a97d6aa16f
This commit is contained in:
1 parent
0f92aa6213
commit
540120a527
4 files changed
+71
-24
No files matched your search
@@ -12,8 +12,10 @@ import type {HostInstance} from '../../src/private/types/HostInstance';
|
||||
import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
|
||||
import type {RootTag} from '../Types/RootTagTypes';
|
||||
import type {ImageProps} from './ImageProps';
|
||||
import type {ImageSourceHeaders} from './ImageSourceUtils';
|
||||
import type {AbstractImageAndroid, ImageAndroid} from './ImageTypes.flow';
|
||||
|
||||
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
|
||||
import flattenStyle from '../StyleSheet/flattenStyle';
|
||||
import StyleSheet from '../StyleSheet/StyleSheet';
|
||||
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
|
||||
@@ -194,37 +196,55 @@ let BaseImage: AbstractImageAndroid = ({
|
||||
);
|
||||
}
|
||||
|
||||
const nativeProps = restProps as {
|
||||
...React.PropsOf<ImageViewNativeComponent>,
|
||||
};
|
||||
|
||||
let style_: ImageStyleProp;
|
||||
let sources_;
|
||||
let headers_: ?ImageSourceHeaders;
|
||||
if (Array.isArray(source_)) {
|
||||
const {
|
||||
headers: sourceHeaders,
|
||||
width: sourceWidth,
|
||||
height: sourceHeight,
|
||||
} = source_[0];
|
||||
if (sourceHeaders != null) {
|
||||
nativeProps.headers = sourceHeaders;
|
||||
}
|
||||
headers_ = sourceHeaders;
|
||||
// Default to the first source's width and height if only one is provided
|
||||
nativeProps.style = [
|
||||
source_.length === 1 && {width: sourceWidth, height: sourceHeight},
|
||||
styles.base,
|
||||
style,
|
||||
];
|
||||
nativeProps.source = source_;
|
||||
if (ReactNativeFeatureFlags.fixImageSrcDimensionPropagation()) {
|
||||
style_ = [
|
||||
source_.length === 1 && {width: sourceWidth, height: sourceHeight},
|
||||
styles.base,
|
||||
style,
|
||||
];
|
||||
} else {
|
||||
style_ = [styles.base, style];
|
||||
}
|
||||
sources_ = source_;
|
||||
} else {
|
||||
const {uri, width: sourceWidth, height: sourceHeight} = source_;
|
||||
if (uri === '') {
|
||||
console.warn('source.uri should not be an empty string');
|
||||
}
|
||||
nativeProps.style = [
|
||||
style_ = [
|
||||
{width: sourceWidth ?? width, height: sourceHeight ?? height},
|
||||
styles.base,
|
||||
style,
|
||||
];
|
||||
nativeProps.source = [source_];
|
||||
sources_ = [source_];
|
||||
}
|
||||
|
||||
const nativeProps = restProps as {
|
||||
...React.PropsOf<ImageViewNativeComponent>,
|
||||
};
|
||||
|
||||
// Both iOS and C++ sides expect to have "source" prop, whereas on Android it's "src"
|
||||
// (for historical reasons). So in the latter case we populate both "src" and "source",
|
||||
// in order to have a better alignment between platforms in the future.
|
||||
// TODO: `src` should be eventually removed from the API on Android.
|
||||
nativeProps.src = sources_;
|
||||
nativeProps.source = sources_;
|
||||
|
||||
nativeProps.style = style_;
|
||||
|
||||
if (headers_ != null) {
|
||||
nativeProps.headers = headers_;
|
||||
}
|
||||
|
||||
if (onLoadStart != null) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @fantom_flags fixImageSrcDimensionPropagation:*
|
||||
* @format
|
||||
*/
|
||||
|
||||
@@ -12,6 +13,7 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
|
||||
|
||||
import type {AccessibilityProps, HostInstance} from 'react-native';
|
||||
|
||||
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
||||
import * as Fantom from '@react-native/fantom';
|
||||
import * as React from 'react';
|
||||
import {createRef} from 'react';
|
||||
@@ -475,14 +477,23 @@ describe('<Image>', () => {
|
||||
.getRenderedOutput({props: ['source', 'width', 'height']})
|
||||
.toJSX(),
|
||||
).toEqual(
|
||||
<rn-image
|
||||
source-scale="1"
|
||||
source-type="remote"
|
||||
source-size="{40, 40}"
|
||||
source-uri="https://reactnative.dev/img/tiny_logo.png"
|
||||
width="40"
|
||||
height="40"
|
||||
/>,
|
||||
ReactNativeFeatureFlags.fixImageSrcDimensionPropagation() ? (
|
||||
<rn-image
|
||||
source-scale="1"
|
||||
source-type="remote"
|
||||
source-size="{40, 40}"
|
||||
source-uri="https://reactnative.dev/img/tiny_logo.png"
|
||||
width="40"
|
||||
height="40"
|
||||
/>
|
||||
) : (
|
||||
<rn-image
|
||||
source-scale="1"
|
||||
source-type="remote"
|
||||
source-size="{40, 40}"
|
||||
source-uri="https://reactnative.dev/img/tiny_logo.png"
|
||||
/>
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1076,6 +1076,16 @@ const definitions: FeatureFlagDefinitions = {
|
||||
},
|
||||
ossReleaseStage: 'none',
|
||||
},
|
||||
fixImageSrcDimensionPropagation: {
|
||||
defaultValue: true,
|
||||
metadata: {
|
||||
description:
|
||||
'Fix image dimensions not being passed through when src is used',
|
||||
expectedReleaseValue: true,
|
||||
purpose: 'release',
|
||||
},
|
||||
ossReleaseStage: 'none',
|
||||
},
|
||||
fixVirtualizeListCollapseWindowSize: {
|
||||
defaultValue: false,
|
||||
metadata: {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<d929e85924c23746edd258449cdb2d42>>
|
||||
* @generated SignedSource<<8c2aa180526563dbaaeb91f1428e0c77>>
|
||||
* @flow strict
|
||||
* @noformat
|
||||
*/
|
||||
@@ -34,6 +34,7 @@ export type ReactNativeFeatureFlagsJsOnly = $ReadOnly<{
|
||||
deferFlatListFocusChangeRenderUpdate: Getter<boolean>,
|
||||
disableMaintainVisibleContentPosition: Getter<boolean>,
|
||||
externalElementInspectionEnabled: Getter<boolean>,
|
||||
fixImageSrcDimensionPropagation: Getter<boolean>,
|
||||
fixVirtualizeListCollapseWindowSize: Getter<boolean>,
|
||||
isLayoutAnimationEnabled: Getter<boolean>,
|
||||
shouldUseAnimatedObjectForTransform: Getter<boolean>,
|
||||
@@ -169,6 +170,11 @@ export const disableMaintainVisibleContentPosition: Getter<boolean> = createJava
|
||||
*/
|
||||
export const externalElementInspectionEnabled: Getter<boolean> = createJavaScriptFlagGetter('externalElementInspectionEnabled', true);
|
||||
|
||||
/**
|
||||
* Fix image dimensions not being passed through when src is used
|
||||
*/
|
||||
export const fixImageSrcDimensionPropagation: Getter<boolean> = createJavaScriptFlagGetter('fixImageSrcDimensionPropagation', true);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user